[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2002-02-16 Thread Jason Dillon

  User: user57  
  Date: 02/02/16 02:35:22

  Modified:src/main/org/jboss/system ServiceConfigurator.java
  Log:
   o moved xml utilities to common under org.jboss.util.xml
  
  Revision  ChangesPath
  1.18  +24 -23jboss/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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ServiceConfigurator.java  5 Feb 2002 03:31:42 -   1.17
  +++ ServiceConfigurator.java  16 Feb 2002 10:35:22 -  1.18
  @@ -1,9 +1,10 @@
   /*
  -* JBoss, the OpenSource J2EE webOS
  -*
  -* Distributable under LGPL license.
  -* See terms of license at gnu.org.
  -*/
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
  +
   package org.jboss.system;
   
   import java.beans.PropertyEditor;
  @@ -28,7 +29,7 @@
   import javax.xml.parsers.DocumentBuilderFactory;
   import org.jboss.deployment.DeploymentException;
   import org.jboss.logging.Logger;
  -import org.jboss.util.DOMWriter;
  +import org.jboss.util.xml.DOMWriter;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   import org.w3c.dom.Node;
  @@ -36,23 +37,23 @@
   import org.w3c.dom.Text;
   
   /**
  -* Service configuration helper.
  -*
  -* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  -* @author a href=mailto:[EMAIL PROTECTED];Hiram Chirino/a
  -* @version $Revision: 1.17 $
  -*
  -* pb20010830 marc fleury:/b
  -* ul
  -*   liInitial import
  -* /ul
  -* pb20010831 hiram chirino:/b
  -* ul
  -*   liAdded suppport for org.w3c.dom.Element type mbean attributes.
  -*  The first child Element of the lt;attribute ...gt; is used
  -*  to set the value of the attribute.
  -* /ul
  -*/
  + * Service configuration helper.
  + *
  + * @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  + * @author a href=mailto:[EMAIL PROTECTED];Hiram Chirino/a
  + * @version $Revision: 1.18 $
  + *
  + * pb20010830 marc fleury:/b
  + * ul
  + *   liInitial import
  + * /ul
  + * pb20010831 hiram chirino:/b
  + * ul
  + *   liAdded suppport for org.w3c.dom.Element type mbean attributes.
  + *  The first child Element of the lt;attribute ...gt; is used
  + *  to set the value of the attribute.
  + * /ul
  + */
   public class ServiceConfigurator
   {
  /** Primitive type name - class map. */
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2002-02-04 Thread David Jencks

  User: d_jencks
  Date: 02/02/04 19:31:42

  Modified:src/main/org/jboss/system ServiceConfigurator.java
  Log:
  fix for tags named attribute, depends, and depends-list in Element-valued 
attributes. Fixes bug 505657. Testcase to follow
  
  Revision  ChangesPath
  1.17  +138 -135  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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ServiceConfigurator.java  2002/01/05 12:08:54 1.16
  +++ ServiceConfigurator.java  2002/02/05 03:31:42 1.17
  @@ -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.16 $
  +* @version $Revision: 1.17 $
   *
   * pb20010830 marc fleury:/b
   * ul
  @@ -191,155 +191,158 @@
// The MBean is no longer available
throw new DeploymentException(trying to configure nonexistent mbean:  + 
objectName);
 }
  +  // Set mbean references (object names)
  +  ArrayList mbeans = new ArrayList();
   
 // Set attributes
 MBeanAttributeInfo[] attributes = info.getAttributes();
  -  NodeList attrs = mbeanElement.getElementsByTagName(attribute);
  +  //NodeList attrs = mbeanElement.getElementsByTagName(attribute);
  +  NodeList attrs = mbeanElement.getChildNodes();
 for (int j = 0; j  attrs.getLength(); j++)
 {
  - Element attributeElement = (Element)attrs.item(j);
  - String attributeName = attributeElement.getAttribute(name);
  - attrfound:
  - if (attributeElement.hasChildNodes())
  - {
  -// Get the attribute value
  -Node n = attributeElement.getFirstChild();
  -String attributeText = null;
  -if( n instanceof Text )
  -{
  -   attributeText = ((Text)n).getData().trim();
  -}
  +  if (attrs.item(j).getNodeType() == Node.ELEMENT_NODE)
  +  {
   
  -for (int k = 0; k  attributes.length; k++)
  -{
  -   if (attributeName.equals(attributes[k].getName()))
  -   {
  -  String typeName = attributes[k].getType();
  -  Class typeClass;
  -  if (primitives.containsKey(typeName))
  -  {
  - typeClass = (Class)primitives.get(typeName);
  -  }
  -  else
  -  {
  - typeClass = Class.forName(typeName);
  -  }
  -
  -  Object value = null;
  -
  -  // HRC: Is the attribute type a org.w3c.dom.Element??
  -  if (typeClass.equals(Element.class))
  -  {
  - // Then we can pass the first child Element of this
  - // attributeElement
  - NodeList nl = attributeElement.getChildNodes();
  - for (int i=0; i  nl.getLength(); i++)
  - {
  -n = nl.item(i);
  -if (n.getNodeType() == Node.ELEMENT_NODE)
  -{
  -   value = (Element) n;
  -   break;
  -}
  - }
  -  }
  + Element element = (Element)attrs.item(j);
  + if (element.getTagName().equals(attribute))
  + {
  +String attributeName = element.getAttribute(name);
  + attrfound:
  +if (element.hasChildNodes())
  +{
  +   // Get the attribute value
  +   Node n = element.getFirstChild();
  +   String attributeText = null;
  +   if( n instanceof Text )
  +   {
  +  attributeText = ((Text)n).getData().trim();
  +   }
  +
  +   for (int k = 0; k  attributes.length; k++)
  +   {
  +  if (attributeName.equals(attributes[k].getName()))
  +  {
  + String typeName = attributes[k].getType();
  + Class typeClass;
  + if (primitives.containsKey(typeName))
  + {
  +typeClass = (Class)primitives.get(typeName);
  + }
  + else
  + {
  +typeClass = Class.forName(typeName);
  + }
  +
  + Object value = null;
  +
  + // HRC: Is the attribute type a org.w3c.dom.Element??
  + if (typeClass.equals(Element.class))
  + {
  +   

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java ServiceController.java ServiceCreator.java

2002-01-05 Thread Adrian Brock

  User: ejort   
  Date: 02/01/05 04:08:54

  Modified:src/main/org/jboss/system ServiceConfigurator.java
ServiceController.java ServiceCreator.java
  Log:
  Guarded debug logging
  
  Revision  ChangesPath
  1.16  +30 -22jboss/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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ServiceConfigurator.java  2001/12/20 06:12:09 1.15
  +++ ServiceConfigurator.java  2002/01/05 12:08:54 1.16
  @@ -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.15 $
  +* @version $Revision: 1.16 $
   *
   * pb20010830 marc fleury:/b
   * ul
  @@ -92,14 +92,16 @@
  public String getConfiguration(ObjectName[] objectNames)
  throws Exception
  {
  +  boolean debug = log.isDebugEnabled();
  +
 Writer out = new StringWriter();
  -  
  +
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 DocumentBuilder builder = factory.newDocumentBuilder();
 Document doc = builder.newDocument();
  -  
  +
 Element serverElement = doc.createElement(server);
  -  
  +
 // Store attributes as XML
 for (int j = 0 ; jobjectNames.length ; j++)
 {
  @@ -107,7 +109,7 @@
ObjectName name = (ObjectName)instance.getObjectName();
Element mbeanElement = doc.createElement(mbean);
mbeanElement.setAttribute(name, name.toString());
  - 
  +
MBeanInfo info = server.getMBeanInfo(name);
mbeanElement.setAttribute(code, info.getClassName());
MBeanAttributeInfo[] attributes = info.getAttributes();
  @@ -118,13 +120,14 @@
   {
  if (!attributes[i].isWritable())
  {
  -  log.debug(Detected JMX Bug: Server reports attribute 
'+attributes[i].getName() + ' is not writeable for MBean ' + 
name.getCanonicalName() + ');
  +  if (debug)
  + log.debug(Detected JMX Bug: Server reports attribute 
'+attributes[i].getName() + ' is not writeable for MBean ' + 
name.getCanonicalName() + ');
  }
  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()));
  @@ -147,14 +150,14 @@
 (new DOMWriter(out, false)).print(doc, true);
 
 out.close();
  -  
  +
 // Return configuration
 return out.toString();
  }
  -   
  -   
  +
  +
  // Public -
  -   
  +
  /**
  * The codeconfigure/code method configures an mbean based on the xml element 
configuration
  * passed in.  Three formats are supported:
  @@ -171,12 +174,14 @@
  public ArrayList configure(Element mbeanElement)
  throws Exception
  {
  -  
  +
 // Set configuration to MBeans from XML
  -  
  +
  +  boolean debug = log.isDebugEnabled();
  +
 // get the name of the mbean
 ObjectName objectName = parseObjectName(mbeanElement);
  -  
  +
 MBeanInfo info;
 try
 {
  @@ -186,7 +191,7 @@
// The MBean is no longer available
throw new DeploymentException(trying to configure nonexistent mbean:  + 
objectName);
 }
  -  
  +
 // Set attributes
 MBeanAttributeInfo[] attributes = info.getAttributes();
 NodeList attrs = mbeanElement.getElementsByTagName(attribute);
  @@ -204,7 +209,7 @@
   {
  attributeText = ((Text)n).getData().trim();
   }
  -
  +
   for (int k = 0; k  attributes.length; k++)
   {
  if (attributeName.equals(attributes[k].getName()))
  @@ -219,9 +224,9 @@
 {
typeClass = Class.forName(typeName);
 }
  -  
  +
 Object value = null;
  -  
  +
 // HRC: Is the attribute type a org.w3c.dom.Element??
 if (typeClass.equals(Element.class))
 {
  @@ -246,7 +251,8 @@
value = editor.getValue();
 }
 
  -  log.debug(attributeName +  set to  + value +  in  + 

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java ServiceController.java

2001-12-19 Thread David Jencks

  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  ChangesPath
  1.15  +46 -59jboss/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 $
   *
   * pb20010830 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);
  - 

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2001-12-18 Thread marc fleury

  User: mnf999  
  Date: 01/12/18 22:24:41

  Modified:src/main/org/jboss/system ServiceConfigurator.java
  Log:
  parse the dependencies used by the deployer
  
  Revision  ChangesPath
  1.14  +203 -211  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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ServiceConfigurator.java  2001/12/04 18:13:23 1.13
  +++ ServiceConfigurator.java  2001/12/19 06:24:41 1.14
  @@ -1,9 +1,9 @@
   /*
  - * JBoss, the OpenSource J2EE webOS
  - *
  - * Distributable under LGPL license.
  - * See terms of license at gnu.org.
  - */
  +* JBoss, the OpenSource J2EE webOS
  +*
  +* Distributable under LGPL license.
  +* See terms of license at gnu.org.
  +*/
   package org.jboss.system;
   
   import java.beans.PropertyEditor;
  @@ -12,6 +12,8 @@
   import java.io.Writer;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
  +import java.util.StringTokenizer;
  +import java.util.LinkedList;
   import java.util.ArrayList;
   import java.util.Hashtable;
   import javax.management.Attribute;
  @@ -34,23 +36,23 @@
   import org.w3c.dom.Text;
   
   /**
  - * Service configuration helper.
  - *
  - * @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  - * @author a href=mailto:[EMAIL PROTECTED];Hiram Chirino/a
  - * @version $Revision: 1.13 $
  - *
  - * pb20010830 marc fleury:/b
  - * ul
  - *   liInitial import
  - * /ul
  - * pb20010831 hiram chirino:/b
  - * ul
  - *   liAdded suppport for org.w3c.dom.Element type mbean attributes.
  - *  The first child Element of the lt;attribute ...gt; is used
  - *  to set the value of the attribute.
  - * /ul
  - */
  +* Service configuration helper.
  +*
  +* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  +* @author a href=mailto:[EMAIL PROTECTED];Hiram Chirino/a
  +* @version $Revision: 1.14 $
  +*
  +* pb20010830 marc fleury:/b
  +* ul
  +*   liInitial import
  +* /ul
  +* pb20010831 hiram chirino:/b
  +* ul
  +*   liAdded suppport for org.w3c.dom.Element type mbean attributes.
  +*  The first child Element of the lt;attribute ...gt; is used
  +*  to set the value of the attribute.
  +* /ul
  +*/
   public class ServiceConfigurator
   {
  /** Primitive type name - class map. */
  @@ -82,11 +84,11 @@
  // Public  ---
  
  /**
  -* Builds a string that consists of the configuration elements of
  -* the currently running MBeans registered in the server.
  -*
  -* @throws ExceptionFailed to construct configuration.
  -*/
  +   * Builds a string that consists of the configuration elements of
  +   * the currently running MBeans registered in the server.
  +   *
  +   * @throws ExceptionFailed to construct configuration.
  +   */
  public String getConfiguration(ObjectName[] objectNames)
  throws Exception
  {
  @@ -154,18 +156,18 @@
  // Public -
  
  /**
  -* The codeconfigure/code method configures an mbean based on the xml 
element configuration
  -* passed in.  Three formats are supported:
  -* lt;attribute name=(name)gt;(value)lt;/attributegt;
  -* lt;mbean-ref name=(name)gt;(object name of mbean 
referenced)lt;/mbean-refgt;
  -* lt;mbean-ref-list name=(name)gt;
  -* [list of]  lt;/mbean-ref-list-elementgt;(object 
name)lt;/mbean-ref-list-elementgt;
  -* lt;/mbean-ref-listgt;
  -*
  -* @param mbeanElement an codeElement/code value
  -* @return a codeArrayList/code of all the mbeans this one references.
  -* @exception Exception if an error occurs
  -*/
  +   * The codeconfigure/code method configures an mbean based on the xml element 
configuration
  +   * passed in.  Three formats are supported:
  +   * lt;attribute name=(name)gt;(value)lt;/attributegt;
  +   * lt;depends optional-attribute-name=(name)gt;(object name of mbean 
referenced)lt;/dependsgt;
  +   * lt;depends-list optional-attribute-name=(name)gt;
  +   * [list of]  lt;/depends-list-elementgt;(object 
name)lt;/depends-list-elementgt;
  +   * lt;/depends-listgt;
  +   *
  +   * @param mbeanElement an codeElement/code value
  +   * @return a codeArrayList/code of all the mbeans this one references.
  +   * @exception Exception if an error occurs
  +   */
  public ArrayList configure(Element mbeanElement)
  throws Exception
  {
  @@ -182,7 +184,6 @@
 } catch (InstanceNotFoundException e)
 {
// The MBean is no longer available
  - // It's ok, just return It is ? Why??  Oh yeah?
throw new DeploymentException(trying to configure nonexistent mbean:  + 
objectName);
 }
 
  @@ -194,181 

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2001-12-04 Thread Scott M Stark

  User: starksm 
  Date: 01/12/04 10:13:24

  Modified:src/main/org/jboss/system ServiceConfigurator.java
  Log:
  The first child node of an attribute element does not have to be a Text
  node so validate the type before casting.
  
  Revision  ChangesPath
  1.13  +13 -11jboss/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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ServiceConfigurator.java  2001/12/03 17:43:33 1.12
  +++ ServiceConfigurator.java  2001/12/04 18:13:23 1.13
  @@ -6,10 +6,6 @@
*/
   package org.jboss.system;
   
  -
  -
  -
  -
   import java.beans.PropertyEditor;
   import java.beans.PropertyEditorManager;
   import java.io.StringWriter;
  @@ -33,6 +29,7 @@
   import org.jboss.util.DOMWriter;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  +import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
   import org.w3c.dom.Text;
   
  @@ -41,7 +38,7 @@
*
* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
* @author a href=mailto:[EMAIL PROTECTED];Hiram Chirino/a
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
*
* pb20010830 marc fleury:/b
* ul
  @@ -200,7 +197,12 @@
   if (attributeElement.hasChildNodes())
   {
  // Get the attribute value
  -   String attributeValue = 
((Text)attributeElement.getFirstChild()).getData().trim();
  +   Node n = attributeElement.getFirstChild();
  +   String attributeText = null;
  +   if( n instanceof Text )
  +   {
  +  attributeText = ((Text)n).getData().trim();
  +   }
  
  for (int k = 0; k  attributes.length; k++)
  {
  @@ -227,10 +229,10 @@
   NodeList nl = attributeElement.getChildNodes();
   for (int i=0; i  nl.getLength(); i++)
   {
  -   org.w3c.dom.Node n = nl.item(i);
  -   if (n.getNodeType() == n.ELEMENT_NODE)
  +   n = nl.item(i);
  +   if (n.getNodeType() == Node.ELEMENT_NODE)
  {
  -  value = (Element)n;
  +  value = (Element) n;
 break;
  }
   }
  @@ -239,11 +241,11 @@
if (value == null)
{
   PropertyEditor editor = 
PropertyEditorManager.findEditor(typeClass);
  -editor.setAsText(attributeValue);
  +editor.setAsText(attributeText);
   value = editor.getValue();
}

  - log.debug(attributeName +  set to  + attributeValue +  in  
+ objectName);
  + log.debug(attributeName +  set to  + value +  in  + 
objectName);
server.setAttribute(objectName, new Attribute(attributeName, 
value));

break attrfound;
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2001-12-03 Thread Scott M Stark

  User: starksm 
  Date: 01/12/03 09:43:34

  Modified:src/main/org/jboss/system ServiceConfigurator.java
  Log:
  Fix the formatting.
  
  Revision  ChangesPath
  1.12  +218 -184  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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ServiceConfigurator.java  2001/11/26 03:19:46 1.11
  +++ ServiceConfigurator.java  2001/12/03 17:43:33 1.12
  @@ -13,7 +13,7 @@
   import java.beans.PropertyEditor;
   import java.beans.PropertyEditorManager;
   import java.io.StringWriter;
  -import java.io.Writer;   
  +import java.io.Writer;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.util.ArrayList;
  @@ -38,10 +38,10 @@
   
   /**
* Service configuration helper.
  - * 
  + *
* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
* @author a href=mailto:[EMAIL PROTECTED];Hiram Chirino/a
  - * @version $Revision: 1.11 $
  + * @version $Revision: 1.12 $
*
* pb20010830 marc fleury:/b
* ul
  @@ -50,7 +50,7 @@
* pb20010831 hiram chirino:/b
* ul
*   liAdded suppport for org.w3c.dom.Element type mbean attributes.
  - *  The first child Element of the lt;attribute ...gt; is used 
  + *  The first child Element of the lt;attribute ...gt; is used
*  to set the value of the attribute.
* /ul
*/
  @@ -58,281 +58,305 @@
   {
  /** Primitive type name - class map. */
  private static Hashtable primitives = new Hashtable();
  - 
  +   
  /** Setup the primitives map. */
  -   static {
  +   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);
  }
  - 
  +   
  /** The MBean server which this service is registered in. */
  private MBeanServer server;
  -
  +   
  /** The instance logger. */
  private static Logger log = Logger.getLogger(ServiceConfigurator.class);
  - 
  +   
  // Constructors --
  - 
  -   public ServiceConfigurator(final MBeanServer server) 
  +   
  +   public ServiceConfigurator(final MBeanServer server)
  {
 this.server = server;
  }
  
  // Public  ---
  - 
  +   
  /**
   * Builds a string that consists of the configuration elements of
   * the currently running MBeans registered in the server.
   *
   * @throws ExceptionFailed to construct configuration.
   */
  -   public String getConfiguration(ObjectName[] objectNames) 
  -  throws Exception 
  +   public String getConfiguration(ObjectName[] objectNames)
  +   throws Exception
  {
 Writer out = new StringWriter();
  - 
  +  
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 DocumentBuilder builder = factory.newDocumentBuilder();
 Document doc = builder.newDocument();
  - 
  +  
 Element serverElement = doc.createElement(server);
  - 
  +  
 // Store attributes as XML
  -  for (int j = 0 ; jobjectNames.length ; j++) 
  +  for (int j = 0 ; jobjectNames.length ; j++)
 {
ObjectInstance instance = server.getObjectInstance(objectNames[j]);
ObjectName name = (ObjectName)instance.getObjectName();
Element mbeanElement = doc.createElement(mbean);
mbeanElement.setAttribute(name, name.toString());
  - 
  + 
MBeanInfo info = server.getMBeanInfo(name);
mbeanElement.setAttribute(code, info.getClassName());
MBeanAttributeInfo[] attributes = info.getAttributes();
boolean hasAttributes = true;
  - for (int i = 0; i  attributes.length; i++) {
  -if (attributes[i].isReadable()  
isAttributeWriteable(server.getObjectInstance(name).getClassName(), 
attributes[i].getName(), attributes[i].getType())) {
  -   if (!attributes[i].isWritable()) {
  + for (int i = 0; i  attributes.length; i++)
  + {
  +if (attributes[i].isReadable()  
isAttributeWriteable(server.getObjectInstance(name).getClassName(), 
attributes[i].getName(), attributes[i].getType()))
  +{
  +   if (!attributes[i].isWritable())
  +   {
 log.debug(Detected JMX Bug: Server reports attribute 
'+attributes[i].getName() + ' is not writeable for MBean ' + 
name.getCanonicalName() + ');
  }
  Element attributeElement = 

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2001-11-21 Thread Jason Dillon

  User: user57  
  Date: 01/11/21 15:31:39

  Modified:src/main/org/jboss/system ServiceConfigurator.java
  Log:
   o using class to create Logger instance
  
  Revision  ChangesPath
  1.9   +2 -2  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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ServiceConfigurator.java  2001/11/19 06:58:57 1.8
  +++ ServiceConfigurator.java  2001/11/21 23:31:39 1.9
  @@ -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.8 $
  + * @version $Revision: 1.9 $
*
* pb20010830 marc fleury:/b
* ul
  @@ -73,7 +73,7 @@
  private MBeanServer server;
   
  /** The instance logger. */
  -   private static Logger log = Logger.create(Configurator);
  +   private static Logger log = Logger.create(ServiceConfigurator.class);

  // Constructors --

  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java ServiceController.java ServiceCreator.java

2001-11-18 Thread David Jencks

  User: d_jencks
  Date: 01/11/18 22:58:57

  Modified:src/main/org/jboss/system ServiceConfigurator.java
ServiceController.java ServiceCreator.java
  Log:
  Cleaned up deployment a bit and enabled jar in sar
  
  Revision  ChangesPath
  1.8   +8 -10 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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ServiceConfigurator.java  2001/11/15 06:30:22 1.7
  +++ ServiceConfigurator.java  2001/11/19 06:58:57 1.8
  @@ -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.7 $
  + * @version $Revision: 1.8 $
*
* pb20010830 marc fleury:/b
* ul
  @@ -180,21 +180,20 @@
// The MBean is no longer available
// It's ok, just return It is ? Why??  Oh yeah?
throw new DeploymentException(trying to configure nonexistent mbean:  + 
objectName);
  - //log.debug(object name  + objectName +  is no longer available);
  - //return true;
 }

 // Set attributes
  +  MBeanAttributeInfo[] attributes = info.getAttributes();
 NodeList attrs = mbeanElement.getElementsByTagName(attribute);
 for (int j = 0; j  attrs.getLength(); j++) {
Element attributeElement = (Element)attrs.item(j);
String attributeName = attributeElement.getAttribute(name);
  +  attrfound:
if (attributeElement.hasChildNodes()) {

   // Get the attribute value
   String attributeValue = 
((Text)attributeElement.getFirstChild()).getData().trim();

  -MBeanAttributeInfo[] attributes = info.getAttributes();
   for (int k = 0; k  attributes.length; k++) {
  if (attributeName.equals(attributes[k].getName())) {
 String typeName = attributes[k].getType();
  @@ -230,10 +229,11 @@
 log.debug(attributeName +  set to  + attributeValue +  in  + 
objectName);
 server.setAttribute(objectName, new Attribute(attributeName, 
value));

  -  break;
  -   }
  -}
  - }
  +  break attrfound;
  +   }//if name matches
  +}//for attr names
  +throw new DeploymentException(No Attribute found with name:  +  
attributeName);
  + }//if has children
 }
 // Set mbean references (object names)
 ArrayList mBeanRefs = new ArrayList();
  @@ -262,7 +262,6 @@
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();
  @@ -320,7 +319,6 @@
} // 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);
  
  
  
  1.13  +3 -2  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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ServiceController.java2001/11/12 06:52:17 1.12
  +++ ServiceController.java2001/11/19 06:58:57 1.13
  @@ -42,7 +42,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.12 $ p
  + * @version $Revision: 1.13 $ p
*
* bRevisions:/b p
*
  @@ -247,9 +247,10 @@

} // end of if (mBeanRefs.size()  0)
 }
  -  catch (ConfigurationException e)
  +  catch (Exception e)
 {
log.error(Could not configure MBean:  + objectName, e);
  + server.unregisterMBean(objectName);
throw e;
 }
 String serviceFactory = mbeanElement.getAttribute(serviceFactory);
  
  
  
  1.3   +7 -3  jboss/src/main/org/jboss/system/ServiceCreator.java
  
  

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2001-11-14 Thread David Jencks

  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  ChangesPath
  1.7   +82 -64jboss/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 $
*
* pb20010830 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
 

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2001-11-13 Thread David Jencks

  User: d_jencks
  Date: 01/11/12 23:55:00

  Modified:src/main/org/jboss/system ServiceConfigurator.java
  Log:
  Fixed dumb bug in mbean-ref-list handling
  
  Revision  ChangesPath
  1.6   +21 -17jboss/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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServiceConfigurator.java  2001/11/10 21:38:06 1.5
  +++ ServiceConfigurator.java  2001/11/13 07:55:00 1.6
  @@ -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.5 $
  + * @version $Revision: 1.6 $
*
* pb20010830 marc fleury:/b
* ul
  @@ -274,37 +274,41 @@
 }
 // Set lists of mbean references (object names)
   
  -  NodeList mbeanRefLists = mbeanElement.getElementsByTagName(mbean-ref-list);
  -  for (int j = 0; j  mbeanRefLists.getLength(); j++) {
  - Element mbeanRefListElement = (Element)mbeanRefLists.item(j);
  - String mbeanRefListName = mbeanRefListElement.getAttribute(name);
  +  NodeList mBeanRefLists = mbeanElement.getElementsByTagName(mbean-ref-list);
  +  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())) {
  +if (mBeanRefListName.equals(attributes[k].getName())) {
   
  -   NodeList mbeanRefList = 
mbeanRefListElement.getElementsByTagName(mbean-ref-list-element);
  -   ArrayList mbeanRefs = new ArrayList();
  -   for (int l = 0; l  mbeanRefList.getLength(); l++) 
  +   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()) 
  +  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 (!mBeanRefs.contains(mbeanRefObjectName)) 
  +  String mBeanRefValue = 
((Text)mBeanRefElement.getFirstChild()).getData().trim();
  +  ObjectName mBeanRefObjectName = new ObjectName(mBeanRefValue);
  +  if (!mBeanRefListNames.contains(mBeanRefObjectName)) 
 {
  - mBeanRefs.add(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  + mbeanRefs +  in  + 
objectName);
  -   server.setAttribute(objectName, new Attribute(mbeanRefListName, 
mbeanRefs));
  +   log.debug(mBeanRefListName +  set to  + mBeanRefListNames +  in  
+ objectName);
  +   server.setAttribute(objectName, new Attribute(mBeanRefListName, 
mBeanRefListNames));
   
  break;
   }
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java ServiceController.java ServiceControllerMBean.java URLClassLoader.java

2001-11-10 Thread David Jencks

  User: d_jencks
  Date: 01/11/10 13:38:07

  Modified:src/main/org/jboss/system ServiceConfigurator.java
ServiceController.java ServiceControllerMBean.java
URLClassLoader.java
  Log:
  Changed mbean dependencies to work directly by mbean-references: eliminated depends 
tag from *service.xml files
  
  Revision  ChangesPath
  1.5   +114 -20   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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServiceConfigurator.java  2001/09/11 18:35:03 1.4
  +++ ServiceConfigurator.java  2001/11/10 21:38:06 1.5
  @@ -6,41 +6,43 @@
*/
   package org.jboss.system;
   
  -import java.io.Writer;   
  -import java.io.StringWriter;
  -import java.util.Hashtable;
  +
  +
  +
  +
   import java.beans.PropertyEditor;
   import java.beans.PropertyEditorManager;
  +import java.io.StringWriter;
  +import java.io.Writer;   
   import java.lang.reflect.Method;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
  -
  -import javax.management.MBeanInfo;
  +import java.util.ArrayList;
  +import java.util.Hashtable;
   import javax.management.Attribute;
  -import javax.management.ObjectName;
  -import javax.management.MBeanServer;
  -import javax.management.ObjectInstance;
  -import javax.management.MBeanAttributeInfo;
   import javax.management.InstanceNotFoundException;
  +import javax.management.MBeanAttributeInfo;
  +import javax.management.MBeanInfo;
  +import javax.management.MBeanServer;
   import javax.management.MalformedObjectNameException;
  -
  +import javax.management.ObjectInstance;
  +import javax.management.ObjectName;
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
  -
  -import org.w3c.dom.Text;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.Document;
  -
  +import org.jboss.deployment.DeploymentException;
   import org.jboss.logging.Logger;
   import org.jboss.util.DOMWriter;
  +import org.w3c.dom.Document;
  +import org.w3c.dom.Element;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.Text;
   
   /**
* Service configuration helper.
* 
* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
* @author a href=mailto:[EMAIL PROTECTED];Hiram Chirino/a
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
*
* pb20010830 marc fleury:/b
* ul
  @@ -149,7 +151,20 @@

  // Public -

  -   public void configure(Element mbeanElement) 
  +/**
  + * The codeconfigure/code method configures an mbean based on the xml 
element configuration
  + * passed in.  Three formats are supported:
  + * lt;attribute name=(name)gt;(value)lt;/attributegt;
  + * lt;mbean-ref name=(name)gt;(object name of mbean 
referenced)lt;/mbean-refgt;
  + * lt;mbean-ref-list name=(name)gt;
  + * [list of]  lt;/mbean-ref-list-elementgt;(object 
name)lt;/mbean-ref-list-elementgt;
  + * lt;/mbean-ref-listgt;
  + *
  + * @param mbeanElement an codeElement/code value
  + * @return a codeArrayList/code of all the mbeans this one references.
  + * @exception Exception if an error occurs
  + */
  +public ArrayList configure(Element mbeanElement) 
 throws Exception 
  {

  @@ -163,8 +178,10 @@
info = server.getMBeanInfo(objectName);
 } catch (InstanceNotFoundException e) {
// The MBean is no longer available
  - // It's ok, just return
  - return;
  + // It's ok, just return It is ? Why??  Oh yeah?
  + throw new DeploymentException(trying to configure nonexistent mbean:  + 
objectName);
  + //log.debug(object name  + objectName +  is no longer available);
  + //return true;
 }

 // Set attributes
  @@ -218,6 +235,83 @@
   }
}
 }
  +  // 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()) 
  + {
  +throw new DeploymentException(No ObjectName supplied for mbean-ref  + 
mbeanRefName);   
  +
  + }   
  + // Get the mbeanRef value
  + String mbeanRefValue = 

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceConfigurator.java

2001-08-31 Thread Hiram Chirino

  User: chirino 
  Date: 01/08/31 20:51:05

  Modified:src/main/org/jboss/system ServiceConfigurator.java
  Log:
  Added suppport for org.w3c.dom.Element type mbean attributes.
  The first child Element of the attribute ... is used
  to set the value of the attribute.
  
  Revision  ChangesPath
  1.2   +31 -8 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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceConfigurator.java  2001/08/29 23:08:21 1.1
  +++ ServiceConfigurator.java  2001/09/01 03:51:05 1.2
  @@ -42,13 +42,20 @@
   *
   *
   * @author  a href=mailto:[EMAIL PROTECTED];Marc Fleury/a`
  -* @version $Revision: 1.1 $
  +* @author  a href=mailto:[EMAIL PROTECTED];Hiram Chirino/a`
  +* @version $Revision: 1.2 $
   *
   *   pb20010830 marc fleury:/b
   *   ul
   *  initial import
   *   li 
   *   /ul
  +*   pb20010831 hiram chirino:/b
  +*   ul
  +*   li Added suppport for org.w3c.dom.Element type mbean attributes.
  +*The first child Element of the lt;attribute ...gt; is used 
  +*to set the value of the attribute.
  +*   /ul
   */
   
   public class ServiceConfigurator
  @@ -183,11 +190,30 @@
typeClass = 
(Class)primitives.get(typeName);
} else {
typeClass = 
Class.forName(typeName);
  + }
  + 
  + Object value = null;
  + 
  + // HRC: Is the attribute type a 
org.w3c.dom.Element??
  + if( typeClass.equals(Element.class) ) 
{ 
  + // Then we can pass the first 
child Element of this 
  + // attributeElement
  + NodeList nl = 
attributeElement.getChildNodes();
  + for(int i=0; i  
nl.getLength(); i++) {
  + org.w3c.dom.Node n = 
nl.item(i);
  + if( n.getNodeType() == 
n.ELEMENT_NODE ) {
  + value = 
(Element)n;
  + break;
  + }
  + }
}
  - PropertyEditor editor = 
PropertyEditorManager.findEditor(typeClass);
  - editor.setAsText(attributeValue);
  - Object value = editor.getValue();

  + if( value == null ) {
  + PropertyEditor editor = 
PropertyEditorManager.findEditor(typeClass);
  + 
editor.setAsText(attributeValue);
  + value = editor.getValue();
  + }
  + 
log.debug(attributeName +  set to  + 
attributeValue +  in  + objectName);
server.setAttribute(objectName, new 
Attribute(attributeName, value));

  @@ -290,7 +316,4 @@

return false;
}
  -}
  -
  -
  -
  +}
  \ No newline at end of file
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development