commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-commons/modeler/src/java/org/apache/commons/modeler/modules MbeansSource.java
Date Sun, 13 Apr 2003 17:11:56 GMT
costin      2003/04/13 10:11:56

  Modified:    modeler/src/java/org/apache/commons/modeler/modules
                        MbeansSource.java
  Log:
  Saving on attribute change and timeout doesn't work.
  
  Added explicit save method. We could add a thread that periodically saves if
  changed, but that's low priority.
  
  Revision  Changes    Path
  1.11      +23 -27    jakarta-commons/modeler/src/java/org/apache/commons/modeler/modules/MbeansSource.java
  
  Index: MbeansSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/modules/MbeansSource.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MbeansSource.java	9 Apr 2003 07:25:18 -0000	1.10
  +++ MbeansSource.java	13 Apr 2003 17:11:56 -0000	1.11
  @@ -2,7 +2,6 @@
   
   import org.w3c.dom.Document;
   import org.w3c.dom.Node;
  -import org.w3c.dom.NamedNodeMap;
   import org.apache.commons.modeler.util.DomUtil;
   import org.apache.commons.modeler.*;
   import org.apache.commons.logging.Log;
  @@ -50,7 +49,7 @@
   
       public void setRegistry(Registry reg) {
           this.registry=reg;
  -    }
  +    }          
   
       public void setLocation( String loc ) {
           this.location=loc;
  @@ -231,29 +230,30 @@
               log.info( "Node not found " + oname );
               return;
           }
  -        // n is an <mbean> node
  -        Node firstAttN=DomUtil.getChild(n, "attribute");
  -        boolean found=false;
  -        for (Node descN = firstAttN; descN != null;
  -             descN = DomUtil.getNext( descN ))
  -        {
  -            String thisAttName=DomUtil.getAttribute(descN, "name");
  -            if( name.equals( thisAttName )) {
  -                // XXX value = null, remove existing, conversions
  -                found=true;
  -                DomUtil.setAttribute(descN, "value", value.toString());
  -                break;
  -            }
  -        }
  -        if( ! found ) {
  -            Node attN=n.getOwnerDocument().createElement("attribute");
  -            DomUtil.setAttribute(attN, "name", name);
  -            DomUtil.setAttribute(attN, "value", value.toString());
  -            n.appendChild(attN);
  +        Node attNode=DomUtil.findChildWithAtt(n, "attribute", "name", name);
  +        if( attNode == null ) {
  +            // found no existing attribute with this name
  +            attNode=n.getOwnerDocument().createElement("attribute");
  +            DomUtil.setAttribute(attNode, "name", name);
  +            n.appendChild(attNode);
  +        } 
  +        String oldValue=DomUtil.getAttribute(attNode, "value");
  +        if( oldValue != null ) {
  +            // we'll convert all values to text content
  +            DomUtil.removeAttribute( attNode, "value");
           }
  +        DomUtil.setText(attNode, value.toString());
   
  -
  -        // XXX no often than, etc.
  +        //store();
  +    }
  +    
  +    /** Store the mbeans. 
  +     * XXX add a background thread to store it periodically 
  +     */ 
  +    public void store() {
  +        // XXX customize no often than ( based on standard descriptor ), etc.
  +        // It doesn't work very well if we call this on each set att - 
  +        // the triger will work for the first att, but all others will be delayed
           long time=System.currentTimeMillis();
           if( location!=null &&
                   time - lastUpdate > updateInterval ) {
  @@ -267,10 +267,6 @@
                   log.error( "Error writing" ,e );
               }
           }
  -    }
  -    
  -    public void store() {
  -        
       }
   
       private void processAttribute(MBeanServer server,
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message