Class AbstractBeanTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.di.tags.AbstractBeanTag
-
- All Implemented Interfaces:
org.apache.commons.jelly.Tag
- Direct Known Subclasses:
BeanTag
,CollectionTag
,ContextBeanTag
,MapTag
public abstract class AbstractBeanTag extends org.apache.commons.jelly.TagSupport
An abstract base class for tag handler implementations that create bean providers.
This class provides some common functionality related to the creation and management of
objects. The features implemented here include the following:BeanProvider
- A
store
attribute is implemented for selecting the bean store, in which to store the provider created by this tag. Alternatively the tag can be nested inside a
.BeanStoreTag
- Functionality is provided for passing a bean provider to a bean store. Both standard and anonymous bean providers can be stored.
- A framework of methods is defined that are called during the execution of the tag. While most of these methods are fully functional, derived classes can override some for adding specific functionality.
- An abstract
createBeanProvider()
method is declared. Here concrete subclasses have to implement the creation of their bean provider.
- Version:
- $Id: AbstractBeanTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description AbstractBeanTag()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract BeanProvider
createBeanProvider()
Creates the bean provider defined by this tag.void
doTag(org.apache.commons.jelly.XMLOutput output)
The main method of this tag.BeanStoreTag
getBeanStoreTag()
Returns a reference to the enclosingBeanStoreTag
.String
getName()
Returns the name of the managed bean definition.String
getStore()
Returns the name of theBeanStore
, in which to place the managed bean definition.DependencyTag
getTargetDependency()
Returns the target dependency.boolean
isAnonymous()
Returns a flag whether this tag declares an anonymous bean.protected void
process()
Processes this tag after its body has been evaluated.protected void
processBeforeBody()
Performs pre-processing before the body of this tag is evaluated.protected void
setBeanStoreTag(BeanStoreTag beanStoreTag)
Sets the reference to the enclosingBeanStoreTag
.void
setStore(String store)
Set method of the store attribute.protected void
store(BeanProvider provider)
Stores the newly createdBeanProvider
in the correct bean store.-
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
-
getName
public String getName()
Returns the name of the managed bean definition. This name is used when theBeanProvider
created by this tag is stored in aBeanStore
. In this base implementation the name is only queried to distinguish whether this is a normal or an anonymous bean definition.getName()
always returns null here; if derived classes support setting a name, they must override this method.- Returns:
- the name of the bean definition
-
getStore
public String getStore()
Returns the name of theBeanStore
, in which to place the managed bean definition.- Returns:
- the name of the bean store
-
setStore
public void setStore(String store)
Set method of the store attribute.- Parameters:
store
- the attribute's value
-
getBeanStoreTag
public BeanStoreTag getBeanStoreTag()
Returns a reference to the enclosingBeanStoreTag
. This can be null if there is no such tag.- Returns:
- a reference to the enclosing bean store tag
-
getTargetDependency
public DependencyTag getTargetDependency()
Returns the target dependency. If this is a valid anonymous bean declaration, there is a target dependency tag, on which to set the reference to the declared bean.- Returns:
- the target dependency tag
-
isAnonymous
public boolean isAnonymous()
Returns a flag whether this tag declares an anonymous bean. This is a bean without a name that is only visible in the context it is declared.- Returns:
- a flag if this is an anonymous bean
-
doTag
public void doTag(org.apache.commons.jelly.XMLOutput output) throws org.apache.commons.jelly.JellyTagException
The main method of this tag. Delegates to the specific processing methods.- Parameters:
output
- the output object- Throws:
org.apache.commons.jelly.JellyTagException
- if an error occurs or the tag is incorrectly used
-
setBeanStoreTag
protected void setBeanStoreTag(BeanStoreTag beanStoreTag)
Sets the reference to the enclosingBeanStoreTag
. This can be null if this tag is not placed in the body of a bean store tag.- Parameters:
beanStoreTag
- the enclosingBeanStoreTag
-
processBeforeBody
protected void processBeforeBody() throws org.apache.commons.jelly.JellyTagException
Performs pre-processing before the body of this tag is evaluated. This method is called by thedoTag()
method. It checks whether this tag is nested inside a
, which will become the target dependency, i.e. if this is an anonymous bean declaration, the target dependency will be initialized to point to this bean.DependencyTag
- Throws:
org.apache.commons.jelly.JellyTagException
- if no name is defined for this tag, but no target dependency can be obtained or the target dependency is already initialized
-
process
protected void process() throws org.apache.commons.jelly.JellyTagException
Processes this tag after its body has been evaluated. Creates the bean provider and adds it to the correct bean store.- Throws:
org.apache.commons.jelly.JellyTagException
- if the tag is incorrectly used
-
store
protected void store(BeanProvider provider) throws org.apache.commons.jelly.JellyTagException
Stores the newly createdBeanProvider
in the correct bean store. This method is called byprocess()
when a provider could be successfully created.- Parameters:
provider
- the newly created bean provider- Throws:
org.apache.commons.jelly.JellyTagException
- if an error occurs
-
createBeanProvider
protected abstract BeanProvider createBeanProvider() throws org.apache.commons.jelly.JellyTagException
Creates the bean provider defined by this tag. This method is invoked byprocess()
. A concrete subclass has to implement it and return aBeanProvider
, which will be stored in the selected bean store.- Returns:
- the bean provider defined by this tag
- Throws:
org.apache.commons.jelly.JellyTagException
- in case of an error
-
-