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 BaseModelMBean.java
Date Sun, 13 Apr 2003 16:51:47 GMT
costin      2003/04/13 09:51:47

  Modified:    modeler/src/java/org/apache/commons/modeler
                        BaseModelMBean.java
  Log:
  Add missing support for wrapped DynamicMBeans.
  While DynamicMBeans can be supported directly by the JMX server, sometimes
  it's better to wrap them in modeler ( persistence is one of the use cases )
  
  Revision  Changes    Path
  1.19      +21 -7     jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseModelMBean.java
  
  Index: BaseModelMBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseModelMBean.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- BaseModelMBean.java	8 Apr 2003 04:07:07 -0000	1.18
  +++ BaseModelMBean.java	13 Apr 2003 16:51:47 -0000	1.19
  @@ -85,6 +85,7 @@
   import javax.management.modelmbean.ModelMBeanNotificationInfo;
   import javax.management.modelmbean.ModelMBeanOperationInfo;
   import javax.management.*;
  +import javax.management.DynamicMBean;
   
   // TODO: enable ant-like substitutions ? ( or at least discuss it )
   
  @@ -271,6 +272,10 @@
                   (new IllegalArgumentException("Attribute name is null"),
                    "Attribute name is null");
   
  +        if( resource instanceof DynamicMBean ) {
  +            return ((DynamicMBean)resource).getAttribute(name);
  +        }
  +        
           // Extract the method from cache
           Method m=(Method)getAttMap.get( name );
   
  @@ -402,8 +407,12 @@
        *  occurs when invoking a method
        */
       public Object invoke(String name, Object params[], String signature[])
  -        throws MBeanException, ReflectionException {
  -
  +        throws MBeanException, ReflectionException 
  +    {
  +        if( resource instanceof DynamicMBean ) {
  +            return ((DynamicMBean)resource).invoke(name, params, signature);
  +        }
  +    
           // Validate the input parameters
           if (name == null)
               throw new RuntimeOperationsException
  @@ -542,11 +551,16 @@
        */
       public void setAttribute(Attribute attribute)
           throws AttributeNotFoundException, MBeanException,
  -        ReflectionException
  +        ReflectionException, InvalidAttributeValueException
       {
           if( log.isDebugEnabled() )
               log.debug("Setting attribute " + this + " " + attribute );
   
  +        if( resource instanceof DynamicMBean ) {
  +            ((DynamicMBean)resource).setAttribute(attribute);
  +            return;
  +        }
  +        
           // Validate the input parameters
           if (attribute == null)
               throw new RuntimeOperationsException
  
  
  

---------------------------------------------------------------------
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