You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/04/02 04:35:13 UTC
cvs commit: avalon/merlin/platform/xdocs/reference/component/artifacts context.xml
mcconnell 2004/04/01 18:35:13
Modified: merlin/platform/xdocs/reference/component/artifacts
context.xml
Log:
Add custom context via injection.
Revision Changes Path
1.2 +41 -5 avalon/merlin/platform/xdocs/reference/component/artifacts/context.xml
Index: context.xml
===================================================================
RCS file: /home/cvs/avalon/merlin/platform/xdocs/reference/component/artifacts/context.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- context.xml 31 Mar 2004 12:57:23 -0000 1.1
+++ context.xml 2 Apr 2004 02:35:13 -0000 1.2
@@ -108,11 +108,47 @@
</subsection>
<subsection name="Context Casting">
- <p>IN PREP</p>
- </subsection>
-
- <subsection name="Custom Delivery Strategies">
- <p>IN PREP</p>
+ <p>
+ While the context interface provides the mechanisms to
+ access any object type via key, it is sometimes convenient to
+ declare a domain specific interface and custom context
+ implementation. This enables client code to take advantage
+ of convenience accessors, resulting in code that is not
+ cluttered with casting and context entry key references.
+ </p>
+ <p>
+ The dependency of a component on a custom context type is
+ declared using the
+ <a href="http://avalon.apache.org/meta/tools/tags/context.html">
+ @avalon.context</a> tag type attribute.
+ </p>
+<source>
+ /**
+ * Creation of a new DefaultWidget instance using a
+ * custom object that is castable to a domain specific
+ * interface.
+ *
+ * @avalon.context type="net.dpml.WidgetContext"
+ * @avalon.entry key="urn:avalon:home" type="java.io.File"
+ */
+ public DefaultWidget( WidgetContext context )
+ throws ContextException
+ {
+ File common = context.getCommonDirectory();
+ m_common = common;
+ }
+</source>
+ <p>
+ In the above example the WidgetContext interfact is unknown
+ to the container - as such an explicit deployment directives is
+ required to declare a the context implementation class to be used
+ by the container during context argument establishment.
+ </p>
+<source><![CDATA[
+ <component name="widget" class="net.dpml.DefaultWidget">
+ <context class="net.dpml.DefaultWidgetContext"/>
+ </component>
+]]></source>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org