<?xml version="1.0"?>
<!-- 
   Copyright 2005 The Apache Software Foundation

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->

<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" "http://xml.apache.org/forrest/dtd/document-v13.dtd" [
  <!ENTITY % common-links SYSTEM "links.ent">
  %common-links;
  ]>
<document>
  <header>
    <title>Lightweight Instance Initialization</title>
  </header>
  <body>
    <p> There are frequently situations in which you want HiveMind to create an instance of an object for you, and initialize some of its properties. </p>
    <p> The &hivemind.BuilderFactory; can do this ... but it means dressing up your instance as a complete service, which can be cumbersome and overkill. </p>
    <p> In HiveMind 1.0, you didn't have many other options. Starting with HiveMind 1.1, you do: <em>lightweight instance initialization</em>. </p>
    <p> In certain places where you specify a class name (&create-instance;, &create-object;, the <link href="rules.html#instance">instance translator</link> and the <link href="site:hivemind.ObjectProviders">instance object provider</link>), you can further identify a list of properties and values. The values are always strings and are converted to appropriate types for assignment. </p>
    <p> 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: <code>com.example.MyBean,name=Bean,priority=10</code>. </p>
    <p> For properties that are boolean, you can omit the equals sign and value. The value 'true' is assumed. Example: <code>com.example.MyBean,required</code> would set the required property of the bean to true. </p>
    <p> Alternately, you can prefix the boolean property name with an exclamation point to set the value to false. Example: <code>com.example.MyBean,!required</code> </p>
    <p> These object instantiations and initializations occur within a reference module; you can omit the module's package from the class name. </p>
  </body>
</document>