1 17 18 19 package org.apache.catalina.startup; 20 21 22 import org.apache.catalina.Lifecycle; 23 import org.apache.catalina.LifecycleListener; 24 import org.apache.tomcat.util.digester.Rule; 25 import org.xml.sax.Attributes ; 26 27 28 33 34 public class LifecycleListenerRule extends Rule { 35 36 37 39 40 48 public LifecycleListenerRule(String listenerClass, String attributeName) { 49 50 this.listenerClass = listenerClass; 51 this.attributeName = attributeName; 52 53 } 54 55 56 58 59 63 private String attributeName; 64 65 66 69 private String listenerClass; 70 71 72 74 75 82 public void begin(String namespace, String name, Attributes attributes) 83 throws Exception { 84 85 String className = listenerClass; 87 if (attributeName != null) { 88 String value = attributes.getValue(attributeName); 89 if (value != null) 90 className = value; 91 } 92 Class clazz = Class.forName(className); 93 LifecycleListener listener = 94 (LifecycleListener) clazz.newInstance(); 95 96 Lifecycle lifecycle = (Lifecycle) digester.peek(); 98 lifecycle.addLifecycleListener(listener); 99 100 } 101 102 103 } 104 | Popular Tags |