Fork me on GitHub

How To

How to write my own service?

  • Write your service interface and implementation using the Avalon Lifecycle interfaces.
  • Add an entry to the role configuration file. This entry contains the information how YAAFI can instantiate and access the service
  • Add an entry to the component configurating file if you need to configure your service.

How can I embed YAAFI in an application?

The embedding is done by creating a YAAFI instance using the ServiceContainerFactory.create() method. Technically there are two ways to create a YAAFI container

  • Provide all paramters by the caller
  • Use a containerConfiguration.xml

The following example creates a fully initialized and running YAAFI container with the given configuration parameters using a LOG4J logger.

Logger logger = new Log4JLogger( org.apache.log4j.Logger.getLogger("YAAFI");
ServiceContainer container = null;
ServiceContainerConfiguration config = new ServiceContainerConfiguration();
config.setLogger( logger );
config.setComponentRolesLocation( "./src/test/TestRoleConfig.xml" );
config.setComponentConfigurationLocation( "./src/test/TestComponentConfig.xml" );
config.setParametersLocation( "./src/test/TestParameters.properties" );
container = ServiceContainerFactory.create( config );
        

The following example uses a XML file to initialize the YAAFI container

ServiceContainer container = null;
ServiceContainerConfiguration config = new ServiceContainerConfiguration();
config.setContainerConfiguration( "./src/test/TestContainerConfig.xml", false );
container = ServiceContainerFactory.create( config );
        

At the end of day you have to terminate YAAFI

ServiceContainerFactory.dispose(container);
        

How can I embed YAAFI into Turbine?

In the 'contrib' directory there is a ready-to-use Turbine service which needs the following configuration (for Turbine 2.2)

services.YaafiComponentService.classname=org.apache.turbine.services.yafficomponent.TurbineYaafiComponentService
services.YaafiComponentService.componentRoles=./conf/componentRoles.xml
services.YaafiComponentService.componentConfiguration=./conf/componentConfiguration.xml
services.YaafiComponentService.parameters=