Avalon Component Service

The Yaafi Component service loads external modules which implement the Avalon lifecycle interfaces. This is a bridge between the Turbine 2.3 we have today and the Fulcrum components that until now have only been available to Turbine 2.4 (yet to be released).

Most of the Fulcrum components should work using this service, however it is only being added in Turbine 2.3.3, so you should ensure that you perform your own testing to verify the desired behaviour of your application, though note that the author is successfully running Torque, Fulcrum Quartz as well as making use for Yaafi's ServiceManager and SystemProperty services - all under Turbine 2.3.

Dependencies

If you are using Yaafi Component Service you will need to add Yaafi as a dependency (the following is from a Maven 2 POM):

    <dependency>
      <groupId>fulcrum</groupId>
      <artifactId>fulcrum-yaafi</artifactId>
      <version>1.0.4</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>

If you are no longer using the Avalon Component Service you can stop your build from including the Excalibur dependencies thus (again from a Maven 2 POM):

    <!--
    There are a few Turbine dependencies, included for the AvalonComponentService,
    that are not needed when using YaafiComponentService as a replacement.
    -->
    <dependency>
      <groupId>org.apache.turbine</groupId>
      <artifactId>turbine</artifactId>
      <version>2.3.2</version>
      <type>jar</type>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <groupId>excalibur-component</groupId>
          <artifactId>excalibur-component</artifactId>
        </exclusion>
        <exclusion>
          <groupId>junitperf</groupId>
          <artifactId>junitperf</artifactId>
        </exclusion>
        <exclusion>
          <groupId>excalibur-instrument</groupId>
          <artifactId>excalibur-instrument-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>excalibur-logger</groupId>
          <artifactId>excalibur-logger</artifactId>
        </exclusion>
        <exclusion>
          <groupId>excalibur-pool</groupId>
          <artifactId>excalibur-pool-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

The above is based on the turbine-2.3.2 pom that exists in the default maven 2 repository. Whether or not you need the above will depend on how these dependencies are declared in the final version of the Turbine 2.3.3 POM (just including Yaafi should be enough if they are all declared as optional).

Configuration

# -------------------------------------------------------------------
#
#  S E R V I C E S
#
# -------------------------------------------------------------------
# Classes for Turbine Services should be defined here.
# Format: services.[name].classname=[implementing class]
#
# To specify properties of a service use the following syntax:
# service.[name].[property]=[value]

services.YaafiComponentService.classname=org.apache.turbine.services.avaloncomponent.ACSYaafiComponentService
services.YaafiComponentService.earlyInit=true
...

# -------------------------------------------------------------------
#
#  Y A A F I   C O M P O N E N T   S E R V I C E
#
# -------------------------------------------------------------------
# Components implementing the avalon lifecycle interfaces can be
# loaded, configured and initialized by Turbine
# -------------------------------------------------------------------

services.YaafiComponentService.containerConfiguration = /WEB-INF/conf/containerConfiguration.xml

In /WEB-INF/conf you should provide containerConfiguration.xml:

<fulcrum-yaafi>
  <componentRoles>
    <location>/WEB-INF/conf/componentRoles.xml</location>
  </componentRoles>
  <componentConfiguration>
    <location>/WEB-INF/conf/componentConfiguration.xml</location>
  </componentConfiguration>
</fulcrum-yaafi>

componentRoles.xml:

<role-list>
    <role name="org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerService"
          default-class="org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerServiceImpl"/>
    <role name="org.apache.fulcrum.yaafi.service.systemproperty.SystemPropertyService"
          shorthand="SystemPropertyService"
          default-class="org.apache.fulcrum.yaafi.service.systemproperty.SystemPropertyServiceImpl"
          early-init="true"/>
    <role name="org.apache.torque.avalon.Torque"
          shorthand="torque"
          default-class="org.apache.torque.avalon.TorqueComponent"/>
    <!-- Details of other components and services you want to use. -->
</role-list>

and componentConfiguration.xml:

<componentConfig>
    <SystemPropertyService>
        <property name="my.property">my property value</property>
    </SystemPropertyService>

    <torque>
        <configfile>WEB-INF/conf/Torque.properties</configfile>
    </torque>

    <!-- Configuration for other components and services. -->
</componentConfig>

No changes to torque.properties are required.

If all goes well you should see the following in your log file when Turbine starts up (actual output will depend on your logging configuration):

...INFO...services.BaseServiceBroker - Added Mapping for Service: ACSYaafiComponentService
...INFO...services.BaseServiceBroker - Start Initializing service (early): ACSYaafiComponentService
...INFO...avaloncomponent.ACSYaafiComponentService - Initializing ACSYaafiComponentService ...
...
...DEBUG...avalon - Incarnating the service org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerService
...
...DEBUG...avalon - Incarnating the service SystemPropertyService
...
...DEBUG...avalon - Incarnating the service torque
...INFO...avalon - YAAFI Avalon Service Container is up and running
...INFO...services.BaseServiceBroker - Finish Initializing service (early): ACSYaafiComponentService

Usage

If you plan to use the decoupled Torque in your application, you should leave the Yaafi Component Service configured at all times. It is started at early startup time. See the Yaafi documentation for more information and for details of the various services that it provides and the Fulcrum site for details of the other components that are available.