billbarker 2004/08/03 23:48:07 Modified: catalina/src/share/org/apache/catalina/startup HostConfig.java mbeans-descriptors.xml Log: Adding methods for JMX managed Contexts. -- Adding method to get the configBase via JMX -- Adding methods to add and remove apps with minimal dependancy checks. This is for use with JMX apps (like the admin) that control the Context themselves. Revision Changes Path 1.43 +74 -3 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java Index: HostConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- HostConfig.java 28 Jul 2004 10:30:10 -0000 1.42 +++ HostConfig.java 4 Aug 2004 06:48:07 -0000 1.43 @@ -422,6 +422,13 @@ } + /** + * Get the name of the configBase. + * For use with JMX management. + */ + public String getConfigBaseName() { + return configBase().getAbsolutePath(); + } /** * Given a context path, get the config file name. @@ -1133,8 +1140,72 @@ deployApps(name); } } - - + + /** + * Add a new Context to be managed by us. + * Entry point for the admin webapp, and other JMX Context controlers. + */ + public void manageApp(Context context) { + + String contextPath = context.getPath(); + + if (deployed.containsKey(contextPath)) + return; + + DeployedApplication deployedApp = new DeployedApplication(contextPath); + + // Add the associated docBase to the redeployed list if it's a WAR + boolean isWar = false; + if (context.getDocBase() != null) { + File docBase = new File(context.getDocBase()); + if (!docBase.isAbsolute()) { + docBase = new File(appBase(), context.getDocBase()); + } + deployedApp.redeployResources.put(docBase.getAbsolutePath(), + new Long(docBase.lastModified())); + if (docBase.getAbsolutePath().toLowerCase().endsWith(".war")) { + isWar = true; + } + } + host.addChild(context); + // Add the eventual unpacked WAR and all the resources which will be + // watched inside it + if (isWar && unpackWARs) { + String name = null; + String path = context.getPath(); + if (path.equals("")) { + name = "ROOT"; + } else { + if (path.startsWith("/")) { + name = path.substring(1); + } else { + name = path; + } + } + File docBase = new File(name); + if (!docBase.isAbsolute()) { + docBase = new File(appBase(), name); + } + deployedApp.redeployResources.put(docBase.getAbsolutePath(), + new Long(docBase.lastModified())); + addWatchedResources(deployedApp, docBase.getAbsolutePath(), context); + } else { + addWatchedResources(deployedApp, null, context); + } + deployed.put(contextPath, deployedApp); + } + + /** + * Remove a webapp from our control. + * Entry point for the admin webapp, and other JMX Context controlers. + */ + public void unmanageApp(String contextPath) { + if(isServiced(contextPath)) { + deployed.remove(contextPath); + host.removeChild(host.findChild(contextPath)); + } + } + // ----------------------------------------------------- Instance Variables 1.4 +23 -0 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml Index: mbeans-descriptors.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- mbeans-descriptors.xml 27 Jul 2004 07:17:21 -0000 1.3 +++ mbeans-descriptors.xml 4 Aug 2004 06:48:07 -0000 1.4 @@ -39,6 +39,11 @@ type="java.lang.String" writeable="false"/> + <attribute name="configBaseName" + description="The base directory for Context configuration files" + type="java.lang.String" + writeable="false" /> + <attribute name="configClass" description="The Java class name of the Context configuration class we should use" type="java.lang.String"/> @@ -74,6 +79,15 @@ type="java.lang.String"/> </operation> + <operation name="manageApp" + description="Add a web application managed externally" + impact="ACTION" + returnType="void"> + <parameter name="context" + description="Context to add" + type="org.apache.catalina.Context" /> + </operation> + <operation name="removeServiced" description="Add a web application name to the serviced list" impact="ACTION" @@ -81,6 +95,15 @@ <parameter name="name" description="Application name" type="java.lang.String"/> + </operation> + + <operation name="unmanageApp" + description="Remove a web application from checks" + impact="ACTION" + returnType="void"> + <parameter name="contextPath" + description="The application path" + type="java.lang.String" /> </operation> </mbean>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]