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

For more information, please explore the Attic.

Apache > HiveMind
Apache
 
Font size:      

Lightweight Instance Initialization

There are frequently situations in which you want HiveMind to create an instance of an object for you, and initialize some of its properties.

The hivemind.BuilderFactory can do this ... but it means dressing up your instance as a complete service, which can be cumbersome and overkill.

In HiveMind 1.0, you didn't have many other options. Starting with HiveMind 1.1, you do: lightweight instance initialization.

In certain places where you specify a class name (<create-instance>, <create-object>, the instance translator and the instance object provider), you can further identify a list of properties and values. The values are always strings and are converted to appropriate types for assignment.

The class name is seperated from the property values by a comma, and a comma seperates each property value pair. An equals sign seperates each property from its value. The end result is quite readable: com.example.MyBean,name=Bean,priority=10.

For properties that are boolean, you can omit the equals sign and value. The value 'true' is assumed. Example: com.example.MyBean,required would set the required property of the bean to true.

Alternately, you can prefix the boolean property name with an exclamation point to set the value to false. Example: com.example.MyBean,!required

These object instantiations and initializations occur within a reference module; you can omit the module's package from the class name.