From: <jbo...@li...> - 2006-01-10 15:54:37
|
Author: rem...@jb... Date: 2006-01-10 10:54:34 -0500 (Tue, 10 Jan 2006) New Revision: 2050 Modified: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/core/StandardContext.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/core/mbeans-descriptors.xml Log: - Port new JMX ContextConfig tweaks. Modified: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/core/StandardContext.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/core/StandardContext.java 2006-01-10 14:20:02 UTC (rev 2049) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/core/StandardContext.java 2006-01-10 15:54:34 UTC (rev 2050) @@ -33,6 +33,7 @@ import java.util.Stack; import java.util.TreeMap; +import javax.management.AttributeNotFoundException; import javax.management.ListenerNotFoundException; import javax.management.MBeanNotificationInfo; import javax.management.MBeanRegistrationException; @@ -44,7 +45,6 @@ import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; -import javax.naming.NamingException; import javax.naming.directory.DirContext; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; @@ -89,7 +89,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.modeler.Registry; -import org.apache.naming.ContextBindings; import org.apache.naming.resources.BaseDirContext; import org.apache.naming.resources.DirContextURLStreamHandler; import org.apache.naming.resources.FileDirContext; @@ -4999,7 +4998,26 @@ .registerComponent(host, parentName, null); mserver.invoke(parentName, "init", new Object[] {}, new String[] {} ); } - ContextConfig config = new ContextConfig(); + + // Add the main configuration listener + LifecycleListener config = null; + try { + Object configClassname = null; + try { + configClassname = mserver.getAttribute(parentName, "configClass"); + } catch (AttributeNotFoundException e) { + // Ignore, it's normal a host may not have this optional attribute + } + if (configClassname != null) { + Class clazz = Class.forName(String.valueOf(configClassname)); + config = (LifecycleListener) clazz.newInstance(); + } else { + config = new ContextConfig(); + } + } catch (Exception e) { + log.warn("Error creating ContextConfig for " + parentName, e); + throw e; + } this.addLifecycleListener(config); if(log.isDebugEnabled()) Modified: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/core/mbeans-descriptors.xml =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/core/mbeans-descriptors.xml 2006-01-10 14:20:02 UTC (rev 2049) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/core/mbeans-descriptors.xml 2006-01-10 15:54:34 UTC (rev 2050) @@ -248,6 +248,24 @@ type="org.apache.catalina.Valve"/> </operation> + <operation name="addLifecycleListener" + description="Add a lifecycle listener to this Context" + impact="ACTION" + returnType="void"> + <parameter name="listener" + description="New lifecycle listener to be added" + type="org.apache.catalina.LifecycleListener"/> + </operation> + + <operation name="removeLifecycleListener" + description="Remove a lifecycle listener from this Context" + impact="ACTION" + returnType="void"> + <parameter name="listener" + description="New lifecycle listener to be removed" + type="org.apache.catalina.LifecycleListener"/> + </operation> + <operation name="reload" description="Reload the webapplication" impact="ACTION" @@ -384,6 +402,10 @@ description="The auto deploy flag for this Host" type="boolean"/> + <attribute name="configClass" + description="The configuration class for contexts" + type="java.lang.String"/> + <attribute name="deployOnStartup" description="The deploy on startup flag for this Host" type="boolean"/> |