felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1002809 - in /felix/trunk/ipojo: annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/ handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/ tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annot...
Date Wed, 29 Sep 2010 19:10:11 GMT
Author: clement
Date: Wed Sep 29 19:10:10 2010
New Revision: 1002809

URL: http://svn.apache.org/viewvc?rev=1002809&view=rev
Log:
Refactor the JMX Handler
Fix FELIX-2633 Rename JMX annotations

Added:
    felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXMethod.java
    felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXProperty.java
    felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java
Modified:
    felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java
    felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java
    felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java
    felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
    felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
    felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java

Modified: felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java?rev=1002809&r1=1002808&r2=1002809&view=diff
==============================================================================
--- felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java
(original)
+++ felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Config.java
Wed Sep 29 19:10:10 2010
@@ -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 @@ import java.lang.annotation.Target;
 /**
  * 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 @@ public @interface Config {
      * 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 "";
-    
+
 
 }

Added: felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXMethod.java?rev=1002809&view=auto
==============================================================================
--- felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXMethod.java
(added)
+++ felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXMethod.java
Wed Sep 29 19:10:10 2010
@@ -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 "";
+
+}

Added: felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXProperty.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXProperty.java?rev=1002809&view=auto
==============================================================================
--- felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXProperty.java
(added)
+++ felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXProperty.java
Wed Sep 29 19:10:10 2010
@@ -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;
+    
+
+}

Modified: felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java?rev=1002809&r1=1002808&r2=1002809&view=diff
==============================================================================
--- felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java
(original)
+++ felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Method.java
Wed Sep 29 19:10:10 2010
@@ -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 @@ import java.lang.annotation.Target;
  * 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

Modified: felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java?rev=1002809&r1=1002808&r2=1002809&view=diff
==============================================================================
--- felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java
(original)
+++ felix/trunk/ipojo/annotations/src/main/java/org/apache/felix/ipojo/handlers/jmx/Property.java
Wed Sep 29 19:10:10 2010
@@ -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 @@ import java.lang.annotation.Target;
  * 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;
-    
+
 
 }

Modified: felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java?rev=1002809&r1=1002808&r2=1002809&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
(original)
+++ felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
Wed Sep 29 19:10:10 2010
@@ -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.MBeanServer;
 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 @@ public class MBeanHandler extends Primit
     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 @@ public class MBeanHandler extends Primit
     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 @@ public class MBeanHandler extends Primit
             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 @@ public class MBeanHandler extends Primit
         }
 
         // set property
-        Element[] attributes = mbeans[0].getElements(JMX_PROPERTY_ELT, m_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));
+        }
 
-        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[] 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));
         }
 
-        // 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);
-
-                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 (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";
+            }
 
-                if (attributes[i].containsAttribute(JMX_NOTIFICATION_ELT)) {
-                    notif = Boolean.parseBoolean(attributes[i]
-                        .getAttribute(JMX_NOTIFICATION_ELT));
-                }
+            PropertyField property = new PropertyField(name, field, rights,
+                getTypeFromAttributeField(field, manipulation));
 
-                property.setNotifiable(notif);
+            if (attribute.containsAttribute(JMX_NOTIFICATION_ELT)) {
+                notif = Boolean.parseBoolean(attribute
+                    .getAttribute(JMX_NOTIFICATION_ELT));
+            }
 
-                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);
+            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);
+        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));
+        }
 
-        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[] 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 (int i = 0; methods != null && i < methods.length; i++) {
-            String name = methods[i].getAttribute(JMX_NAME_ELT);
+        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);
             }
         }
 

Modified: felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java?rev=1002809&r1=1002808&r2=1002809&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
(original)
+++ felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
Wed Sep 29 19:10:10 2010
@@ -5,22 +5,22 @@ import org.apache.felix.ipojo.junit4osgi
 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 @@ public class JMX extends OSGiTestCase {
         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);
     }
 
 }

Added: felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java?rev=1002809&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java
(added)
+++ felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java
Wed Sep 29 19:10:10 2010
@@ -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;
+    }
+}

Modified: felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java?rev=1002809&r1=1002808&r2=1002809&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
(original)
+++ felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
Wed Sep 29 19:10:10 2010
@@ -2,23 +2,23 @@ package org.apache.felix.ipojo.test.scen
 
 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;
     }



Mime
View raw message