User: mulder  
  Date: 00/06/19 20:22:04

  Modified:    src/main/org/jboss/configuration ConfigurationService.java
  Log:
  Update Minerva XA MBeans to use new configuration architecture.
  Make build script copy JCML configuration file.
  Add "long" variables to configuration architecture.
  
  This still won't work unless you're lucky due to dependency on
  TransactionManager being loaded beforehand.
  
  Revision  Changes    Path
  1.2       +42 -41    jboss/src/main/org/jboss/configuration/ConfigurationService.java
  
  Index: ConfigurationService.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/configuration/ConfigurationService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigurationService.java 2000/06/16 13:13:28     1.1
  +++ ConfigurationService.java 2000/06/20 03:22:03     1.2
  @@ -4,7 +4,7 @@
    * Distributable under GPL license.
    * See terms of license at gnu.org.
    */
  - 
  +
   package org.jboss.configuration;
   
   import java.io.*;
  @@ -23,11 +23,11 @@
   import org.jboss.util.ServiceMBeanSupport;
   
   /**
  - *   <description> 
  - *      
  + *   <description>
  + *
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public class ConfigurationService
      extends ServiceMBeanSupport
  @@ -35,26 +35,27 @@
   {
      // Constants -----------------------------------------------------
        static Hashtable primitives = new Hashtable();
  -     
  +
        static
        {
                primitives.put("int",Integer.TYPE);
                primitives.put("boolean",Boolean.TYPE);
                primitives.put("double",Double.TYPE);
                primitives.put("float",Float.TYPE);
  +        primitives.put("long",Long.TYPE);
        }
  -     
  +
      // Attributes ----------------------------------------------------
        Log log = new Log(getName());
  -     
  +
        String configurationUrl = "jboss.jcml";
  -     
  +
        MBeanServer server;
  -   
  +
      // Static --------------------------------------------------------
   
      // Constructors --------------------------------------------------
  -   
  +
      // Public --------------------------------------------------------
        public ObjectName getObjectName(MBeanServer server, ObjectName name)
           throws javax.management.MalformedObjectNameException
  @@ -62,12 +63,12 @@
                this.server = server;
           return new ObjectName(OBJECT_NAME);
        }
  -     
  +
        public String getName()
        {
           return "Configuration";
        }
  -     
  +
        public void load(String configuration)
                throws Exception
        {
  @@ -78,27 +79,27 @@
                        XmlDocumentBuilder xdb = new XmlDocumentBuilder();
                        Parser parser = new com.sun.xml.parser.Parser();
                        xdb.setParser(parser);
  -                     
  -                     try 
  -                     { 
  +
  +                     try
  +                     {
                                parser.parse(new InputSource(new 
StringReader(configuration)));
                                doc = xdb.getDocument();
  -                     } 
  -                     catch (SAXException se) 
  -                     { 
  -                          throw new IOException(se.getMessage()); 
  -                     } 
  -                     
  +                     }
  +                     catch (SAXException se)
  +                     {
  +                          throw new IOException(se.getMessage());
  +                     }
  +
                        // Set configuration to MBeans from XML
                        NodeList nl = doc.getElementsByTagName("mbean");
                        for (int i = 0; i < nl.getLength(); i++)
                        {
                                Element mbeanElement = (Element)nl.item(i);
  -                             
  +
                                String name = mbeanElement.getAttribute("name");
                                ObjectName objectName = new ObjectName(name);
                                MBeanInfo info = server.getMBeanInfo(objectName);
  -                             
  +
                                NodeList attrs = 
mbeanElement.getElementsByTagName("attribute");
                                for (int j = 0; j < attrs.getLength(); j++)
                                {
  @@ -107,7 +108,7 @@
                                        if (attributeElement.hasChildNodes())
                                        {
                                                String attributeValue = 
((Text)attributeElement.getFirstChild()).getData();
  -                                     
  +
                                                MBeanAttributeInfo[] attributes = 
info.getAttributes();
                                                for (int k = 0; k < attributes.length; 
k++)
                                                {
  @@ -125,15 +126,15 @@
                                                                PropertyEditor editor 
= PropertyEditorManager.findEditor(typeClass);
                                                                
editor.setAsText(attributeValue);
                                                                Object value = 
editor.getValue();
  -                                                             
  +
                                                                log.log(attributeName 
+" set to "+attributeValue+" in "+name);
                                                                
server.setAttribute(objectName, new Attribute(attributeName, value));
  -                                                             
  +
                                                                break;
                                                        }
                                                }
                                        }
  -                                     
  +
                                }
                        }
                } catch (Throwable e)
  @@ -142,24 +143,24 @@
                        throw (Exception)e;
                }
        }
  -     
  +
      public String save()
                throws Exception
      {
                Writer out = new StringWriter();
  -             
  +
                // Create new ProjectX XML doc
                XmlDocument doc = new XmlDocument();
  -             
  +
                Element serverElement = doc.createElement("server");
  -             
  +
                Iterator mbeans = server.queryNames(null, null).iterator();
                while (mbeans.hasNext())
                {
                        ObjectName name = (ObjectName)mbeans.next();
                        Element mbeanElement = doc.createElement("mbean");
                        mbeanElement.setAttribute("name",name.toString());
  -                     
  +
                        MBeanInfo info = server.getMBeanInfo(name);
                        MBeanAttributeInfo[] attributes = info.getAttributes();
                        boolean hasAttributes = false;
  @@ -169,32 +170,32 @@
                                {
                                        Element attributeElement = 
doc.createElement("attribute");
                                        Object value = server.getAttribute(name, 
attributes[i].getName());
  -                                     
  +
                                        attributeElement.setAttribute("name", 
attributes[i].getName());
  -                                     
  +
                                        if (value != null)
                                                
attributeElement.appendChild(doc.createTextNode(value.toString()));
  -                                     
  +
                                        mbeanElement.appendChild(attributeElement);
  -                                     
  +
                                        hasAttributes = true;
                                }
                        }
  -                     
  +
                        if (hasAttributes)
                                serverElement.appendChild(mbeanElement);
                }
  -             
  +
                doc.appendChild(serverElement);
  -             
  +
                // Write configuration
                doc.writeXml(new XmlWriteContext(out,3));
                out.close();
  -             
  +
                // Return configuration
                return out.toString();
      }
  -     
  +
      // Protected -----------------------------------------------------
   }
   
  
  
  

Reply via email to