FileDocCategorySizeDatePackage
LifecycleListenerRule.javaAPI DocGlassfish v2 API4513Fri May 04 22:32:30 BST 2007org.apache.catalina.startup

LifecycleListenerRule

public class LifecycleListenerRule extends com.sun.org.apache.commons.digester.Rule

Rule that creates a new LifecycleListener instance, and associates it with the top object on the stack (which must implement LifecycleListener).

Fields Summary
private String
attributeName
The attribute name of an attribute that can override the implementation class name.
private String
listenerClass
The name of the LifecycleListener implementation class.
Constructors Summary
public LifecycleListenerRule(com.sun.org.apache.commons.digester.Digester digester, String listenerClass, String attributeName)
Construct a new instance of this Rule.

param
digester Digester we are associated with
param
listenerClass Default name of the LifecycleListener implementation class to be created
param
attributeName Name of the attribute that optionally includes an override name of the LifecycleListener class


        super(digester);
        this.listenerClass = listenerClass;
        this.attributeName = attributeName;

    
Methods Summary
public voidbegin(org.xml.sax.Attributes attributes)
Handle the beginning of an XML element.

param
attributes The attributes of this element
exception
Exception if a processing error occurs


        // Instantiate a new LifecyleListener implementation object
        String className = listenerClass;
        if (attributeName != null) {
            String value = attributes.getValue(attributeName);
            if (value != null)
                className = value;
        }
        Class clazz = Class.forName(className);
        LifecycleListener listener =
            (LifecycleListener) clazz.newInstance();

        // Add this LifecycleListener to our associated component
        Lifecycle lifecycle = (Lifecycle) digester.peek();
        lifecycle.addLifecycleListener(listener);