User: d_jencks Date: 01/11/14 22:30:22 Modified: src/main/org/jboss/system ServiceConfigurator.java Log: Added anonymous mbean-ref and mbean-ref-lists. (i.e, don't supply a name). See hsqldb-default-service for an example Revision Changes Path 1.7 +82 -64 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ServiceConfigurator.java 2001/11/13 07:55:00 1.6 +++ ServiceConfigurator.java 2001/11/15 06:30:22 1.7 @@ -42,7 +42,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> * @author <a href="mailto:[EMAIL PROTECTED]">Hiram Chirino</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * * <p><b>20010830 marc fleury:</b> * <ul> @@ -237,40 +237,49 @@ } // Set mbean references (object names) ArrayList mBeanRefs = new ArrayList(); - NodeList mbeanRefElements = mbeanElement.getElementsByTagName("mbean-ref"); - log.debug("found " + mbeanRefElements.getLength() + " mbean-ref elements"); - for (int j = 0; j < mbeanRefElements.getLength(); j++) { - Element mbeanRefElement = (Element)mbeanRefElements.item(j); - String mbeanRefName = mbeanRefElement.getAttribute("name"); - if (!mbeanRefElement.hasChildNodes()) + NodeList mBeanRefElements = mbeanElement.getElementsByTagName("mbean-ref"); + log.debug("found " + mBeanRefElements.getLength() + " mbean-ref elements"); + for (int j = 0; j < mBeanRefElements.getLength(); j++) { + Element mBeanRefElement = (Element)mBeanRefElements.item(j); + String mBeanRefName = mBeanRefElement.getAttribute("name"); + if (!mBeanRefElement.hasChildNodes()) { - throw new DeploymentException("No ObjectName supplied for mbean-ref " + mbeanRefName); + throw new DeploymentException("No ObjectName supplied for mbean-ref " + mBeanRefName); } // Get the mbeanRef value - String mbeanRefValue = ((Text)mbeanRefElement.getFirstChild()).getData().trim(); - ObjectName mbeanRefObjectName = new ObjectName(mbeanRefValue); - log.debug("considering " + mbeanRefName + " with object name " + mbeanRefObjectName); - MBeanAttributeInfo[] attributes = info.getAttributes(); - 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 (!mBeanRefs.contains(mbeanRefObjectName)) - { - mBeanRefs.add(mbeanRefObjectName); - } // end of if () + String mBeanRefValue = ((Text)mBeanRefElement.getFirstChild()).getData().trim(); + ObjectName mBeanRefObjectName = new ObjectName(mBeanRefValue); + if (!mBeanRefs.contains(mBeanRefObjectName)) + { + mBeanRefs.add(mBeanRefObjectName); + } // end of if () + namefound: + if (mBeanRefName == null || "".equals(mBeanRefName)) + { + log.debug("Anonymous dependency on object name " + mBeanRefObjectName); + } // end of if () + else + { + log.debug("considering " + mBeanRefName + " with object name " + mBeanRefObjectName); + MBeanAttributeInfo[] attributes = info.getAttributes(); + 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 () - log.debug(mbeanRefName + " set to " + mbeanRefValue + " in " + objectName); - server.setAttribute(objectName, new Attribute(mbeanRefName, mbeanRefObjectName)); + log.debug(mBeanRefName + " set to " + mBeanRefValue + " in " + objectName); + server.setAttribute(objectName, new Attribute(mBeanRefName, mBeanRefObjectName)); - break; - } - } - + break namefound; + }//name test + }//for + throw new DeploymentException("No Attribute found with name: " + mBeanRefName); + } // end of else + //breaks to here } // Set lists of mbean references (object names) @@ -278,42 +287,51 @@ for (int j = 0; j < mBeanRefLists.getLength(); j++) { Element mBeanRefListElement = (Element)mBeanRefLists.item(j); String mBeanRefListName = mBeanRefListElement.getAttribute("name"); - - MBeanAttributeInfo[] attributes = info.getAttributes(); - for (int k = 0; k < attributes.length; k++) { - if (mBeanRefListName.equals(attributes[k].getName())) { - - NodeList mBeanRefList = mBeanRefListElement.getElementsByTagName("mbean-ref-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 mbean-ref-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 (!mBeanRefs.contains(mBeanRefObjectName)) - { - mBeanRefs.add(mBeanRefObjectName); - } // end of if () + //Make the list of object names, and add them to mbeanRefs. + NodeList mBeanRefList = mBeanRefListElement.getElementsByTagName("mbean-ref-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 mbean-ref-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 (!mBeanRefs.contains(mBeanRefObjectName)) + { + mBeanRefs.add(mBeanRefObjectName); + } // end of if () - } // end of for () - - log.debug(mBeanRefListName + " set to " + mBeanRefListNames + " in " + objectName); - server.setAttribute(objectName, new Attribute(mBeanRefListName, mBeanRefListNames)); - - break; - } - - } + } // end of for () + //Now look for the name + listnamefound: + if (mBeanRefListName == null || "".equals(mBeanRefListName)) + { + log.debug("Anonymous dependency on list of object names " + mBeanRefListNames); + + } // end of if () + else + { + MBeanAttributeInfo[] attributes = info.getAttributes(); + for (int k = 0; k < attributes.length; k++) { + if (mBeanRefListName.equals(attributes[k].getName())) { + log.debug(mBeanRefListName + " set to " + mBeanRefListNames + " in " + objectName); + server.setAttribute(objectName, new Attribute(mBeanRefListName, mBeanRefListNames)); + + break listnamefound; + }//if name matches + }//for + throw new DeploymentException("No Attribute found with name: " + mBeanRefListName); + } // end of else + //breaks to here } return mBeanRefs; }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development