0001: /*
0002: * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v 1.30 2002/06/19 21:17:19 amyroh Exp $
0003: * $Revision: 1.30 $
0004: * $Date: 2002/06/19 21:17:19 $
0005: *
0006: * ====================================================================
0007: *
0008: * The Apache Software License, Version 1.1
0009: *
0010: * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
0011: * reserved.
0012: *
0013: * Redistribution and use in source and binary forms, with or without
0014: * modification, are permitted provided that the following conditions
0015: * are met:
0016: *
0017: * 1. Redistributions of source code must retain the above copyright
0018: * notice, this list of conditions and the following disclaimer.
0019: *
0020: * 2. Redistributions in binary form must reproduce the above copyright
0021: * notice, this list of conditions and the following disclaimer in
0022: * the documentation and/or other materials provided with the
0023: * distribution.
0024: *
0025: * 3. The end-user documentation included with the redistribution, if
0026: * any, must include the following acknowlegement:
0027: * "This product includes software developed by the
0028: * Apache Software Foundation (http://www.apache.org/)."
0029: * Alternately, this acknowlegement may appear in the software itself,
0030: * if and wherever such third-party acknowlegements normally appear.
0031: *
0032: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
0033: * Foundation" must not be used to endorse or promote products derived
0034: * from this software without prior written permission. For written
0035: * permission, please contact apache@apache.org.
0036: *
0037: * 5. Products derived from this software may not be called "Apache"
0038: * nor may "Apache" appear in their names without prior written
0039: * permission of the Apache Group.
0040: *
0041: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0042: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0043: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0044: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
0045: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0046: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0047: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
0048: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0049: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
0050: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
0051: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0052: * SUCH DAMAGE.
0053: * ====================================================================
0054: *
0055: * This software consists of voluntary contributions made by many
0056: * individuals on behalf of the Apache Software Foundation. For more
0057: * information on the Apache Software Foundation, please see
0058: * <http://www.apache.org/>.
0059: *
0060: * [Additional notices, if required by prior licensing conditions]
0061: *
0062: */
0063:
0064: package org.apache.catalina.mbeans;
0065:
0066: import java.beans.PropertyChangeEvent;
0067: import java.beans.PropertyChangeListener;
0068: import java.io.File;
0069: import java.io.InputStream;
0070: import java.net.URL;
0071: import java.util.Collection;
0072: import java.util.Iterator;
0073: import java.util.StringTokenizer;
0074: import javax.management.MBeanException;
0075: import javax.management.MBeanServer;
0076: import javax.management.ObjectName;
0077: import org.apache.catalina.Connector;
0078: import org.apache.catalina.Container;
0079: import org.apache.catalina.ContainerEvent;
0080: import org.apache.catalina.ContainerListener;
0081: import org.apache.catalina.Context;
0082: import org.apache.catalina.DefaultContext;
0083: import org.apache.catalina.Engine;
0084: import org.apache.catalina.Globals;
0085: import org.apache.catalina.Host;
0086: import org.apache.catalina.Loader;
0087: import org.apache.catalina.Logger;
0088: import org.apache.catalina.Manager;
0089: import org.apache.catalina.Lifecycle;
0090: import org.apache.catalina.LifecycleEvent;
0091: import org.apache.catalina.LifecycleListener;
0092: import org.apache.catalina.Realm;
0093: import org.apache.catalina.Server;
0094: import org.apache.catalina.ServerFactory;
0095: import org.apache.catalina.Service;
0096: import org.apache.catalina.Valve;
0097: import org.apache.catalina.core.StandardContext;
0098: import org.apache.catalina.core.StandardEngine;
0099: import org.apache.catalina.core.StandardHost;
0100: import org.apache.catalina.core.StandardServer;
0101: import org.apache.catalina.core.StandardService;
0102: import org.apache.catalina.deploy.ContextEnvironment;
0103: import org.apache.catalina.deploy.ContextResource;
0104: import org.apache.catalina.deploy.ContextResourceLink;
0105: import org.apache.catalina.deploy.NamingResources;
0106: import org.apache.catalina.deploy.ResourceParams;
0107:
0108: /**
0109: * Implementation of <code>LifecycleListener</code> that
0110: * instantiates the set of MBeans associated with the components of a
0111: * running instance of Catalina.
0112: *
0113: * @author Craig R. McClanahan
0114: * @author Amy Roh
0115: * @version $Revision: 1.30 $ $Date: 2002/06/19 21:17:19 $
0116: */
0117:
0118: public class ServerLifecycleListener implements ContainerListener,
0119: LifecycleListener, PropertyChangeListener {
0120:
0121: // ------------------------------------------------------------- Properties
0122:
0123: /**
0124: * The debugging detail level for this component.
0125: */
0126: protected int debug = 0;
0127:
0128: public int getDebug() {
0129: return (this .debug);
0130: }
0131:
0132: public void setDebug(int debug) {
0133: this .debug = debug;
0134: }
0135:
0136: /**
0137: * Semicolon separated list of paths containing MBean desciptor resources.
0138: */
0139: protected String descriptors = null;
0140:
0141: public String getDescriptors() {
0142: return (this .descriptors);
0143: }
0144:
0145: public void setDescriptors(String descriptors) {
0146: this .descriptors = descriptors;
0147: }
0148:
0149: // ---------------------------------------------- ContainerListener Methods
0150:
0151: /**
0152: * Handle a <code>ContainerEvent</code> from one of the Containers we are
0153: * interested in.
0154: *
0155: * @param event The event that has occurred
0156: */
0157: public void containerEvent(ContainerEvent event) {
0158:
0159: try {
0160: String type = event.getType();
0161: if (Container.ADD_CHILD_EVENT.equals(type)) {
0162: processContainerAddChild(event.getContainer(),
0163: (Container) event.getData());
0164: } else if (Container.ADD_VALVE_EVENT.equals(type)) {
0165: processContainerAddValve(event.getContainer(),
0166: (Valve) event.getData());
0167: } else if (Container.REMOVE_CHILD_EVENT.equals(type)) {
0168: processContainerRemoveChild(event.getContainer(),
0169: (Container) event.getData());
0170: } else if (Container.REMOVE_VALVE_EVENT.equals(type)) {
0171: processContainerRemoveValve(event.getContainer(),
0172: (Valve) event.getData());
0173: }
0174: } catch (Exception e) {
0175: log("Exception processing event " + event, e);
0176: }
0177:
0178: }
0179:
0180: // ---------------------------------------------- LifecycleListener Methods
0181:
0182: /**
0183: * Primary entry point for startup and shutdown events.
0184: *
0185: * @param event The event that has occurred
0186: */
0187: public void lifecycleEvent(LifecycleEvent event) {
0188:
0189: Lifecycle lifecycle = event.getLifecycle();
0190: if (Lifecycle.START_EVENT.equals(event.getType())) {
0191:
0192: if (lifecycle instanceof Server) {
0193:
0194: // Loading additional MBean descriptors
0195: loadMBeanDescriptors();
0196:
0197: createMBeans();
0198:
0199: }
0200:
0201: /*
0202: // Ignore events from StandardContext objects to avoid
0203: // reregistering the context
0204: if (lifecycle instanceof StandardContext)
0205: return;
0206: createMBeans();
0207: */
0208:
0209: } else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
0210:
0211: if (lifecycle instanceof Server) {
0212: destroyMBeans();
0213: }
0214:
0215: } else if (Context.RELOAD_EVENT.equals(event.getType())) {
0216:
0217: // Give context a new handle to the MBean server if the
0218: // context has been reloaded since reloading causes the
0219: // context to lose its previous handle to the server
0220: if (lifecycle instanceof StandardContext) {
0221: // If the context is privileged, give a reference to it
0222: // in a servlet context attribute
0223: StandardContext context = (StandardContext) lifecycle;
0224: if (context.getPrivileged()) {
0225: context.getServletContext().setAttribute(
0226: Globals.MBEAN_REGISTRY_ATTR,
0227: MBeanUtils.createRegistry());
0228: context.getServletContext().setAttribute(
0229: Globals.MBEAN_SERVER_ATTR,
0230: MBeanUtils.createServer());
0231: }
0232: }
0233:
0234: }
0235:
0236: }
0237:
0238: // ----------------------------------------- PropertyChangeListener Methods
0239:
0240: /**
0241: * Handle a <code>PropertyChangeEvent</code> from one of the Containers
0242: * we are interested in.
0243: *
0244: * @param event The event that has occurred
0245: */
0246: public void propertyChange(PropertyChangeEvent event) {
0247:
0248: if (event.getSource() instanceof Container) {
0249: try {
0250: processContainerPropertyChange((Container) event
0251: .getSource(), event.getPropertyName(), event
0252: .getOldValue(), event.getNewValue());
0253: } catch (Exception e) {
0254: log("Exception handling Container property change", e);
0255: }
0256: } else if (event.getSource() instanceof NamingResources) {
0257: try {
0258: processNamingResourcesPropertyChange(
0259: (NamingResources) event.getSource(), event
0260: .getPropertyName(),
0261: event.getOldValue(), event.getNewValue());
0262: } catch (Exception e) {
0263: log(
0264: "Exception handling NamingResources property change",
0265: e);
0266: }
0267: } else if (event.getSource() instanceof Server) {
0268: try {
0269: processServerPropertyChange((Server) event.getSource(),
0270: event.getPropertyName(), event.getOldValue(),
0271: event.getNewValue());
0272: } catch (Exception e) {
0273: log("Exception handing Server property change", e);
0274: }
0275: } else if (event.getSource() instanceof Service) {
0276: try {
0277: processServicePropertyChange((Service) event
0278: .getSource(), event.getPropertyName(), event
0279: .getOldValue(), event.getNewValue());
0280: } catch (Exception e) {
0281: log("Exception handing Service property change", e);
0282: }
0283: }
0284:
0285: }
0286:
0287: // ------------------------------------------------------ Protected Methods
0288:
0289: /**
0290: * Load additional MBean descriptor resources.
0291: */
0292: protected void loadMBeanDescriptors() {
0293:
0294: if (descriptors != null) {
0295: StringTokenizer tokenizer = new StringTokenizer(
0296: descriptors, ";");
0297: while (tokenizer.hasMoreTokens()) {
0298: String resource = tokenizer.nextToken();
0299: MBeanUtils.loadMBeanDescriptors(resource);
0300: }
0301: }
0302:
0303: }
0304:
0305: /**
0306: * Create the MBeans that correspond to every existing node of our tree.
0307: */
0308: protected void createMBeans() {
0309:
0310: try {
0311:
0312: MBeanFactory factory = new MBeanFactory();
0313: createMBeans(factory);
0314: createMBeans(ServerFactory.getServer());
0315:
0316: } catch (MBeanException t) {
0317:
0318: Exception e = t.getTargetException();
0319: if (e == null)
0320: e = t;
0321: log("createMBeans: MBeanException", e);
0322:
0323: } catch (Throwable t) {
0324:
0325: log("createMBeans: Throwable", t);
0326:
0327: }
0328:
0329: }
0330:
0331: /**
0332: * Create the MBeans for the specified Connector and its nested components.
0333: *
0334: * @param connector Connector for which to create MBeans
0335: *
0336: * @exception Exception if an exception is thrown during MBean creation
0337: */
0338: protected void createMBeans(Connector connector) throws Exception {
0339:
0340: // Create the MBean for the Connnector itself
0341: if (debug >= 5)
0342: log("Creating MBean for Connector " + connector);
0343: MBeanUtils.createMBean(connector);
0344:
0345: }
0346:
0347: /**
0348: * Create the MBeans for the specified Context and its nested components.
0349: *
0350: * @param context Context for which to create MBeans
0351: *
0352: * @exception Exception if an exception is thrown during MBean creation
0353: */
0354: protected void createMBeans(Context context) throws Exception {
0355:
0356: // Create the MBean for the Context itself
0357: if (debug >= 4)
0358: log("Creating MBean for Context " + context);
0359: MBeanUtils.createMBean(context);
0360: context.addContainerListener(this );
0361: if (context instanceof StandardContext) {
0362: ((StandardContext) context).addPropertyChangeListener(this );
0363: ((StandardContext) context).addLifecycleListener(this );
0364: }
0365:
0366: // If the context is privileged, give a reference to it
0367: // in a servlet context attribute
0368: if (context.getPrivileged()) {
0369: context.getServletContext().setAttribute(
0370: Globals.MBEAN_REGISTRY_ATTR,
0371: MBeanUtils.createRegistry());
0372: context.getServletContext().setAttribute(
0373: Globals.MBEAN_SERVER_ATTR,
0374: MBeanUtils.createServer());
0375: }
0376:
0377: // Create the MBeans for the associated nested components
0378: Loader cLoader = context.getLoader();
0379: if (cLoader != null) {
0380: if (debug >= 4)
0381: log("Creating MBean for Loader " + cLoader);
0382: MBeanUtils.createMBean(cLoader);
0383: }
0384: Logger hLogger = context.getParent().getLogger();
0385: Logger cLogger = context.getLogger();
0386: if ((cLogger != null) && (cLogger != hLogger)) {
0387: if (debug >= 4)
0388: log("Creating MBean for Logger " + cLogger);
0389: MBeanUtils.createMBean(cLogger);
0390: }
0391: Manager cManager = context.getManager();
0392: if (cManager != null) {
0393: if (debug >= 4)
0394: log("Creating MBean for Manager " + cManager);
0395: MBeanUtils.createMBean(cManager);
0396: }
0397: Realm hRealm = context.getParent().getRealm();
0398: Realm cRealm = context.getRealm();
0399: if ((cRealm != null) && (cRealm != hRealm)) {
0400: if (debug >= 4)
0401: log("Creating MBean for Realm " + cRealm);
0402: MBeanUtils.createMBean(cRealm);
0403: }
0404:
0405: // Create the MBeans for the associated Valves
0406: if (context instanceof StandardContext) {
0407: Valve cValves[] = ((StandardContext) context).getValves();
0408: for (int l = 0; l < cValves.length; l++) {
0409: if (debug >= 4)
0410: log("Creating MBean for Valve " + cValves[l]);
0411: MBeanUtils.createMBean(cValves[l]);
0412: }
0413:
0414: }
0415:
0416: // Create the MBeans for the NamingResources (if any)
0417: NamingResources resources = context.getNamingResources();
0418: createMBeans(resources);
0419:
0420: }
0421:
0422: /**
0423: * Create the MBeans for the specified ContextEnvironment entry.
0424: *
0425: * @param environment ContextEnvironment for which to create MBeans
0426: *
0427: * @exception Exception if an exception is thrown during MBean creation
0428: */
0429: protected void createMBeans(ContextEnvironment environment)
0430: throws Exception {
0431:
0432: // Create the MBean for the ContextEnvironment itself
0433: if (debug >= 3) {
0434: log("Creating MBean for ContextEnvironment " + environment);
0435: }
0436: MBeanUtils.createMBean(environment);
0437:
0438: }
0439:
0440: /**
0441: * Create the MBeans for the specified ContextResource entry.
0442: *
0443: * @param resource ContextResource for which to create MBeans
0444: *
0445: * @exception Exception if an exception is thrown during MBean creation
0446: */
0447: protected void createMBeans(ContextResource resource)
0448: throws Exception {
0449:
0450: // Create the MBean for the ContextResource itself
0451: if (debug >= 3) {
0452: log("Creating MBean for ContextResource " + resource);
0453: }
0454: MBeanUtils.createMBean(resource);
0455:
0456: }
0457:
0458: /**
0459: * Create the MBeans for the specified ContextResourceLink entry.
0460: *
0461: * @param resourceLink ContextResourceLink for which to create MBeans
0462: *
0463: * @exception Exception if an exception is thrown during MBean creation
0464: */
0465: protected void createMBeans(ContextResourceLink resourceLink)
0466: throws Exception {
0467:
0468: // Create the MBean for the ContextResourceLink itself
0469: if (debug >= 3) {
0470: log("Creating MBean for ContextResourceLink "
0471: + resourceLink);
0472: }
0473: MBeanUtils.createMBean(resourceLink);
0474:
0475: }
0476:
0477: /**
0478: * Create the MBeans for the specified Engine and its nested components.
0479: *
0480: * @param engine Engine for which to create MBeans
0481: *
0482: * @exception Exception if an exception is thrown during MBean creation
0483: */
0484: protected void createMBeans(Engine engine) throws Exception {
0485:
0486: // Create the MBean for the Engine itself
0487: if (debug >= 2) {
0488: log("Creating MBean for Engine " + engine);
0489: }
0490: MBeanUtils.createMBean(engine);
0491: engine.addContainerListener(this );
0492: if (engine instanceof StandardEngine) {
0493: ((StandardEngine) engine).addPropertyChangeListener(this );
0494: }
0495:
0496: // Create the MBeans for the associated nested components
0497: Logger eLogger = engine.getLogger();
0498: if (eLogger != null) {
0499: if (debug >= 2)
0500: log("Creating MBean for Logger " + eLogger);
0501: MBeanUtils.createMBean(eLogger);
0502: }
0503: Realm eRealm = engine.getRealm();
0504: if (eRealm != null) {
0505: if (debug >= 2)
0506: log("Creating MBean for Realm " + eRealm);
0507: MBeanUtils.createMBean(eRealm);
0508: }
0509:
0510: // Create the MBeans for the associated Valves
0511: if (engine instanceof StandardEngine) {
0512: Valve eValves[] = ((StandardEngine) engine).getValves();
0513: for (int j = 0; j < eValves.length; j++) {
0514: if (debug >= 2)
0515: log("Creating MBean for Valve " + eValves[j]);
0516: MBeanUtils.createMBean(eValves[j]);
0517: }
0518: }
0519:
0520: // Create the MBeans for each child Host
0521: Container hosts[] = engine.findChildren();
0522: for (int j = 0; j < hosts.length; j++) {
0523: createMBeans((Host) hosts[j]);
0524: }
0525:
0526: }
0527:
0528: /**
0529: * Create the MBeans for the specified Host and its nested components.
0530: *
0531: * @param host Host for which to create MBeans
0532: *
0533: * @exception Exception if an exception is thrown during MBean creation
0534: */
0535: protected void createMBeans(Host host) throws Exception {
0536:
0537: // Create the MBean for the Host itself
0538: if (debug >= 3) {
0539: log("Creating MBean for Host " + host);
0540: }
0541: MBeanUtils.createMBean(host);
0542: host.addContainerListener(this );
0543: if (host instanceof StandardHost) {
0544: ((StandardHost) host).addPropertyChangeListener(this );
0545: }
0546:
0547: // Create the MBeans for the associated nested components
0548: Logger eLogger = host.getParent().getLogger();
0549: Logger hLogger = host.getLogger();
0550: if ((hLogger != null) && (hLogger != eLogger)) {
0551: if (debug >= 3)
0552: log("Creating MBean for Logger " + hLogger);
0553: MBeanUtils.createMBean(hLogger);
0554: }
0555: Realm eRealm = host.getParent().getRealm();
0556: Realm hRealm = host.getRealm();
0557: if ((hRealm != null) && (hRealm != eRealm)) {
0558: if (debug >= 3)
0559: log("Creating MBean for Realm " + hRealm);
0560: MBeanUtils.createMBean(hRealm);
0561: }
0562:
0563: // Create the MBeans for the associated Valves
0564: if (host instanceof StandardHost) {
0565: Valve hValves[] = ((StandardHost) host).getValves();
0566: for (int k = 0; k < hValves.length; k++) {
0567: if (debug >= 3)
0568: log("Creating MBean for Valve " + hValves[k]);
0569: MBeanUtils.createMBean(hValves[k]);
0570: }
0571: }
0572:
0573: // Create the MBeans for each child Context
0574: Container contexts[] = host.findChildren();
0575: for (int k = 0; k < contexts.length; k++) {
0576: createMBeans((Context) contexts[k]);
0577: }
0578:
0579: }
0580:
0581: /**
0582: * Create the MBeans for MBeanFactory.
0583: *
0584: * @param factory MBeanFactory for which to create MBean
0585: *
0586: * @exception Exception if an exception is thrown during MBean creation
0587: */
0588: protected void createMBeans(MBeanFactory factory) throws Exception {
0589:
0590: // Create the MBean for the MBeanFactory
0591: if (debug >= 2)
0592: log("Creating MBean for MBeanFactory " + factory);
0593: MBeanUtils.createMBean(factory);
0594:
0595: }
0596:
0597: /**
0598: * Create the MBeans for the specified NamingResources and its
0599: * nested components.
0600: *
0601: * @param resources NamingResources for which to create MBeans
0602: */
0603: protected void createMBeans(NamingResources resources)
0604: throws Exception {
0605:
0606: // Create the MBean for the NamingResources itself
0607: if (debug >= 2) {
0608: log("Creating MBean for NamingResources " + resources);
0609: }
0610: MBeanUtils.createMBean(resources);
0611: resources.addPropertyChangeListener(this );
0612:
0613: // Create the MBeans for each child environment entry
0614: ContextEnvironment environments[] = resources
0615: .findEnvironments();
0616: for (int i = 0; i < environments.length; i++) {
0617: createMBeans(environments[i]);
0618: }
0619:
0620: // Create the MBeans for each child resource entry
0621: ContextResource cresources[] = resources.findResources();
0622: for (int i = 0; i < cresources.length; i++) {
0623: createMBeans(cresources[i]);
0624: }
0625:
0626: // Create the MBeans for each child resource link entry
0627: ContextResourceLink cresourcelinks[] = resources
0628: .findResourceLinks();
0629: for (int i = 0; i < cresourcelinks.length; i++) {
0630: createMBeans(cresourcelinks[i]);
0631: }
0632:
0633: }
0634:
0635: /**
0636: * Create the MBeans for the specified Server and its nested components.
0637: *
0638: * @param server Server for which to create MBeans
0639: *
0640: * @exception Exception if an exception is thrown during MBean creation
0641: */
0642: protected void createMBeans(Server server) throws Exception {
0643:
0644: // Create the MBean for the Server itself
0645: if (debug >= 2)
0646: log("Creating MBean for Server " + server);
0647: MBeanUtils.createMBean(server);
0648: if (server instanceof StandardServer) {
0649: ((StandardServer) server).addPropertyChangeListener(this );
0650: }
0651:
0652: // Create the MBeans for the global NamingResources (if any)
0653: NamingResources resources = server.getGlobalNamingResources();
0654: if (resources != null) {
0655: createMBeans(resources);
0656: }
0657:
0658: // Create the MBeans for each child Service
0659: Service services[] = server.findServices();
0660: for (int i = 0; i < services.length; i++) {
0661: // FIXME - Warp object hierarchy not currently supported
0662: if (services[i].getContainer().getClass().getName().equals(
0663: "org.apache.catalina.connector.warp.WarpEngine")) {
0664: if (debug >= 1) {
0665: log("Skipping MBean for Service " + services[i]);
0666: }
0667: continue;
0668: }
0669: createMBeans(services[i]);
0670: }
0671:
0672: }
0673:
0674: /**
0675: * Create the MBeans for the specified Service and its nested components.
0676: *
0677: * @param service Service for which to create MBeans
0678: *
0679: * @exception Exception if an exception is thrown during MBean creation
0680: */
0681: protected void createMBeans(Service service) throws Exception {
0682:
0683: // Create the MBean for the Service itself
0684: if (debug >= 2)
0685: log("Creating MBean for Service " + service);
0686: MBeanUtils.createMBean(service);
0687: if (service instanceof StandardService) {
0688: ((StandardService) service).addPropertyChangeListener(this );
0689: }
0690:
0691: // Create the MBeans for the corresponding Connectors
0692: Connector connectors[] = service.findConnectors();
0693: for (int j = 0; j < connectors.length; j++) {
0694: createMBeans(connectors[j]);
0695: }
0696:
0697: // Create the MBean for the associated Engine and friends
0698: Engine engine = (Engine) service.getContainer();
0699: if (engine != null) {
0700: createMBeans(engine);
0701: }
0702:
0703: }
0704:
0705: /**
0706: * Destroy the MBeans that correspond to every existing node of our tree.
0707: */
0708: protected void destroyMBeans() {
0709:
0710: try {
0711:
0712: destroyMBeans(ServerFactory.getServer());
0713:
0714: } catch (MBeanException t) {
0715:
0716: Exception e = t.getTargetException();
0717: if (e == null) {
0718: e = t;
0719: }
0720: log("destroyMBeans: MBeanException", e);
0721:
0722: } catch (Throwable t) {
0723:
0724: log("destroyMBeans: Throwable", t);
0725:
0726: }
0727:
0728: }
0729:
0730: /**
0731: * Deregister the MBeans for the specified Connector and its nested
0732: * components.
0733: *
0734: * @param connector Connector for which to deregister MBeans
0735: *
0736: * @exception Exception if an exception is thrown during MBean destruction
0737: */
0738: protected void destroyMBeans(Connector connector, Service service)
0739: throws Exception {
0740:
0741: // deregister the MBean for the Connector itself
0742: if (debug >= 5)
0743: log("Destroying MBean for Connector " + connector);
0744: MBeanUtils.destroyMBean(connector, service);
0745:
0746: }
0747:
0748: /**
0749: * Deregister the MBeans for the specified Context and its nested
0750: * components.
0751: *
0752: * @param context Context for which to deregister MBeans
0753: *
0754: * @exception Exception if an exception is thrown during MBean destruction
0755: */
0756: protected void destroyMBeans(Context context) throws Exception {
0757:
0758: // Deregister ourselves as a ContainerListener
0759: context.removeContainerListener(this );
0760:
0761: // destroy the MBeans for the associated Valves
0762: if (context instanceof StandardContext) {
0763: Valve cValves[] = ((StandardContext) context).getValves();
0764: for (int l = 0; l < cValves.length; l++) {
0765: if (debug >= 4)
0766: log("Destroying MBean for Valve " + cValves[l]);
0767: MBeanUtils.destroyMBean(cValves[l], context);
0768: }
0769:
0770: }
0771:
0772: // Destroy the MBeans for the associated nested components
0773: Realm hRealm = context.getParent().getRealm();
0774: Realm cRealm = context.getRealm();
0775: if ((cRealm != null) && (cRealm != hRealm)) {
0776: if (debug >= 4)
0777: log("Destroying MBean for Realm " + cRealm);
0778: MBeanUtils.destroyMBean(cRealm);
0779: }
0780: Manager cManager = context.getManager();
0781: if (cManager != null) {
0782: if (debug >= 4)
0783: log("Destroying MBean for Manager " + cManager);
0784: MBeanUtils.destroyMBean(cManager);
0785: }
0786: Logger hLogger = context.getParent().getLogger();
0787: Logger cLogger = context.getLogger();
0788: if ((cLogger != null) && (cLogger != hLogger)) {
0789: if (debug >= 4)
0790: log("Destroying MBean for Logger " + cLogger);
0791: MBeanUtils.destroyMBean(cLogger);
0792: }
0793: Loader cLoader = context.getLoader();
0794: if (cLoader != null) {
0795: if (debug >= 4)
0796: log("Destroying MBean for Loader " + cLoader);
0797: MBeanUtils.destroyMBean(cLoader);
0798: }
0799:
0800: // Destroy the MBeans for the NamingResources (if any)
0801: NamingResources resources = context.getNamingResources();
0802: if (resources != null) {
0803: destroyMBeans(resources);
0804: }
0805:
0806: // deregister the MBean for the Context itself
0807: if (debug >= 4)
0808: log("Destroying MBean for Context " + context);
0809: MBeanUtils.destroyMBean(context);
0810: if (context instanceof StandardContext) {
0811: ((StandardContext) context)
0812: .removePropertyChangeListener(this );
0813: }
0814:
0815: }
0816:
0817: /**
0818: * Deregister the MBeans for the specified ContextEnvironment entry.
0819: *
0820: * @param environment ContextEnvironment for which to destroy MBeans
0821: *
0822: * @exception Exception if an exception is thrown during MBean destruction
0823: */
0824: protected void destroyMBeans(ContextEnvironment environment)
0825: throws Exception {
0826:
0827: // Destroy the MBean for the ContextEnvironment itself
0828: if (debug >= 3) {
0829: log("Destroying MBean for ContextEnvironment "
0830: + environment);
0831: }
0832: MBeanUtils.destroyMBean(environment);
0833:
0834: }
0835:
0836: /**
0837: * Deregister the MBeans for the specified ContextResource entry.
0838: *
0839: * @param resource ContextResource for which to destroy MBeans
0840: *
0841: * @exception Exception if an exception is thrown during MBean destruction
0842: */
0843: protected void destroyMBeans(ContextResource resource)
0844: throws Exception {
0845:
0846: // Destroy the MBean for the ContextResource itself
0847: if (debug >= 3) {
0848: log("Destroying MBean for ContextResource " + resource);
0849: }
0850: MBeanUtils.destroyMBean(resource);
0851:
0852: }
0853:
0854: /**
0855: * Deregister the MBeans for the specified ContextResourceLink entry.
0856: *
0857: * @param resourceLink ContextResourceLink for which to destroy MBeans
0858: *
0859: * @exception Exception if an exception is thrown during MBean destruction
0860: */
0861: protected void destroyMBeans(ContextResourceLink resourceLink)
0862: throws Exception {
0863:
0864: // Destroy the MBean for the ContextResourceLink itself
0865: if (debug >= 3) {
0866: log("Destroying MBean for ContextResourceLink "
0867: + resourceLink);
0868: }
0869: MBeanUtils.destroyMBean(resourceLink);
0870:
0871: }
0872:
0873: /**
0874: * Deregister the MBeans for the specified Engine and its nested
0875: * components.
0876: *
0877: * @param engine Engine for which to destroy MBeans
0878: *
0879: * @exception Exception if an exception is thrown during MBean destruction
0880: */
0881: protected void destroyMBeans(Engine engine) throws Exception {
0882:
0883: // Deregister ourselves as a ContainerListener
0884: engine.removeContainerListener(this );
0885:
0886: // Deregister the MBeans for each child Host
0887: Container hosts[] = engine.findChildren();
0888: for (int k = 0; k < hosts.length; k++) {
0889: destroyMBeans((Host) hosts[k]);
0890: }
0891:
0892: // Deregister the MBeans for the associated Valves
0893: if (engine instanceof StandardEngine) {
0894: Valve eValves[] = ((StandardEngine) engine).getValves();
0895: for (int k = 0; k < eValves.length; k++) {
0896: if (debug >= 3)
0897: log("Destroying MBean for Valve " + eValves[k]);
0898: MBeanUtils.destroyMBean(eValves[k], engine);
0899: }
0900: }
0901:
0902: // Deregister the MBeans for the associated nested components
0903: Realm eRealm = engine.getRealm();
0904: if (eRealm != null) {
0905: if (debug >= 3)
0906: log("Destroying MBean for Realm " + eRealm);
0907: MBeanUtils.destroyMBean(eRealm);
0908: }
0909: Logger eLogger = engine.getLogger();
0910: if (eLogger != null) {
0911: if (debug >= 3)
0912: log("Destroying MBean for Logger " + eLogger);
0913: MBeanUtils.destroyMBean(eLogger);
0914: }
0915:
0916: // Deregister the MBean for the Engine itself
0917: if (debug >= 2) {
0918: log("Destroying MBean for Engine " + engine);
0919: }
0920: MBeanUtils.destroyMBean(engine);
0921:
0922: }
0923:
0924: /**
0925: * Deregister the MBeans for the specified Host and its nested components.
0926: *
0927: * @param host Host for which to destroy MBeans
0928: *
0929: * @exception Exception if an exception is thrown during MBean destruction
0930: */
0931: protected void destroyMBeans(Host host) throws Exception {
0932:
0933: // Deregister ourselves as a ContainerListener
0934: host.removeContainerListener(this );
0935:
0936: // Deregister the MBeans for each child Context
0937: Container contexts[] = host.findChildren();
0938: for (int k = 0; k < contexts.length; k++) {
0939: destroyMBeans((Context) contexts[k]);
0940: }
0941:
0942: // Deregister the MBeans for the associated Valves
0943: if (host instanceof StandardHost) {
0944: Valve hValves[] = ((StandardHost) host).getValves();
0945: for (int k = 0; k < hValves.length; k++) {
0946: if (debug >= 3)
0947: log("Destroying MBean for Valve " + hValves[k]);
0948: MBeanUtils.destroyMBean(hValves[k], host);
0949: }
0950: }
0951:
0952: // Deregister the MBeans for the associated nested components
0953: Realm eRealm = host.getParent().getRealm();
0954: Realm hRealm = host.getRealm();
0955: if ((hRealm != null) && (hRealm != eRealm)) {
0956: if (debug >= 3)
0957: log("Destroying MBean for Realm " + hRealm);
0958: MBeanUtils.destroyMBean(hRealm);
0959: }
0960: Logger eLogger = host.getParent().getLogger();
0961: Logger hLogger = host.getLogger();
0962: if ((hLogger != null) && (hLogger != eLogger)) {
0963: if (debug >= 3)
0964: log("Destroying MBean for Logger " + hLogger);
0965: MBeanUtils.destroyMBean(hLogger);
0966: }
0967:
0968: // Deregister the MBean for the Host itself
0969: if (debug >= 3) {
0970: log("Destroying MBean for Host " + host);
0971: }
0972: MBeanUtils.destroyMBean(host);
0973:
0974: }
0975:
0976: /**
0977: * Deregister the MBeans for the specified NamingResources and its
0978: * nested components.
0979: *
0980: * @param resources NamingResources for which to destroy MBeans
0981: *
0982: * @exception Exception if an exception is thrown during MBean destruction
0983: */
0984: protected void destroyMBeans(NamingResources resources)
0985: throws Exception {
0986:
0987: // Destroy the MBeans for each child resource entry
0988: ContextResource cresources[] = resources.findResources();
0989: for (int i = 0; i < cresources.length; i++) {
0990: destroyMBeans(cresources[i]);
0991: }
0992:
0993: // Destroy the MBeans for each child resource link entry
0994: ContextResourceLink cresourcelinks[] = resources
0995: .findResourceLinks();
0996: for (int i = 0; i < cresourcelinks.length; i++) {
0997: destroyMBeans(cresourcelinks[i]);
0998: }
0999:
1000: // Destroy the MBeans for each child environment entry
1001: ContextEnvironment environments[] = resources
1002: .findEnvironments();
1003: for (int i = 0; i < environments.length; i++) {
1004: destroyMBeans(environments[i]);
1005: }
1006:
1007: // Destroy the MBean for the NamingResources itself
1008: if (debug >= 2) {
1009: log("Destroying MBean for NamingResources " + resources);
1010: }
1011: MBeanUtils.destroyMBean(resources);
1012: resources.removePropertyChangeListener(this );
1013:
1014: }
1015:
1016: /**
1017: * Deregister the MBeans for the specified Server and its related
1018: * components.
1019: *
1020: * @param server Server for which to destroy MBeans
1021: *
1022: * @exception Exception if an exception is thrown during MBean destruction
1023: */
1024: protected void destroyMBeans(Server server) throws Exception {
1025:
1026: // Destroy the MBeans for the global NamingResources (if any)
1027: NamingResources resources = server.getGlobalNamingResources();
1028: if (resources != null) {
1029: destroyMBeans(resources);
1030: }
1031:
1032: // Destroy the MBeans for each child Service
1033: Service services[] = server.findServices();
1034: for (int i = 0; i < services.length; i++) {
1035: // FIXME - Warp object hierarchy not currently supported
1036: if (services[i].getContainer().getClass().getName().equals(
1037: "org.apache.catalina.connector.warp.WarpEngine")) {
1038: if (debug >= 1) {
1039: log("Skipping MBean for Service " + services[i]);
1040: }
1041: continue;
1042: }
1043: destroyMBeans(services[i]);
1044: }
1045:
1046: // Destroy the MBean for the Server itself
1047: if (debug >= 2) {
1048: log("Destroying MBean for Server " + server);
1049: }
1050: MBeanUtils.destroyMBean(server);
1051: if (server instanceof StandardServer) {
1052: ((StandardServer) server)
1053: .removePropertyChangeListener(this );
1054: }
1055:
1056: }
1057:
1058: /**
1059: * Deregister the MBeans for the specified Service and its nested
1060: * components.
1061: *
1062: * @param service Service for which to destroy MBeans
1063: *
1064: o * @exception Exception if an exception is thrown during MBean destruction
1065: */
1066: protected void destroyMBeans(Service service) throws Exception {
1067:
1068: // Deregister the MBeans for the associated Engine
1069: Engine engine = (Engine) service.getContainer();
1070: if (engine != null) {
1071: destroyMBeans(engine);
1072: }
1073:
1074: // Deregister the MBeans for the corresponding Connectors
1075: Connector connectors[] = service.findConnectors();
1076: for (int j = 0; j < connectors.length; j++) {
1077: destroyMBeans(connectors[j], service);
1078: }
1079:
1080: // Deregister the MBean for the Service itself
1081: if (debug >= 2) {
1082: log("Destroying MBean for Service " + service);
1083: }
1084: MBeanUtils.destroyMBean(service);
1085: if (service instanceof StandardService) {
1086: ((StandardService) service)
1087: .removePropertyChangeListener(this );
1088: }
1089:
1090: }
1091:
1092: /**
1093: * Log a message.
1094: *
1095: * @param message The message to be logged
1096: */
1097: protected void log(String message) {
1098:
1099: System.out.print("ServerLifecycleListener: ");
1100: System.out.println(message);
1101:
1102: }
1103:
1104: /**
1105: * Log a message and associated exception.
1106: *
1107: * @param message The message to be logged
1108: * @param throwable The exception to be logged
1109: */
1110: protected void log(String message, Throwable throwable) {
1111:
1112: log(message);
1113: throwable.printStackTrace(System.out);
1114:
1115: }
1116:
1117: /**
1118: * Process the addition of a new child Container to a parent Container.
1119: *
1120: * @param parent Parent container
1121: * @param child Child container
1122: */
1123: protected void processContainerAddChild(Container parent,
1124: Container child) {
1125:
1126: if (debug >= 1)
1127: log("Process addChild[parent=" + parent + ",child=" + child
1128: + "]");
1129:
1130: try {
1131: if (child instanceof Context) {
1132: createMBeans((Context) child);
1133: } else if (child instanceof Engine) {
1134: createMBeans((Engine) child);
1135: } else if (child instanceof Host) {
1136: createMBeans((Host) child);
1137: }
1138: } catch (MBeanException t) {
1139: Exception e = t.getTargetException();
1140: if (e == null)
1141: e = t;
1142: log("processContainerAddChild: MBeanException", e);
1143: } catch (Throwable t) {
1144: log("processContainerAddChild: Throwable", t);
1145: }
1146:
1147: }
1148:
1149: /**
1150: * Process the addition of a new Valve to a Container.
1151: *
1152: * @param container The affected Container
1153: * @param valve The new Valve
1154: */
1155: protected void processContainerAddValve(Container container,
1156: Valve valve) throws Exception {
1157:
1158: if (debug >= 1) {
1159: log("Process addValve[container=" + container + ",valve="
1160: + valve + "]");
1161: }
1162:
1163: if (debug >= 4) {
1164: log("Creating MBean for Valve " + valve);
1165: }
1166: MBeanUtils.createMBean(valve);
1167:
1168: }
1169:
1170: /**
1171: * Process a property change event on a Container.
1172: *
1173: * @param container The container on which this event occurred
1174: * @param propertyName The name of the property that changed
1175: * @param oldValue The previous value (may be <code>null</code>)
1176: * @param newValue The new value (may be <code>null</code>)
1177: *
1178: * @exception Exception if an exception is thrown
1179: */
1180: protected void processContainerPropertyChange(Container container,
1181: String propertyName, Object oldValue, Object newValue)
1182: throws Exception {
1183:
1184: if (debug >= 6) {
1185: log("propertyChange[container=" + container
1186: + ",propertyName=" + propertyName + ",oldValue="
1187: + oldValue + ",newValue=" + newValue + "]");
1188: }
1189: if ("defaultContext".equals(propertyName)) {
1190: if (oldValue != null) {
1191: if (debug >= 5) {
1192: log("Removing MBean for DefaultContext " + oldValue);
1193: }
1194: MBeanUtils.destroyMBean((DefaultContext) oldValue);
1195: }
1196: if (newValue != null) {
1197: if (debug >= 5) {
1198: log("Creating MBean for DefaultContext " + newValue);
1199: }
1200: MBeanUtils.createMBean((DefaultContext) newValue);
1201: }
1202: } else if ("loader".equals(propertyName)) {
1203: if (oldValue != null) {
1204: if (debug >= 5) {
1205: log("Removing MBean for Loader " + oldValue);
1206: }
1207: MBeanUtils.destroyMBean((Loader) oldValue);
1208: }
1209: if (newValue != null) {
1210: if (debug >= 5) {
1211: log("Creating MBean for Loader " + newValue);
1212: }
1213: MBeanUtils.createMBean((Loader) newValue);
1214: }
1215: } else if ("logger".equals(propertyName)) {
1216: if (oldValue != null) {
1217: if (debug >= 5) {
1218: log("Removing MBean for Logger " + oldValue);
1219: }
1220: MBeanUtils.destroyMBean((Logger) oldValue);
1221: }
1222: if (newValue != null) {
1223: if (debug >= 5) {
1224: log("Creating MBean for Logger " + newValue);
1225: }
1226: MBeanUtils.createMBean((Logger) newValue);
1227: }
1228: } else if ("manager".equals(propertyName)) {
1229: if (oldValue != null) {
1230: if (debug >= 5) {
1231: log("Removing MBean for Manager " + oldValue);
1232: }
1233: MBeanUtils.destroyMBean((Manager) oldValue);
1234: }
1235: if (newValue != null) {
1236: if (debug >= 5) {
1237: log("Creating MBean for Manager " + newValue);
1238: }
1239: MBeanUtils.createMBean((Manager) newValue);
1240: }
1241: } else if ("realm".equals(propertyName)) {
1242: if (oldValue != null) {
1243: if (debug >= 5) {
1244: log("Removing MBean for Realm " + oldValue);
1245: }
1246: MBeanUtils.destroyMBean((Realm) oldValue);
1247: }
1248: if (newValue != null) {
1249: if (debug >= 5) {
1250: log("Creating MBean for Realm " + newValue);
1251: }
1252: MBeanUtils.createMBean((Realm) newValue);
1253: }
1254: } else if ("service".equals(propertyName)) {
1255: if (oldValue != null) {
1256: destroyMBeans((Service) oldValue);
1257: }
1258: if (newValue != null) {
1259: createMBeans((Service) newValue);
1260: }
1261: }
1262:
1263: }
1264:
1265: /**
1266: * Process the removal of a child Container from a parent Container.
1267: *
1268: * @param parent Parent container
1269: * @param child Child container
1270: */
1271: protected void processContainerRemoveChild(Container parent,
1272: Container child) {
1273:
1274: if (debug >= 1)
1275: log("Process removeChild[parent=" + parent + ",child="
1276: + child + "]");
1277:
1278: try {
1279: if (child instanceof Context) {
1280: Context context = (Context) child;
1281: if (context.getPrivileged()) {
1282: context.getServletContext().removeAttribute(
1283: Globals.MBEAN_REGISTRY_ATTR);
1284: context.getServletContext().removeAttribute(
1285: Globals.MBEAN_SERVER_ATTR);
1286: }
1287: if (debug >= 4)
1288: log(" Removing MBean for Context " + context);
1289: destroyMBeans(context);
1290: if (context instanceof StandardContext) {
1291: ((StandardContext) context)
1292: .removePropertyChangeListener(this );
1293: }
1294: } else if (child instanceof Host) {
1295: Host host = (Host) child;
1296: destroyMBeans(host);
1297: if (host instanceof StandardHost) {
1298: ((StandardHost) host)
1299: .removePropertyChangeListener(this );
1300: }
1301: }
1302: } catch (MBeanException t) {
1303: Exception e = t.getTargetException();
1304: if (e == null)
1305: e = t;
1306: log("processContainerRemoveChild: MBeanException", e);
1307: } catch (Throwable t) {
1308: log("processContainerRemoveChild: Throwable", t);
1309: }
1310:
1311: }
1312:
1313: /**
1314: * Process the removal of a Valve from a Container.
1315: *
1316: * @param container The affected Container
1317: * @param valve The old Valve
1318: */
1319: protected void processContainerRemoveValve(Container container,
1320: Valve valve) {
1321:
1322: if (debug >= 1)
1323: log("Process removeValve[container=" + container
1324: + ",valve=" + valve + "]");
1325:
1326: try {
1327: MBeanUtils.destroyMBean(valve, container);
1328: } catch (MBeanException t) {
1329: Exception e = t.getTargetException();
1330: if (e == null)
1331: e = t;
1332: log("processContainerRemoveValve: MBeanException", e);
1333: } catch (Throwable t) {
1334: log("processContainerRemoveValve: Throwable", t);
1335: }
1336:
1337: }
1338:
1339: /**
1340: * Process a property change event on a NamingResources.
1341: *
1342: * @param resources The global naming resources on which this
1343: * event occurred
1344: * @param propertyName The name of the property that changed
1345: * @param oldValue The previous value (may be <code>null</code>)
1346: * @param newValue The new value (may be <code>null</code>)
1347: *
1348: * @exception Exception if an exception is thrown
1349: */
1350: protected void processNamingResourcesPropertyChange(
1351: NamingResources resources, String propertyName,
1352: Object oldValue, Object newValue) throws Exception {
1353:
1354: if (debug >= 6) {
1355: log("propertyChange[namingResources=" + resources
1356: + ",propertyName=" + propertyName + ",oldValue="
1357: + oldValue + ",newValue=" + newValue + "]");
1358: }
1359:
1360: // FIXME - Add other resource types when supported by admin tool
1361: if ("environment".equals(propertyName)) {
1362: if (oldValue != null) {
1363: destroyMBeans((ContextEnvironment) oldValue);
1364: }
1365: if (newValue != null) {
1366: createMBeans((ContextEnvironment) newValue);
1367: }
1368: } else if ("resource".equals(propertyName)) {
1369: if (oldValue != null) {
1370: destroyMBeans((ContextResource) oldValue);
1371: }
1372: if (newValue != null) {
1373: createMBeans((ContextResource) newValue);
1374: }
1375: } else if ("resourceLink".equals(propertyName)) {
1376: if (oldValue != null) {
1377: destroyMBeans((ContextResourceLink) oldValue);
1378: }
1379: if (newValue != null) {
1380: createMBeans((ContextResourceLink) newValue);
1381: }
1382: }
1383:
1384: }
1385:
1386: /**
1387: * Process a property change event on a Server.
1388: *
1389: * @param server The server on which this event occurred
1390: * @param propertyName The name of the property that changed
1391: * @param oldValue The previous value (may be <code>null</code>)
1392: * @param newValue The new value (may be <code>null</code>)
1393: *
1394: * @exception Exception if an exception is thrown
1395: */
1396: protected void processServerPropertyChange(Server server,
1397: String propertyName, Object oldValue, Object newValue)
1398: throws Exception {
1399:
1400: if (debug >= 6) {
1401: log("propertyChange[server=" + server + ",propertyName="
1402: + propertyName + ",oldValue=" + oldValue
1403: + ",newValue=" + newValue + "]");
1404: }
1405: if ("globalNamingResources".equals(propertyName)) {
1406: if (oldValue != null) {
1407: destroyMBeans((NamingResources) oldValue);
1408: }
1409: if (newValue != null) {
1410: createMBeans((NamingResources) newValue);
1411: }
1412: } else if ("service".equals(propertyName)) {
1413: if (oldValue != null) {
1414: destroyMBeans((Service) oldValue);
1415: }
1416: if (newValue != null) {
1417: createMBeans((Service) newValue);
1418: }
1419: }
1420:
1421: }
1422:
1423: /**
1424: * Process a property change event on a Service.
1425: *
1426: * @param service The service on which this event occurred
1427: * @param propertyName The name of the property that changed
1428: * @param oldValue The previous value (may be <code>null</code>)
1429: * @param newValue The new value (may be <code>null</code>)
1430: *
1431: * @exception Exception if an exception is thrown
1432: */
1433: protected void processServicePropertyChange(Service service,
1434: String propertyName, Object oldValue, Object newValue)
1435: throws Exception {
1436:
1437: if (debug >= 6) {
1438: log("propertyChange[service=" + service + ",propertyName="
1439: + propertyName + ",oldValue=" + oldValue
1440: + ",newValue=" + newValue + "]");
1441: }
1442: if ("connector".equals(propertyName)) {
1443: if (oldValue != null) {
1444: destroyMBeans((Connector) oldValue, service);
1445: }
1446: if (newValue != null) {
1447: createMBeans((Connector) newValue);
1448: }
1449: } else if ("container".equals(propertyName)) {
1450: if (oldValue != null) {
1451: destroyMBeans((Engine) oldValue);
1452: }
1453: if (newValue != null) {
1454: createMBeans((Engine) newValue);
1455: }
1456: }
1457:
1458: }
1459:
1460: }
|