CVS update: JGroups/src/org/jgroups/jmx ResourceDMBean.java

"Bela Ban" <[email protected]>
Newsgroups gmane.comp.java.javagroups.cvs
Message-ID <[email protected]>
  User: belaban 
  Date: 10/09/09 09:35:20

  Modified:    src/org/jgroups/jmx ResourceDMBean.java
  Log:
  new findMethods() which inherits annotations on methods, too
  
  Revision  Changes    Path
  1.33      +35 -15    JGroups/src/org/jgroups/jmx/ResourceDMBean.java
  
  Index: ResourceDMBean.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/jmx/ResourceDMBean.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- ResourceDMBean.java	11 Dec 2009 13:21:17 -0000	1.32
  +++ ResourceDMBean.java	9 Sep 2010 09:35:20 -0000	1.33
  @@ -31,7 +31,7 @@
    * 
    * @author Chris Mills
    * @author Vladimir Blagojevic
  - * @version $Id: ResourceDMBean.java,v 1.32 2009/12/11 13:21:17 belaban Exp $
  + * @version $Id: ResourceDMBean.java,v 1.33 2010/09/09 09:35:20 belaban Exp $
    * @see ManagedAttribute
    * @see ManagedOperation
    * @see MBean
  @@ -190,21 +190,41 @@
           throw new ClassNotFoundException("Class " + name + " cannot be found");
       }
   
  +//    private void findMethods() {
  +//        //find all methods but don't include methods from Object class
  +//        List<Method> methods = new ArrayList<Method>(Arrays.asList(getObject().getClass().getMethods()));
  +//        List<Method> objectMethods = new ArrayList<Method>(Arrays.asList(Object.class.getMethods()));
  +//        methods.removeAll(objectMethods);
  +//
  +//        for(Method method:methods) {
  +//            //does method have @ManagedAttribute annotation?
  +//            if(method.isAnnotationPresent(ManagedAttribute.class) || method.isAnnotationPresent(Property.class)) {
  +//                exposeManagedAttribute(method);
  +//            }
  +//            //or @ManagedOperation
  +//            else if (method.isAnnotationPresent(ManagedOperation.class) || isMBeanAnnotationPresentWithExposeAll()){
  +//                exposeManagedOperation(method);
  +//            }
  +//        }
  +//    }
  +
  +    /** find all methods but don't include methods from Object class */
       private void findMethods() {
  -        //find all methods but don't include methods from Object class               
  -        List<Method> methods = new ArrayList<Method>(Arrays.asList(getObject().getClass().getMethods()));
  -        List<Method> objectMethods = new ArrayList<Method>(Arrays.asList(Object.class.getMethods()));
  -        methods.removeAll(objectMethods);
  -               
  -        for(Method method:methods) {
  -            //does method have @ManagedAttribute annotation?
  -            if(method.isAnnotationPresent(ManagedAttribute.class) || method.isAnnotationPresent(Property.class)) {
  -                exposeManagedAttribute(method);
  -            }
  -            //or @ManagedOperation
  -            else if (method.isAnnotationPresent(ManagedOperation.class) || isMBeanAnnotationPresentWithExposeAll()){
  -                exposeManagedOperation(method);                
  -            }                     
  +        for(Class<?> clazz=getObject().getClass();clazz != null; clazz=clazz.getSuperclass()) {
  +            if(clazz.equals(Object.class))
  +                break;
  +
  +            Method[] methods=clazz.getDeclaredMethods();
  +            for(Method method: methods) {
  +                //does method have @ManagedAttribute annotation?
  +                if(method.isAnnotationPresent(ManagedAttribute.class) || method.isAnnotationPresent(Property.class)) {
  +                    exposeManagedAttribute(method);
  +                }
  +                //or @ManagedOperation
  +                else if (method.isAnnotationPresent(ManagedOperation.class) || isMBeanAnnotationPresentWithExposeAll()){
  +                    exposeManagedOperation(method);
  +                }
  +            }
           }
       }
   
  
  
  

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.