Refactor the JMX Handler
Fix FELIX-2633 Rename JMX annotations


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1002809 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java
index f5d390d..2b574eb 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -24,13 +24,13 @@
 /**
  * JMX Handler annotation.
  * Allows exposing the instances as a JMX MBean.
- * Be aware that despite is it provided in the annotations jar, 
+ * Be aware that despite is it provided in the annotations jar,
  * it refers to an external handler.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 @Target(ElementType.TYPE)
 public @interface Config {
-    
+
     /**
      * Enables or Disables MOSGi usage.
      * If MOSGi is used, MBeans are exposed with the MOSGi mechanism.
@@ -38,24 +38,24 @@
      * Default : false
      */
     boolean usesMOSGi() default false;
-    
+
     /**
      * Sets the MBean object name.
-     * Default : 'package-name:facotry-name:instance-name'.
+     * Default : 'package-name:factory-name:instance-name'.
      */
     String objectname() default "";
-    
+
     /**
      * Sets the MBean domain.
      * Default : 'package-name'
      */
     String domain() default "";
-    
+
     /**
      * Sets the MBean name.
      * Default : 'instance-name'
      */
     String name() default "";
-    
+
 
 }
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXMethod.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXMethod.java
new file mode 100644
index 0000000..27ca89a
--- /dev/null
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXMethod.java
@@ -0,0 +1,42 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handlers.jmx;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/**
+ * JMX Method annotation.
+ * Allows exposing methods in the MBean.
+ * This annotation must be used only if the {@link Config} annotation
+ * is used.
+ * Be aware that despite is it provided in the annotations jar, 
+ * it refers to an external handler.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Target(ElementType.METHOD)
+public @interface JMXMethod {
+        
+    /**
+     * Gets the method description.
+     * Default : no description
+     */
+    String description() default "";
+
+}
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXProperty.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXProperty.java
new file mode 100644
index 0000000..1b31c7c
--- /dev/null
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXProperty.java
@@ -0,0 +1,55 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handlers.jmx;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/**
+ * JMX Property annotation.
+ * Allows exposing properties in the MBean.
+ * This annotation must be used only if the {@link Config} annotation
+ * is used.
+ * Be aware that despite is it provided in the annotations jar, 
+ * it refers to an external handler.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Target(ElementType.FIELD)
+public @interface JMXProperty {
+        
+    /**
+     * Sets the property name.
+     */
+    String name();
+    
+    /**
+     * Sets the access permission.
+     * Possible values are 'r' (default) or 'w'.
+     * 'w' implies read and write access.
+     */
+    String rights() default "r";
+    
+    /**
+     * Enables notification on the current property.
+     * Notifications are disable by default.
+     */
+    boolean notification() default false;
+    
+
+}
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java
index b4aab6f..4fb0cd1 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -26,13 +26,14 @@
  * Allows exposing methods in the MBean.
  * This annotation must be used only if the {@link Config} annotation
  * is used.
- * Be aware that despite is it provided in the annotations jar, 
+ * Be aware that despite is it provided in the annotations jar,
  * it refers to an external handler.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ * @deprecated replaced by {@link JMXMethod}
  */
 @Target(ElementType.METHOD)
 public @interface Method {
-        
+
     /**
      * Gets the method description.
      * Default : no description
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java
index de9fb9f..6de9e83 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -26,30 +26,31 @@
  * Allows exposing properties in the MBean.
  * This annotation must be used only if the {@link Config} annotation
  * is used.
- * Be aware that despite is it provided in the annotations jar, 
+ * Be aware that despite is it provided in the annotations jar,
  * it refers to an external handler.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ * @deprecated replaced by {@link JMXProperty}
  */
 @Target(ElementType.FIELD)
 public @interface Property {
-        
+
     /**
      * Sets the property name.
      */
     String name();
-    
+
     /**
      * Sets the access permission.
      * Possible values are 'r' (default) or 'w'.
      * 'w' implies read and write access.
      */
     String rights() default "r";
-    
+
     /**
      * Enables notification on the current property.
      * Notifications are disable by default.
      */
     boolean notification() default false;
-    
+
 
 }
diff --git a/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java b/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
index 249b474..efffc22 100644
--- a/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
+++ b/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -19,7 +19,10 @@
 package org.apache.felix.ipojo.handlers.jmx;
 
 import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Dictionary;
+import java.util.List;
 import java.util.Properties;
 
 import javax.management.MBeanRegistration;
@@ -27,6 +30,7 @@
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 
+import org.apache.felix.ipojo.FieldInterceptor;
 import org.apache.felix.ipojo.InstanceManager;
 import org.apache.felix.ipojo.PrimitiveHandler;
 import org.apache.felix.ipojo.architecture.HandlerDescription;
@@ -97,6 +101,11 @@
     private static final String JMX_METHOD_ELT = "method";
 
     /**
+     * The alternative name of a method element.
+     */
+    private static final String JMX_METHOD_ELT_ALT = "method";
+
+    /**
      * The name of the property or method name attribute.
      */
     private static final String JMX_NAME_ELT = "name";
@@ -112,6 +121,11 @@
     private static final String JMX_PROPERTY_ELT = "property";
 
     /**
+     * The alternative name of a property element.
+     */
+    private static final String JMX_PROPERTY_ELT_ALT = "property";
+
+    /**
      * The name of the field attribute.
      */
     private static final String JMX_FIELD_ELT = "field";
@@ -215,15 +229,15 @@
             return;
         }
 
