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

For more information, please explore the Attic.

Jakarta > HiveMind
Font size:      

hivemind.lib.BeanFactoryBuilder Service

The BeanFactoryBuilder services is used to construct a BeanFactory instance. An BeanFactory will vend out instances of classes. A logical name is mapped to a particular Java class to be instantiated.

Client code can retrieve beans via the factory's get() method. Beans are retrieved using a locator, which consists of a name and an optional initializer seperated by commas. The initializer is provided to the bean via an alternate constructor that takes a single string parameter. Initializers are used, typically, to initialize properties of the bean, but the actual implementation is internal to the bean class.


The service takes a single parameter element:

<factory vend-class="..." configuration-id="..." default-cacheable="..."/>

The vend-class attribute is the name of a class all vended objects must be assignable to (as a class or interface). This is used to validate contributed bean definitions. By default it is java.lang.Object.

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

The optional default-cacheable attribute sets the default for whether instantiated beans should be cached for reuse. By default this is true, which is appropriate for most use cases where the vended objects are immutable.


Each BeanFactory service must have a configuration, into which beans are contributed:

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

Contributions into the configuration are used to specify the bean classes to instantiate, as:

<bean name="..." class="..." cacheable="..."/>  

name is a unique name used to reference an instance of the class.

class is the Java class to instantiate.

cacheable determines whether instances of the class are cacheable (that is, have immutable internal state and should be reused), or non-cacheable (presumably, because of mutable internal state).