User: d_jencks Date: 01/12/19 22:12:10 Modified: src/main/org/jboss/system ServiceConfigurator.java ServiceController.java Log: Simplified depends tags and made anonymous depends tags work Revision Changes Path 1.15 +46 -59 jboss/src/main/org/jboss/system/ServiceConfigurator.java Index: ServiceConfigurator.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceConfigurator.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ServiceConfigurator.java 2001/12/19 06:24:41 1.14 +++ ServiceConfigurator.java 2001/12/20 06:12:09 1.15 @@ -40,7 +40,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> * @author <a href="mailto:[EMAIL PROTECTED]">Hiram Chirino</a> -* @version $Revision: 1.14 $ +* @version $Revision: 1.15 $ * * <p><b>20010830 marc fleury:</b> * <ul> @@ -264,7 +264,7 @@ log.debug("found " + dependsElements.getLength() + " depends elements"); for (int j = 0; j < dependsElements.getLength(); j++) { Element dependsElement = (Element)dependsElements.item(j); - + dependAttrFound: if (!dependsElement.hasChildNodes()) { throw new DeploymentException("No ObjectName supplied for depends in " + objectName); @@ -272,30 +272,25 @@ } String mbeanRefName = dependsElement.getAttribute("optional-attribute-name"); + if ("".equals(mbeanRefName)) + { + mbeanRefName = null; + } // end of if () // Get the mbeanRef value String value = ((Text)dependsElement.getFirstChild()).getData().trim(); ObjectName dependsObjectName = new ObjectName(value); - log.debug("considering " + mbeanRefName + " with object name " + dependsObjectName); - for (int k = 0; k < attributes.length; k++) { - if (mbeanRefName.equals(attributes[k].getName())) { - String typeName = attributes[k].getType(); - if (!"javax.management.ObjectName".equals(typeName)) - { - throw new DeploymentException("Trying to set " + mbeanRefName + " as an MBeanRef when it is not of type ObjectName"); - } // end of if () - if (!mbeans.contains(dependsObjectName)) - { - mbeans.add(dependsObjectName); - } // end of if () - - log.debug(mbeanRefName + " set to " + value); - server.setAttribute(objectName, new Attribute(mbeanRefName, dependsObjectName)); - - break; - } - } + if (!mbeans.contains(dependsObjectName)) + { + mbeans.add(dependsObjectName); + } // end of if () + log.debug("considering " + ((mbeanRefName == null)? "<anonymous>": mbeanRefName.toString()) + " with object name " + dependsObjectName); + if (mbeanRefName != null) + { + //if if doesn't exist or has wrong type, we'll get an exception + server.setAttribute(objectName, new Attribute(mbeanRefName, dependsObjectName)); + } // end of if () } @@ -305,47 +300,39 @@ for (int j = 0; j < mBeanRefLists.getLength(); j++) { Element mBeanRefListElement = (Element)mBeanRefLists.item(j); String mBeanRefListName = mBeanRefListElement.getAttribute("optional-attribute-name"); - - for (int k = 0; k < attributes.length; k++) { - if (mBeanRefListName.equals(attributes[k].getName())) { - - NodeList mBeanRefList = mBeanRefListElement.getElementsByTagName("depends-list-element"); - ArrayList mBeanRefListNames = new ArrayList(); - for (int l = 0; l < mBeanRefList.getLength(); l++) - { - Element mBeanRefElement = (Element)mBeanRefList.item(l); - if (!mBeanRefElement.hasChildNodes()) - { - throw new DeploymentException("Empty depends-list-element!"); - } // end of if () - - // Get the mbeanRef value - String mBeanRefValue = ((Text)mBeanRefElement.getFirstChild()).getData().trim(); - ObjectName mBeanRefObjectName = new ObjectName(mBeanRefValue); - if (!mBeanRefListNames.contains(mBeanRefObjectName)) - { - mBeanRefListNames.add(mBeanRefObjectName); - } // end of if () - if (!mbeans.contains(mBeanRefObjectName)) - { - mbeans.add(mBeanRefObjectName); - } // end of if () - - } // end of for () - - log.debug(mBeanRefListName + " set to " + mBeanRefListNames + " in " + objectName); - server.setAttribute(objectName, new Attribute(mBeanRefListName, mBeanRefListNames)); + if ("".equals(mBeanRefListName)) + { + mBeanRefListName = null; + } // end of if () - break; - } + NodeList mBeanRefList = mBeanRefListElement.getElementsByTagName("depends-list-element"); + ArrayList mBeanRefListNames = new ArrayList(); + for (int l = 0; l < mBeanRefList.getLength(); l++) + { + Element mBeanRefElement = (Element)mBeanRefList.item(l); + if (!mBeanRefElement.hasChildNodes()) + { + throw new DeploymentException("Empty depends-list-element!"); + } // end of if () - } + // Get the mbeanRef value + String mBeanRefValue = ((Text)mBeanRefElement.getFirstChild()).getData().trim(); + ObjectName mBeanRefObjectName = new ObjectName(mBeanRefValue); + if (!mBeanRefListNames.contains(mBeanRefObjectName)) + { + mBeanRefListNames.add(mBeanRefObjectName); + } // end of if () + if (!mbeans.contains(mBeanRefObjectName)) + { + mbeans.add(mBeanRefObjectName); + } // end of if () + + } // end of for () + if (mBeanRefListName != null) + { + server.setAttribute(objectName, new Attribute(mBeanRefListName, mBeanRefListNames)); + } // end of if () } - - - - - return mbeans; } 1.20 +12 -8 jboss/src/main/org/jboss/system/ServiceController.java Index: ServiceController.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceController.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- ServiceController.java 2001/12/19 19:52:20 1.19 +++ ServiceController.java 2001/12/20 06:12:10 1.20 @@ -43,7 +43,7 @@ * @see org.jboss.system.Service * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> * @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a> -* @version $Revision: 1.19 $ <p> +* @version $Revision: 1.20 $ <p> * * <b>Revisions:</b> <p> * @@ -206,6 +206,7 @@ // We work from the service context, if it doesn't exist yet, we have a wrapper (OK) ServiceContext service = getServiceContext((ObjectName) iterator.next()); + log.debug("recording that " + ctx.objectName + " depends on " + service.objectName); // ctx depends on service ctx.iDependOn.add(service); @@ -357,7 +358,7 @@ { ServiceContext ctx = (ServiceContext) nameToServiceMap.get(serviceName); - + log.debug("stopping service: " + serviceName); if (ctx != null) { // If we are already stopped (can happen in dependencies) just return @@ -366,21 +367,20 @@ // JSR 77 and to avoid circular dependencies ctx.state = ServiceContext.STOPPED; + log.debug("service context has " + ctx.dependsOnMe.size() + " depending services"); Iterator iterator = ctx.dependsOnMe.iterator(); while (iterator.hasNext()) { - // stop all the mbeans that depend on me - stop(((ServiceContext) iterator.next()).objectName); + ObjectName other = ((ServiceContext) iterator.next()).objectName; + log.debug("stopping dependent service " + other); + stop(other); } // Call create on the service Proxy try { ctx.proxy.stop(); } catch (Exception e){ ctx.state = ServiceContext.FAILED; throw e;} - - - } } @@ -395,6 +395,7 @@ { ServiceContext ctx = (ServiceContext) nameToServiceMap.get(serviceName); + log.debug("destroying service: " + serviceName); if (ctx != null) { @@ -409,7 +410,9 @@ { // destroy all the mbeans that depend on me - destroy(((ServiceContext) iterator.next()).objectName); + ObjectName other = ((ServiceContext) iterator.next()).objectName; + log.debug("destroying dependent service " + other); + destroy(other); } // Call create on the service Proxy @@ -446,6 +449,7 @@ { ServiceContext ctx = getServiceContext(objectName); + log.debug("removing service: " + objectName); // Notify those that think I depend on them Iterator iterator = ctx.iDependOn.iterator();
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development