+        Element mbean = mbeans[0];
+
         // retrieve kind of MBeanServer to use
-        m_usesMOSGi = Boolean.parseBoolean(mbeans[0]
-            .getAttribute(JMX_USES_MOSGI_ELT));
+        m_usesMOSGi = Boolean.parseBoolean(mbean.getAttribute(JMX_USES_MOSGI_ELT));
 
         // retrieve object name
-        m_completeObjNameElt = mbeans[0].getAttribute(JMX_OBJ_NAME_ELT);
-        m_domainElt = mbeans[0].getAttribute(JMX_OBJ_NAME_DOMAIN_ELT);
-        m_objNameWODomainElt = mbeans[0]
-            .getAttribute(JMX_OBJ_NAME_WO_DOMAIN_ELT);
+        m_completeObjNameElt = mbean.getAttribute(JMX_OBJ_NAME_ELT);
+        m_domainElt = mbean.getAttribute(JMX_OBJ_NAME_DOMAIN_ELT);
+        m_objNameWODomainElt = mbean.getAttribute(JMX_OBJ_NAME_WO_DOMAIN_ELT);
 
         // test if Pojo is interested in registration callbacks
         m_registerCallbacks = manipulation
@@ -248,87 +262,98 @@
         }
 
         // set property
-        Element[] attributes = mbeans[0].getElements(JMX_PROPERTY_ELT, m_namespace);
-
-        if (attributes == null) {
-            attributes = mbeans[0].getElements(JMX_PROPERTY_ELT);
-            if (attributes != null) {
-                warn("The JMX property element should use the '" + m_namespace + "' namespace.");
-            }
+        Element[] attributes = mbean.getElements(JMX_PROPERTY_ELT, m_namespace);
+        Element[] attributesAlt = mbean.getElements(JMX_PROPERTY_ELT_ALT, m_namespace);
+        List<Element> listOfAttributes = new ArrayList<Element>();
+        if (attributes != null) {
+        	listOfAttributes.addAll(Arrays.asList(attributes));
+        }
+        if (attributesAlt != null) {
+        	listOfAttributes.addAll(Arrays.asList(attributesAlt));
         }
 
-        // String[] fields = new String[attributes.length];
-        if (attributes != null) {
-            for (int i = 0; attributes != null && i < attributes.length; i++) {
-                boolean notif = false;
-                String rights;
-                String name;
-                String field = attributes[i].getAttribute(JMX_FIELD_ELT);
+        Element[] attributesOld = mbeans[0].getElements(JMX_PROPERTY_ELT);
+        if (attributesOld != null) {
+            warn("The JMX property element should use the '" + m_namespace + "' namespace.");
+            listOfAttributes.addAll(Arrays.asList(attributesOld));
+        }
 
-                if (attributes[i].containsAttribute(JMX_NAME_ELT)) {
-                    name = attributes[i].getAttribute(JMX_NAME_ELT);
-                } else {
-                    name = field;
-                }
-                if (attributes[i].containsAttribute(JMX_RIGHTS_ELT)) {
-                    rights = attributes[i].getAttribute(JMX_RIGHTS_ELT);
-                } else {
-                    rights = "r";
-                }
+        for (Element attribute : listOfAttributes) {
+            boolean notif = false;
+            String rights;
+            String name;
+            String field = attribute.getAttribute(JMX_FIELD_ELT);
 
-                PropertyField property = new PropertyField(name, field, rights,
-                    getTypeFromAttributeField(field, manipulation));
-
-                if (attributes[i].containsAttribute(JMX_NOTIFICATION_ELT)) {
-                    notif = Boolean.parseBoolean(attributes[i]
-                        .getAttribute(JMX_NOTIFICATION_ELT));
-                }
-
-                property.setNotifiable(notif);
-
-                if (notif) {
-                    // add the new notifiable property in structure
-                    NotificationField notification = new NotificationField(
-                        name, this.getClass().getName() + "." + field, null);
-                    m_jmxConfigFieldMap.addNotificationFromName(name,
-                        notification);
-                }
-                m_jmxConfigFieldMap.addPropertyFromName(name, property);
-                getInstanceManager().register(manipulation.getField(field),
-                    this);
-                info("property exposed:" + name + " " + field + ":"
-                        + getTypeFromAttributeField(field, manipulation) + " "
-                        + rights + ", Notif=" + notif);
+            if (attribute.containsAttribute(JMX_NAME_ELT)) {
+                name = attribute.getAttribute(JMX_NAME_ELT);
+            } else {
+                name = field;
             }
+            if (attribute.containsAttribute(JMX_RIGHTS_ELT)) {
+                rights = attribute.getAttribute(JMX_RIGHTS_ELT);
+            } else {
+                rights = "r";
+            }
+
+            PropertyField property = new PropertyField(name, field, rights,
+                getTypeFromAttributeField(field, manipulation));
+
+            if (attribute.containsAttribute(JMX_NOTIFICATION_ELT)) {
+                notif = Boolean.parseBoolean(attribute
+                    .getAttribute(JMX_NOTIFICATION_ELT));
+            }
+
+            property.setNotifiable(notif);
+
+            if (notif) {
+                // add the new notifiable property in structure
+                NotificationField notification = new NotificationField(
+                    name, this.getClass().getName() + "." + field, null);
+                m_jmxConfigFieldMap.addNotificationFromName(name,
+                    notification);
+            }
+            m_jmxConfigFieldMap.addPropertyFromName(name, property);
+            getInstanceManager().register(manipulation.getField(field),
+                this);
+            info("property exposed:" + name + " " + field + ":"
+                    + getTypeFromAttributeField(field, manipulation) + " "
+                    + rights + ", Notif=" + notif);
         }
 
         // set methods
-        Element[] methods = mbeans[0].getElements(JMX_METHOD_ELT, m_namespace);
-
-        if (methods == null) {
-            methods = mbeans[0].getElements(JMX_METHOD_ELT);
-            if (methods != null) {
-                warn("The JMX method element should use the '" + m_namespace + "' namespace.");
-            }
+        Element[] methods = mbean.getElements(JMX_METHOD_ELT, m_namespace);
+        Element[] methodsAlt = mbean.getElements(JMX_METHOD_ELT_ALT, m_namespace);
+        List<Element> listOfMethods = new ArrayList<Element>();
+        if (methods != null) {
+        	listOfMethods.addAll(Arrays.asList(methods));
+        }
+        if (methodsAlt != null) {
+        	listOfMethods.addAll(Arrays.asList(methodsAlt));
         }
 
-        for (int i = 0; methods != null && i < methods.length; i++) {
-            String name = methods[i].getAttribute(JMX_NAME_ELT);
+        Element[] methodsOld = mbeans[0].getElements(JMX_PROPERTY_ELT);
+        if (methodsOld != null) {
+            warn("The JMX method element should use the '" + m_namespace + "' namespace.");
+            listOfMethods.addAll(Arrays.asList(methodsOld));
+        }
+
+        for (Element method : listOfMethods) {
+            String name = method.getAttribute(JMX_NAME_ELT);
             if (name == null) {
-                name = methods[i].getAttribute("method");
+                name = method.getAttribute("method");
             }
             String description = null;
-            if (methods[i].containsAttribute(JMX_DESCRIPTION_ELT)) {
-                description = methods[i].getAttribute(JMX_DESCRIPTION_ELT);
+            if (method.containsAttribute(JMX_DESCRIPTION_ELT)) {
+                description = method.getAttribute(JMX_DESCRIPTION_ELT);
             }
 
-            MethodField[] method = getMethodsFromName(name, manipulation,
+            MethodField[] meth = getMethodsFromName(name, manipulation,
                 description);
 
-            for (int j = 0; j < method.length; j++) {
-                m_jmxConfigFieldMap.addMethodFromName(name, method[j]);
+            for (int j = 0; j < meth.length; j++) {
+                m_jmxConfigFieldMap.addMethodFromName(name, meth[j]);
 
-                info("method exposed:" + method[j].getReturnType() + " " + name);
+                info("method exposed:" + meth[j].getReturnType() + " " + name);
             }
         }
 
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
index 4e07d29..7da4390 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
@@ -5,22 +5,22 @@
 import org.apache.felix.ipojo.metadata.Element;
 
 public class JMX extends OSGiTestCase {
-    
+
     private IPOJOHelper helper;
-    
+
     public void setUp() {
         helper = new IPOJOHelper(this);
     }
-    
-    public void testSimple() {
-        Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.jmx.JMXSimple");
+
+    public void testDeprecated() {
+        Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.jmx.JMXDeprecated");
         /*
          * org.apache.felix.ipojo.handlers.jmx:config domain="my-domain" usesmosgi="false"
         org.apache.felix.ipojo.handlers.jmx:property field="m_foo" name="prop" rights="w" notification="true"
         org.apache.felix.ipojo.handlers.jmx:method description="get the foo prop" method="getFoo"
         org.apache.felix.ipojo.handlers.jmx:method description="set the foo prop" method="setFoo"
          */
-        
+
         Element[] ele = meta.getElements("config", "org.apache.felix.ipojo.handlers.jmx");
         assertNotNull("ele not null", ele);
         assertEquals("Ele size", 1, ele.length);
@@ -28,17 +28,40 @@
         String mosgi = ele[0].getAttribute("usesmosgi");
         assertEquals("domain", "my-domain", domain);
         assertEquals("mosgi", "false", mosgi);
-        
+
         Element[] props = ele[0].getElements("property", "org.apache.felix.ipojo.handlers.jmx");
         assertNotNull("props not null", props);
         assertEquals("props size", 1, props.length);
-        
+
         Element[] methods = ele[0].getElements("method", "org.apache.felix.ipojo.handlers.jmx");
         assertNotNull("methods not null", methods);
         assertEquals("methods size", 2, methods.length);
-        
+    }
 
+    public void test() {
+        Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.jmx.JMXSimple");
+        /*
+         * org.apache.felix.ipojo.handlers.jmx:config domain="my-domain" usesmosgi="false"
+        org.apache.felix.ipojo.handlers.jmx:property field="m_foo" name="prop" rights="w" notification="true"
+        org.apache.felix.ipojo.handlers.jmx:method description="get the foo prop" method="getFoo"
+        org.apache.felix.ipojo.handlers.jmx:method description="set the foo prop" method="setFoo"
+         */
 
+        Element[] ele = meta.getElements("config", "org.apache.felix.ipojo.handlers.jmx");
+        assertNotNull("ele not null", ele);
+        assertEquals("Ele size", 1, ele.length);
+        String domain = ele[0].getAttribute("domain");
+        String mosgi = ele[0].getAttribute("usesmosgi");
+        assertEquals("domain", "my-domain", domain);
+        assertEquals("mosgi", "false", mosgi);
+
+        Element[] props = ele[0].getElements("JMXProperty", "org.apache.felix.ipojo.handlers.jmx");
+        assertNotNull("props not null", props);
+        assertEquals("props size", 1, props.length);
+
+        Element[] methods = ele[0].getElements("JMXMethod", "org.apache.felix.ipojo.handlers.jmx");
+        assertNotNull("methods not null", methods);
+        assertEquals("methods size", 2, methods.length);
     }
 
 }
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java
new file mode 100644
index 0000000..ab374b0
--- /dev/null
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java
@@ -0,0 +1,25 @@
+package org.apache.felix.ipojo.test.scenarios.component.jmx;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.handlers.jmx.Config;
+import org.apache.felix.ipojo.handlers.jmx.Method;
+import org.apache.felix.ipojo.handlers.jmx.Property;
+
+@Component
+@Config(domain="my-domain", usesMOSGi=false)
+public class JMXDeprecated {
+
+    @Property(name="prop", notification=true, rights="w")
+    String m_foo;
+    
+    @Method(description="set the foo prop")
+    public void setFoo(String mes) {
+        System.out.println("Set foo to " + mes);
+        m_foo = mes;
+    }
+    
+    @Method(description="get the foo prop")
+    public String getFoo() {
+        return m_foo;
+    }
+}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
index 54cbbe7..675dc40 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
@@ -2,23 +2,23 @@
 
 import org.apache.felix.ipojo.annotations.Component;
 import org.apache.felix.ipojo.handlers.jmx.Config;
-import org.apache.felix.ipojo.handlers.jmx.Method;
-import org.apache.felix.ipojo.handlers.jmx.Property;
+import org.apache.felix.ipojo.handlers.jmx.JMXMethod;
+import org.apache.felix.ipojo.handlers.jmx.JMXProperty;
 
 @Component
 @Config(domain="my-domain", usesMOSGi=false)
 public class JMXSimple {
 
-    @Property(name="prop", notification=true, rights="w")
+    @JMXProperty(name="prop", notification=true, rights="w")
     String m_foo;
-    
-    @Method(description="set the foo prop")
+
+    @JMXMethod(description="set the foo prop")
     public void setFoo(String mes) {
         System.out.println("Set foo to " + mes);
         m_foo = mes;
     }
-    
-    @Method(description="get the foo prop")
+
+    @JMXMethod(description="get the foo prop")
     public String getFoo() {
         return m_foo;
     }