You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2003/10/25 00:47:28 UTC

cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/service MBeanMetadataXMLLoader.java

dain        2003/10/24 15:47:28

  Modified:    modules/kernel/src/java/org/apache/geronimo/kernel/deployment/service
                        MBeanMetadataXMLLoader.java
  Log:
  Moved getValue code to XMLUtil.getContent
  
  Revision  Changes    Path
  1.2       +4 -41     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/service/MBeanMetadataXMLLoader.java
  
  Index: MBeanMetadataXMLLoader.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/service/MBeanMetadataXMLLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MBeanMetadataXMLLoader.java	8 Sep 2003 04:38:33 -0000	1.1
  +++ MBeanMetadataXMLLoader.java	24 Oct 2003 22:47:28 -0000	1.2
  @@ -67,7 +67,6 @@
   import org.apache.geronimo.kernel.service.GeronimoMBeanInfoXMLLoader;
   
   import org.w3c.dom.Element;
  -import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
   
   /**
  @@ -76,12 +75,6 @@
    * @version $Revision$ $Date$
    */
   public class MBeanMetadataXMLLoader {
  -    private final GeronimoMBeanInfoXMLLoader xmlLoader;
  -
  -    public MBeanMetadataXMLLoader() throws DeploymentException {
  -        this.xmlLoader = new GeronimoMBeanInfoXMLLoader();
  -    }
  -
       public MBeanMetadata loadXML(URI baseURI, Element element) throws DeploymentException {
           MBeanMetadata md = new MBeanMetadata();
           md.setBaseURI(baseURI);
  @@ -92,7 +85,7 @@
           String descriptor = element.getAttribute("descriptor").trim();
           if (descriptor.length() > 0) {
               URI descriptorURI = baseURI.resolve(descriptor);
  -            GeronimoMBeanInfo geronimoMBeanInfo = xmlLoader.loadXML(descriptorURI);
  +            GeronimoMBeanInfo geronimoMBeanInfo = GeronimoMBeanInfoXMLLoader.loadMBean(descriptorURI);
               md.setGeronimoMBeanInfo(geronimoMBeanInfo);
           }
           String s = element.getAttribute("name").trim();
  @@ -114,7 +107,7 @@
                   Element argElement = (Element) nl.item(i);
                   String type = argElement.getAttribute("type");
                   types.add(type);
  -                args.add(getValue(argElement));
  +                args.add(XMLUtil.getContent(argElement));
               }
           }
   
  @@ -123,7 +116,7 @@
           for (int i = 0; i < nl.getLength(); i++) {
               Element argElement = (Element) nl.item(i);
               String name = argElement.getAttribute("name");
  -            attrs.put(name, getValue(argElement));
  +            attrs.put(name, XMLUtil.getContent(argElement));
           }
   
           nl = element.getElementsByTagName("relationship");
  @@ -157,35 +150,5 @@
           }
   
           return md;
  -    }
  -
  -    /**
  -     * Return the value of an argument node.
  -     * If the node contains an Element, then the Element is returned;
  -     * otherwise the content of the node (after stripping comments and trimming)
  -     * is returned, or null if it is empty or zero length
  -     * @param element the element to extract the value from
  -     * @return the value of the node (a String or Element)
  -     */
  -    private Object getValue(Element element) {
  -        NodeList nl = element.getChildNodes();
  -        if (nl.getLength() == 0) {
  -            return null;
  -        }
  -
  -        StringBuffer content = new StringBuffer();
  -        for (int i = 0; i < nl.getLength(); i++) {
  -            Node node = nl.item(i);
  -            switch (node.getNodeType()) {
  -            case Node.ELEMENT_NODE:
  -                return node;
  -            case Node.CDATA_SECTION_NODE:
  -            case Node.TEXT_NODE:
  -                content.append(node.getNodeValue());
  -                break;
  -            }
  -        }
  -        String s = content.toString().trim();
  -        return (s.length() > 0) ? s : null;
       }
   }