Class 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 BeanProvider for a BeanTag.

    This tag handler class creates a MethodInvocationBeanProvider and passes it to its enclosing BeanTag. 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 required MethodInvocation defining the method to be invoked on the factory; if no dependency is specified, the MethodInvocation must refer to a static method. The method to be invoked must be defined by a MethodInvocationTag in 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 refClassName attribute 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 Detail

      • FactoryTag

        public FactoryTag()
    • Method Detail

      • getBeanTag

        public BeanTag getBeanTag()
        Returns a reference to the enclosing BeanTag.
        Returns:
        the enclosing bean tag
      • 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 processing methods.
        Specified by:
        doTag in interface org.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 an Invokable to this object. This implementation expects that a single MethodInvocation object is passed, which will be used for creating a MethodInvocationBeanProvider.
        Parameters:
        inv - the Invokable to 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 enclosing BeanTag. This method is called by the tag's main method if a BeanTag can be found.
        Parameters:
        beanTag - the enclosing BeanTag
      • processBeforeBody

        protected void processBeforeBody()
                                  throws org.apache.commons.jelly.JellyTagException
        Performs some pre-processing before the tag's body is evaluated. Registers the tag as an InvokableSupport object.
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is incorrectly used
      • process

        protected void process()
                        throws org.apache.commons.jelly.JellyTagException
        The 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