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 Sat, 11 Jan 2003 07:28:07 GMT
costin      2003/01/10 23:28:07

  Modified:    modeler/src/java/org/apache/commons/modeler
                        BaseModelMBean.java
  Log:
  Added support for MbeanRegistration.
  
  Added a getClassName() method.
  
  Sorry about imports - I found no way to tell idea to not colapse
  them ( there are about 16 javax.management.XXX )
  
  Revision  Changes    Path
  1.11      +48 -23    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- BaseModelMBean.java	6 Jan 2003 05:53:00 -0000	1.10
  +++ BaseModelMBean.java	11 Jan 2003 07:28:07 -0000	1.11
  @@ -72,23 +72,7 @@
   import java.lang.reflect.Method;
   import java.util.Iterator;
   import java.util.Hashtable;
  -import javax.management.Attribute;
  -import javax.management.AttributeChangeNotification;
  -import javax.management.AttributeList;
  -import javax.management.AttributeNotFoundException;
  -import javax.management.Descriptor;
  -import javax.management.ListenerNotFoundException;
  -import javax.management.MBeanException;
  -import javax.management.MBeanInfo;
  -import javax.management.MBeanNotificationInfo;
  -import javax.management.Notification;
  -import javax.management.NotificationFilter;
  -import javax.management.NotificationListener;
  -import javax.management.InstanceNotFoundException;
  -import javax.management.ReflectionException;
  -import javax.management.RuntimeErrorException;
  -import javax.management.RuntimeOperationsException;
  -import javax.management.ServiceNotFoundException;
  +
   import javax.management.modelmbean.DescriptorSupport;
   import javax.management.modelmbean.InvalidTargetObjectTypeException;
   import javax.management.modelmbean.ModelMBean;
  @@ -97,6 +81,7 @@
   import javax.management.modelmbean.ModelMBeanInfoSupport;
   import javax.management.modelmbean.ModelMBeanNotificationInfo;
   import javax.management.modelmbean.ModelMBeanOperationInfo;
  +import javax.management.*;
   
   // TODO: enable ant-like substitutions ? ( or at least discuss it )
   
  @@ -133,7 +118,7 @@
    * @version $Revision$ $Date$
    */
   
  -public class BaseModelMBean implements ModelMBean {
  +public class BaseModelMBean implements ModelMBean, MBeanRegistration {
       private static Log log = LogFactory.getLog(BaseModelMBean.class);
   
       // ----------------------------------------------------------- Constructors
  @@ -244,7 +229,7 @@
        */
       public Object getAttribute(String name)
           throws AttributeNotFoundException, MBeanException,
  -        ReflectionException {
  +            ReflectionException {
           // Validate the input parameters
           if (name == null)
               throw new RuntimeOperationsException
  @@ -1201,6 +1186,13 @@
           }
       }
   
  +    public String getClassName() {
  +        if( resource==null ) {
  +            return null;
  +        }
  +        return resource.getClass().getName();
  +    }
  +
       // ------------------------------------------------------ Protected Methods
   
   
  @@ -1228,4 +1220,37 @@
           return (true);
       }
   
  +    // -------------------- Registration  --------------------
  +    // XXX We can add some method patterns here - like setName() and
  +    // setDomain() for code that doesn't implement the Registration
  +
  +    public ObjectName preRegister(MBeanServer server,
  +                                  ObjectName name)
  +            throws Exception
  +    {
  +        if( log.isDebugEnabled())
  +            log.debug("preRegister " + resource + " " + name );
  +        if( resource instanceof MBeanRegistration ) {
  +            return ((MBeanRegistration)resource).preRegister(server, name );
  +        }
  +        return name;
  +    }
  +
  +    public void postRegister(Boolean registrationDone) {
  +        if( resource instanceof MBeanRegistration ) {
  +            ((MBeanRegistration)resource).postRegister(registrationDone);
  +        }
  +    }
  +
  +    public void preDeregister() throws Exception {
  +        if( resource instanceof MBeanRegistration ) {
  +            ((MBeanRegistration)resource).preDeregister();
  +        }
  +    }
  +
  +    public void postDeregister() {
  +        if( resource instanceof MBeanRegistration ) {
  +            ((MBeanRegistration)resource).postDeregister();
  +        }
  +    }
   }
  
  
  

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


Mime
View raw message