The report generator is intended for usage by Pineapple clients, i.e. object which create and invoke operations on the Pineapple core component.
The report generator is registered as an execution result listener with the core component and when execution of an operation is completed the report generator creates a HTML report at a designated location.
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-basic-html-generator</artifactId> <version>CURRENT_VERSION</version> </dependency>
Invoke the factory method BasicHtmlReportGeneratorImpl.getInstance(). The method creates an instance with the default settings:
Look here for an example of how to create the report generator with default settings.
Invoke the factory method BasicHtmlReportGeneratorImpl.getInstance(File rootDirectory) where rootDirectory defines the root directory where report sub directories should be created in:
Look here for an example of how to create the report generator with custom settings.
Alternatively, the report generator can be looked as a bean named reportGenerator in the Spring configuration file. If the report directory isn't initialized afterwards by invoking ReportGeneratorInfo.setReportDirectory(..) then the generator will create reports at the default location.
Invoke the method PineappleCore.addListener( listener ) with the report generator as argument to register it with the core component. The report generator is basically registered as an observer to events in the core component due to its implementation of the ResultListener interface.
Invoke the method PineappleCore.execute(..) on the core component to execute an operation. At some point, the root execution result within the core component, changes state from running to some completed state (failed, error or successful). The report generator is notified of this state change, due to its registration as an observer, when the core component invokes the method notifyOfResultStateChange(...) on the report generator. This invocation trigger the creation of the report.
Look here for an example of how register and invoke the report generator to create a report.
When the report is generated then two messages are added to the root execution result which triggered the report generation:
If the report generation fail then a message with the label Error Message is added with the stack trace from the exception.
The location of reports is configurable as an argument to the factory method BasicHtmlReportGeneratorImpl.getInstance(File reportDirectory). The reportDirectory parameter defines a the root directory where the generator will generate reports.
Alternatively, the report generator implements the interface ReportGeneratorInfo which contains the method setReportDirectory(..) which can be used to set the root directory.
Look here for an example of how to configure the root directory at runtime.
If no location is defined, i.e. the no-arg factory method BasicHtmlReportGeneratorImpl.getInstance() is used, or the generator is looked up from the Spring context, the generator will generate reports in the default root directory: ${user.home}/.pineapple/reports/