FileDocCategorySizeDatePackage
LifecycleListenerRule.javaAPI DocApache Tomcat 6.0.143274Fri Jul 20 04:20:34 BST 2007org.apache.catalina.startup

LifecycleListenerRule

public class LifecycleListenerRule extends org.apache.tomcat.util.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(String listenerClass, String attributeName)
Construct a new instance of this Rule.

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


        this.listenerClass = listenerClass;
        this.attributeName = attributeName;

    
Methods Summary
public voidbegin(java.lang.String namespace, java.lang.String name, 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);