Class FactoryTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.di.tags.DependencyTag
-
- net.sf.jguiraffe.gui.builder.di.tags.FactoryTag
-
- All Implemented Interfaces:
ValueSupport,org.apache.commons.jelly.Tag
public class FactoryTag extends DependencyTag
A tag for defining a bean factory that is used as creation
BeanProviderfor aBeanTag.This tag handler class creates a
MethodInvocationBeanProviderand passes it to its enclosingBeanTag. This way it is possible to use a kind of factory for creating beans. The factory is defined by an optional dependency to another bean and a requiredMethodInvocationdefining the method to be invoked on the factory; if no dependency is specified, theMethodInvocationmust refer to a static method. The method to be invoked must be defined by aMethodInvocationTagin the body of this tag. The optional dependency is specified through the attributes of this tag:Attribute Description Optional refName Specifies a dependency to another bean. On this bean the factory method will be invoked. yes refClass Specifies a dependency to another bean by its class. On this bean the factory method will be invoked. yes refClassName Specifies a dependency to another bean by its class name. On this bean the factory method will be invoked. yes refClassLoader With this attribute a symbolic name for the class loader to be used can be specified. It is evaluated only if the refClassNameattribute was set. In this case the class loader specified here will be used for resolving the class name.yes value If the factory object is a constant object, this attribute can be used. It allows to directly specify the value. yes valueClass If a constant value is to be used for the factory object, it may be necessary to perform some type conversion. With this attribute the type of the factory can be specified. The value will then be converted to this type. yes valueClassName Like valueClass, but the name of the property's data type class is specified.yes valueClassLoader If the data type class of the value is specified by its name only, with this attribute the class loader can be determined for resolving the class. yes - Version:
- $Id: FactoryTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description FactoryTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInvokable(Invokable inv)Adds anInvokableto this object.voiddoTag(org.apache.commons.jelly.XMLOutput output)The main method of this tag.BeanTaggetBeanTag()Returns a reference to the enclosingBeanTag.protected voidprocess()The main processing method.protected voidprocessBeforeBody()Performs some pre-processing before the tag's body is evaluated.protected voidsetBeanTag(BeanTag beanTag)Initializes the reference to the enclosingBeanTag.-
Methods inherited from class net.sf.jguiraffe.gui.builder.di.tags.DependencyTag
createDependency, createValueDependency, getDependency, getRefClassData, getRefName, getValueData, getVar, hasDependency, processDependencyDefinitions, setDependency, setRefClass, setRefClassLoader, setRefClassName, setRefName, setValue, setValueClass, setValueClassLoader, setValueClassName, setVar
-
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
-
-
-
-
Method Detail
-
getBeanTag
public BeanTag getBeanTag()
Returns a reference to the enclosingBeanTag.- Returns:
- the enclosing bean tag
-
doTag
public void doTag(org.apache.commons.jelly.XMLOutput output) throws org.apache.commons.jelly.JellyTagExceptionThe main method of this tag. Delegates to the processing methods.- Specified by:
doTagin interfaceorg.apache.commons.jelly.Tag- Parameters:
output- the output object- Throws:
org.apache.commons.jelly.JellyTagException- if an error occurs
-
addInvokable
public void addInvokable(Invokable inv) throws org.apache.commons.jelly.JellyTagException
Adds anInvokableto this object. This implementation expects that a singleMethodInvocationobject is passed, which will be used for creating aMethodInvocationBeanProvider.- Parameters:
inv- theInvokableto be added- Throws:
org.apache.commons.jelly.JellyTagException- if the passed in object is not accepted
-
setBeanTag
protected void setBeanTag(BeanTag beanTag)
Initializes the reference to the enclosingBeanTag. This method is called by the tag's main method if aBeanTagcan be found.- Parameters:
beanTag- the enclosingBeanTag
-
processBeforeBody
protected void processBeforeBody() throws org.apache.commons.jelly.JellyTagExceptionPerforms some pre-processing before the tag's body is evaluated. Registers the tag as anInvokableSupportobject.- Throws:
org.apache.commons.jelly.JellyTagException- if the tag is incorrectly used
-
process
protected void process() throws org.apache.commons.jelly.JellyTagExceptionThe main processing method. This method is invoked after the tag's body has been processed. It performs some validity checks.- Throws:
org.apache.commons.jelly.JellyTagException- if the tag is incorrectly used
-
-