The Apache Jakarta Project Jakarta HiveMind Project
 
   

hivemind.lib.PipelineFactory Service

The PipelineFactory services is used to construct a pipeline consisting of a series of filters. The filters implement an interface related to the service interface.

Each method of the service interface has a corresponding method in the filter interface with an identical signature, except that an additional parameter, whose type matches the service interface has been added.

For example, a service interface for transforming a string:

package mypackage; 

public interface StringTransformService
{
  public String transform(String inputValue); 
} 

The corresponding filter interface:

package mypackage;

public interface StringTransformFilter
{
  public String transform(String inputValue, StringTransformService service);
}

The service parameter may appear at any point in the parameter list, though the convention of listing it last is recommended.

The filters in a pipeline are chained together as follows:

Pipeline Calling Sequence

The bridge objects implement the service interface (and are created dynamically at runtime). The terminator at the end also implements the service interface. This can be an object or a service; if no terminator is specified, a default implementation is created and used. Only a single terminator is allowed.

A pipeline is always created in terms of a service and a configuration. The service defines the service interface and identifies a configuration. The configuration conforms to the hivemind.lib.Pipeline schema and is used to specify filters and the terminator. Filters may be ordered much like <interceptor>s, using before and after attributes. This allows different modules to contribute filters into the service's pipeline.

Usage

The general usage is as follows:

invoke-factory (service-id=hivemind.lib.PipelineFactory)
{
  create-pipeline (filter-interface=... configuration-id=... terminator-service-id=...)
}

The filter-interface attribute is the complete class name of the filter interface.

The configuration-id is the id of the companion configuration (used to define filters).

The optional terminator-service-id attribute is used to specify a terminator service directly (a terminator may also be contributed into the pipline configuration).

Configuration

Each pipeline service must have a configuration, into which filters are contributed:

configuration-point (id=... schema-id=hivemind.lib.Pipeline)
   

Contributions

Contributions into the configuration are used to specify the filters and the terminator. Filters and terminators can be specified as services or as objects.

filter

filter (service-id=... before=... after=...)
 

Contributes a filter as a service. The optional before and after attributes are lists of the ids of other filters in the pipeline, used to set the ordering of the filters. They may be comma-seperated lists of filter ids (or filter names), or simple * to indicate absolute positioning.

filter-bean

filter-bean (name=... before=... after=...)

Contributes a bean (from a BeanFactory). The name is of the format service-id:name[,initializer]

filter-object

filter-object (name=... class=... before=... after=...)

Contributes a filter as an instance of the provided class. The name attribute is required and will be qualified with the contributing module id. before and after are optional, as with the <filter> element.

terminator

terminator (service-id=...)

Specifies the terminator service for the pipeline. Only a single terminator may be specified, and the terminator service provided in the factory parameters takes precendence over a terminator in the configuration.

terminator-bean

terminator-bean (name=...)

Contributes a terminator as a bean from a BeanFactory service.

terminator-object

terminator-object (class=...)

Specifies the termnator for the pipeline as an object (intead of as a service).