[jboss-cvs] JBossAS SVN: r64462 - projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 6 06:11:51 EDT 2007
Author: alesj
Date: 2007-08-06 06:11:51 -0400 (Mon, 06 Aug 2007)
New Revision: 64462
Modified:
projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml
Log:
ValueFactory, collection preinstantiated, aliases, fromContext.
Modified: projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml
===================================================================
--- projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml 2007-08-05 23:05:06 UTC (rev 64461)
+++ projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml 2007-08-06 10:11:51 UTC (rev 64462)
@@ -587,9 +587,68 @@
<section>
<title>Value Factory</title>
- <para>TODO - ValueFactory.
+ <para>Similar to using inject's property attribute, we sometimes want to use other beans to
+ create new values from bean's multi parameter methods.
</para>
+ <programlisting>
+ <bean name="PropHolder" class="org.jboss.test.kernel.config.support.PropHolder">
+ <property name="value">
+ <value-factory bean="ldap" method="getValue">
+ <parameter>xyz.key</parameter>
+ <parameter>xyz</parameter>
+ <parameter><bean name="t" class="org.jboss.test.kernel.config.support.TrimTransformer"/></parameter>
+ </value-factory>
+ </property>
+ </bean>
+
+ <bean name="ldap" class="org.jboss.test.kernel.config.support.LDAPFactory">
+ <constructor>
+ <parameter>
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>foo.bar.key</key>
+ <value>QWERT</value>
+ </entry>
+ <entry>
+ <key>xyz.key</key>
+ <value> QWERT </value>
+ </entry>
+ </map>
+ </parameter>
+ </constructor>
+ </bean>
+ </programlisting>
+
+ <para>For the quick usage there is also shorthand version of the value-factory element, having single parameter
+ as string attribute.
+ </para>
+
+ <programlisting>
+ <bean name="PropHolder" class="org.jboss.test.kernel.config.support.PropHolder">
+ <constructor>
+ <parameter>
+ <value-factory bean="ldap" method="getValue" parameter="foo.bar.key"/>
+ </parameter>
+ </constructor>
+ </bean>
+ </programlisting>
+
+ <para>You can also define a default value for the value-factory return value.
+ </para>
+
+ <programlisting>
+ <bean name="PropHolder" class="org.jboss.test.kernel.config.support.PropHolder">
+ <property name="list">
+ <list elementClass="java.lang.String">
+ <value-factory bean="ldap" method="getValue" default="QWERT">
+ <parameter>no.such.key</parameter>
+ </value-factory>
+ </list>
+ <property>
+ </bean>
+ </programlisting>
+
</section>
<section>
@@ -740,10 +799,41 @@
</bean>
</programlisting>
- <para>
- TODO - preinstantiated and actual collection instantiation configuration options.
+ <para>When using collections in your bean configuration, this is the order Microcontainer will use for new
+ instantiation or using already existing collection instance.
+ <itemizedlist mark="bullet">
+ <listitem>
+ <para>if collection's class attribute is defined, a new instance of that class will be instantiated</para>
+ </listitem>
+ <listitem>
+ <para>if already instantiated collection exists and is available via getter, this instance will be used -
+ unless you define preinstantiate attribute on the property to false
+ </para>
+ </listitem>
+ <listitem>
+ <para>if the collection references some non interface class, we'll try to instantiate a new instance of
+ that class
+ </para>
+ </listitem>
+ <listitem>
+ <para>default collection instance will be used - Collection and List will use ArrayList, Set uses
+ HashSet and Map will use HashMap
+ </para>
+ </listitem>
+ </itemizedlist>
</para>
+ <programlisting>
+ <bean name="SimpleBean" class="org.jboss.test.kernel.config.support.UnmodifiableGetterBean">
+ <property name="list" preinstantiate="false">
+ <list elementClass="java.lang.String">
+ <value>string1</value>
+ <value>string2</value>
+ </list>
+ </property>
+ </bean>
+ </programlisting>
+
</section>
<section>
@@ -1113,7 +1203,12 @@
</programlisting>
<para>
- TODO - alias as true dependency.
+ Newly added alias defined as a element on the deployment acts as a full dependency item. Meaning
+ it won't get registered (installed) until the original bean is installed. What this means that you can have
+ original beans defined in one deployment and aliases in another, and the order of deployment doesn't matter.
+ When the original bean is uninstalled, the alias gets unregistered (uninstalled) as well.
+ When the alias gets unregistered, all beans that depend on the alias get undeployed as well, regardless if
+ the original bean is still present.
</para>
</section>
@@ -1332,9 +1427,54 @@
<section>
<title>Injection from context</title>
- <para>TODO - injection from context.
+ <para>Even though Microcontainer is aimed at POJOs, it doesn't mean you are not able to easily get into
+ the underlying architecture of its state machine.
+ Each bean is represented in Microcontainer's state machine (Controller) as a ControllerContext.
+ ControllerContext holds various information in order to consistently move between lifecycle states,
+ resolve dependencies, apply instance aspects, annotations, metadata ...
</para>
+ <para>
+ With already known injection concept (<inject\>), now you can also inject some information from the context.
+ This is what you can currently get a hold on from the underlying context:
+ <itemizedlist>
+ <listitem>
+ <para>name - <inject fromContext="name"/></para>
+ </listitem>
+ <listitem>
+ <para>aliases - <inject fromContext="aliases"/></para>
+ </listitem>
+ <listitem>
+ <para>metadata - <inject fromContext="metadata"/></para>
+ </listitem>
+ <listitem>
+ <para>beaninfo - <inject fromContext="beaninfo"/></para>
+ </listitem>
+ <listitem>
+ <para>scope - <inject fromContext="scope"/></para>
+ </listitem>
+ <listitem>
+ <para>id - <inject fromContext="id"/></para>
+ </listitem>
+ <listitem>
+ <para>context itself - <inject fromContext="context"/></para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ <para>All this information is wrapped into unmodifiable objects, preventing user to add or set additional
+ information outside Microcontainer's Controller.
+ As we already know, <inject/> element can take bean attribute. In this case, if bean attribute is set,
+ we are not targeting bean's underlying context, but context that coresponds to set bean attribute.
+ </para>
+
+ <programlisting>
+ <bean name="sndBean" class="org.jboss.test.kernel.deployment.support.NameAwareBean">
+ <property name="beaninfo"><inject bean="otherBean" fromContext="beaninfo"/></property>
+ </bean>
+ </programlisting>
+
+ <para>In this example we inject otherBean's beaninfo information into sndBean bean.</para>
</section>
</section>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list