2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Jakarta > HiveMind
Font size:      

hivemind.lib.StrategyFactory Service

The StrategyFactory service is used to create a service implementation based on a service interface and a number of strategies implementing that interface.

The class of the first parameter of each method is used to select the correct strategy instance to delegate the method invocation to.

The class-to-strategy lookup understands inheritance. If an exact match for a class is not found, then the search works up the inheritance chain. First, it checks all the super-classes, working upwards, but skipping java.lang.Object. It then searches all the interfaces directly or indirectly implemented by the search class. Finally, java.lang.Object is checked. It is an exception if no match is found (so you should almost always include a strategy for java.lang.Object).


The factory expects a single parameter element:

<construct configuration-id="..."/>

The configuration-id is the id of the companion configuration (used to define classes and strategies).


Each srevice constructed by StrategyFactory must have a configuration, into which strategies are contributed:

<configuration-point id="..." schema-id="hivemind.lib.StrategyRegistry"/>


Contributions into the configuration are used to specify classes to match, and the corresponding strategy to use.


<strategy class="..." object="..."/> 

Contributes a strategy. The class attribute defines the class to match against, the object attribute provides the actual strategy object (which must implement the service interface).