The core component is the entry point into Pineapple. The core component is invoked by Pineapple clients such as Maven plugins, command line interface or web applications. The core component is used by creating an instance and then invoking operations which triggers the execution of zero or more plugins.
The core component implements these public methods:
The get access to the core component, add a Maven dependency in the client project which need access to the core component. The dependency is versioned, so select the appropriate version:
<dependency> <groupId>com.alpha.pineapple</groupId> <artifactId>pineapple-core</artifactId> <version>1.0</version> </dependency>
An instance of the core component is created using the factory com.alpha.pineapple.CoreFactory which provides methods for creating instances. The easiest way to create an instance is to invoke the method createCore() with no parameters. The method creates an instance with default settings:
Both the resources.xml and the credentials.xml file must adhere to the environment configuration schema.
Look here for an example of how to create the core component with default settings.
The purpose of a credential provider is to deliver security credentials to the core component on request. The provided credentials are used to access resources defined in the environment configuration.
A credential provider implements the com.alpha.pineapple.credential.CredentialProvider interface which is defined in the pineapple-api project.
The get(..) method is invoked by the core component when it requests a Credential object for a resource in a specific environment. The com.alpha.pineapple.model.configuration.Credential object is defined in the pineapple-api project.
The package com.alpha.pineapple.credential in the pineapple-core project contains implementations which can be used by clients:
Otherwise the client is free to provide its own implementation.
To create the core component with a custom credential provider invoke the method createCore(CredentialProvider provider) on the CoreFactory. The settings are:
The resources.xml file must adhere to the environment configuration schema.
Look here for an example of how to create the core component with a custom provider.
To create the core component with a custom credential provider and a alternative location for the resources file invoke the method createCore(CredentialProvider provider, File resources ) on the CoreFactory. The settings are:
The resources file must adhere to the environment configuration schema.
The core component implements the interface com.alpha.pineapple.PineappleCore which defines a single method for execution of operations:
public interface PineappleCore { ExecutionInfo executeOperation( String operation, String environment, String module ); // remaining methods here }
To execute an operation, invoke the method execute(..) with the arguments:
The core component implements the observer pattern to provide a facility for clients to be notified in real time of how the execution of an operation proceeds.
The core component has the role of subject in the observer pattern. To support the role, it provides the addListener( ResultListener listener ) method which should be used by observers to register themselves. The core component contain logic which notifies all registered observers during execution of an operation.
Clients should implement objects with the role of observer and register them with the core component to be notified of how the execution an operation proceeds. The client should use the feedback to provide appropriate feedback to the user. An example is the pineapple-application-war project which registers one observer:
An observer must implement the com.alpha.pineapple.execution.ResultListener interface:
public interface ResultListener { void notify(ExecutionResultNotification notification); }
Look here for an example of implement and register a result listener with the core component.
When Pineapple start execution of an operation then it internally builds a hierarchy of execution result objects which documents the execution of the operation. Execution result object implements the ExecutionResult interface. As the execution proceeds new execution results object are created and added to the hierarchy. When an execution path is completed the tracking execution result object has it state updated and it execution time stored.
The execution result object support these life cycle states:
Each time an execution result object changes it state, all registered observers are notified of the change.The notification is implemented by invoking notify(ExecutionResultNotification notification) on the each registered observer.
The argument is a notification object which contains:
To capture the state when listeners are notified the state is recorded separately in the notification. Since the state of an execution result is mutable, the recorded state in the notification might not match the state of the execution result since its state can have changed since the creation of the notification and the notification of the observers.
An observer can query the the execution result about its new state and additional info.
Look here for an example of how to register and invoke the report generator to create a report.