How-to: Create the core component with a custom credential provider

Use the com.alpha.pineapple.CoreFactory to create an instance of the core component with a custom credential provider.

First, create the core factory:

  // create core factory
  CoreFactory coreFactory = new CoreFactory();     

Then create the credential provider using the core factory:

  // define default pineapple home directory
  File homeDirectory = new File( "c:\pineapple-home" ); 
         
  // define conf directory
  File confDirectory = new File( homeDirectory, "conf" ); 
                        
  // initialize credential file
  File credentialsFile = new File( confDirectory, "credentials.xml" );

  // create credential provider
  CredentialProvider provider = coreFactory.createCredentialProvider(credentialsFile);        

Finally, create the core component is created using the core factory:

  // create core component  
  PineappleCore core = coreFactory.createCore( provider );    

How the core component will the load environment configuration

The location where the environment configuration is loaded from is determined by resolution of the runtime directories used by the core component.

With the the system property pineapple.home.dir defined

The core component will:

  • load resources from ${pineapple.home.dir}/conf/resources.xml.
  • load credentials from c:/pineapple-home/conf/credentials.xml.

Without the the system property pineapple.home.dir defined

The core component will:

  • load resources from ${user.home}/.pineapple/conf/resources.xml.
  • load credentials from c:/pineapple-home/conf/credentials.xml.

Please notice: The location where the credentials is loaded from can be customized by the credentialsFile argument to the CoreFactory.createCredentialProvider(credentialsFile) factory method.