The embedding is done by creating a YAAFI instance using the ServiceContainerFactory.create() method. Technically there are two ways to create a YAAFI container
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);
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=