Javadoc TagsEntry TagThe entry tag declares a context entry required by a component. The component is supplied the context entry via a context argument as part of the contextualization lifecycle stage. Context entries my declare a object type or array of object types. If the type is not declared java.lang.String is assumed. Context entries may also be declared as optional and/or volatile. The default behaviour is to assume that a context entry is required (not optional) is is non-volatile. Attributes
Examplepackage org.apache.avalon.playground; /** * Example of a component declaring a context entry dependencies. * * @avalon.component version="1.0" name="demo" */ public class Primary implements Contextualizable { /** * @avalon.entry key="home" type="java.io.File" optional="true" * @avalon.entry key="time" type="java.util.Date" volatile="true" * @avalon.entry key="table" type="java.lang.Object[]" * @avalon.entry key="urn:avalon:name" alias="block.name" */ public void contextualize( Context context ) throws ContextException { String name = (String) context.get( "name" ); Object[] array = (Object[]) context.get( "table" ); try { File home = (File) context.get( "home" ); ... } catch( ContextException ce ) { // it's optional } } } Generated meta-info type descriptor: <type> <info> <version>1.3.0</version> <name>primary-component</name> </info> <context> <entry key="home" type="java.io.File" optional="true"/> <entry key="time" type="java.util.Date" volatile="true"/> <entry key="table" type="java.lang.Object[]"/> <entry key="urn:avalon:name" alias="block.name"> </context> </type> |