Jakarta > HiveMind
Jakarta
 
Font size:      

hivemind.lib.AdapterRegistryFactory Service

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

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

The class-to-adapter 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 an adapter for java.lang.Object).

Usage

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 adapters).

Configuration

Each AdapterRegistry service must have a configuration, into which adapters are contributed:

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

Contributions

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

adapter

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

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