You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by rm...@apache.org on 2012/12/17 00:23:19 UTC

git commit: DELTASPIKE-300 reworking the API to be more consistent

Updated Branches:
  refs/heads/master f7fdffb4f -> ae6b17710


DELTASPIKE-300 reworking the API to be more consistent


Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/ae6b1771
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/ae6b1771
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/ae6b1771

Branch: refs/heads/master
Commit: ae6b1771071426cdfbf805b7edb54d3f90f7e06c
Parents: f7fdffb
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon Dec 17 00:21:53 2012 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon Dec 17 00:22:29 2012 +0100

----------------------------------------------------------------------
 .../core/api/jmx/annotation/Description.java       |   38 ----
 .../core/api/jmx/annotation/JmxDescription.java    |   38 ++++
 .../core/api/jmx/annotation/JmxManaged.java        |   34 ++++
 .../core/api/jmx/annotation/ManagedAttribute.java  |   33 ----
 .../core/api/jmx/annotation/ManagedOperation.java  |   33 ----
 .../core/api/jmx/annotation/NotificationInfo.java  |    2 +-
 .../core/impl/jmx/DynamicMBeanWrapper.java         |  133 +++++++--------
 .../apache/deltaspike/core/impl/jmx/FieldInfo.java |   52 ++++++
 .../test/core/impl/jmx/SimpleRegistrationTest.java |   21 +--
 9 files changed, 192 insertions(+), 192 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/Description.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/Description.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/Description.java
deleted file mode 100644
index c713739..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/Description.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.deltaspike.core.api.jmx.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.CONSTRUCTOR;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ CONSTRUCTOR, FIELD, METHOD, PARAMETER, TYPE })
-public @interface Description
-{
-    String value() default "";
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/JmxDescription.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/JmxDescription.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/JmxDescription.java
new file mode 100644
index 0000000..75b4bd9
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/JmxDescription.java
@@ -0,0 +1,38 @@
+/*
+ * 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.deltaspike.core.api.jmx.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ FIELD, METHOD, TYPE })
+public @interface JmxDescription
+{
+    String value() default "";
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/JmxManaged.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/JmxManaged.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/JmxManaged.java
new file mode 100644
index 0000000..9a46f55
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/JmxManaged.java
@@ -0,0 +1,34 @@
+/*
+ * 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.deltaspike.core.api.jmx.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(RUNTIME)
+@Target({ FIELD, METHOD })
+@Documented
+public @interface JmxManaged
+{
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/ManagedAttribute.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/ManagedAttribute.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/ManagedAttribute.java
deleted file mode 100644
index 1f3e665..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/ManagedAttribute.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.deltaspike.core.api.jmx.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Retention(RUNTIME)
-@Target(METHOD)
-@Documented
-public @interface ManagedAttribute
-{
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/ManagedOperation.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/ManagedOperation.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/ManagedOperation.java
deleted file mode 100644
index be18909..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/ManagedOperation.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.deltaspike.core.api.jmx.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Retention(RUNTIME)
-@Target(METHOD)
-@Documented
-public @interface ManagedOperation
-{
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/NotificationInfo.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/NotificationInfo.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/NotificationInfo.java
index ae89b96..a3b1cd5 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/NotificationInfo.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/jmx/annotation/NotificationInfo.java
@@ -32,7 +32,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
 public @interface NotificationInfo
 {
     String[] types() default { };
-    Description description() default @Description("");
+    JmxDescription description() default @JmxDescription("");
     Class<? extends Notification> notificationClass() default Notification.class;
     String[] descriptorFields() default { };
 

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
index a764812..1d04338 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/DynamicMBeanWrapper.java
@@ -19,9 +19,8 @@
 package org.apache.deltaspike.core.impl.jmx;
 
 import org.apache.deltaspike.core.api.config.ConfigResolver;
-import org.apache.deltaspike.core.api.jmx.annotation.Description;
-import org.apache.deltaspike.core.api.jmx.annotation.ManagedAttribute;
-import org.apache.deltaspike.core.api.jmx.annotation.ManagedOperation;
+import org.apache.deltaspike.core.api.jmx.annotation.JmxDescription;
+import org.apache.deltaspike.core.api.jmx.annotation.JmxManaged;
 import org.apache.deltaspike.core.api.jmx.annotation.NotificationInfo;
 import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
@@ -34,7 +33,6 @@ import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
 import javax.management.DynamicMBean;
 import javax.management.ImmutableDescriptor;
-import javax.management.IntrospectionException;
 import javax.management.InvalidAttributeValueException;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanException;
@@ -43,6 +41,7 @@ import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanOperationInfo;
 import javax.management.ReflectionException;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -60,8 +59,7 @@ public class DynamicMBeanWrapper implements DynamicMBean
     public static final Logger LOGGER = Logger.getLogger(DynamicMBeanWrapper.class.getName());
 
     private final MBeanInfo info;
-    private final Map<String, Method> getters = new HashMap<String, Method>();
-    private final Map<String, Method> setters = new HashMap<String, Method>();
+    private final Map<String, FieldInfo> fields = new HashMap<String, FieldInfo>();
     private final Map<String, Method> operations = new HashMap<String, Method>();
     private final ClassLoader classloader;
     private final Class<?> clazz;
@@ -84,7 +82,7 @@ public class DynamicMBeanWrapper implements DynamicMBean
 
         // class
         final String description =
-            getDescription(annotatedMBean.getAnnotation(Description.class), annotatedMBean.getName());
+            getDescription(annotatedMBean.getAnnotation(JmxDescription.class), annotatedMBean.getName());
 
         final NotificationInfo notification = annotatedMBean.getAnnotation(NotificationInfo.class);
         if (notification != null)
@@ -108,70 +106,64 @@ public class DynamicMBeanWrapper implements DynamicMBean
             final int modifiers = method.getModifiers();
             if (method.getDeclaringClass().equals(Object.class)
                     || !Modifier.isPublic(modifiers)
-                    || Modifier.isAbstract(modifiers))
+                    || Modifier.isAbstract(modifiers)
+                    || Modifier.isStatic(modifiers)
+                    || method.getAnnotation(JmxManaged.class) == null)
             {
                 continue;
             }
 
-            if (method.getAnnotation(ManagedAttribute.class) != null)
-            {
-                final String methodName = method.getName();
-
-                String attrName = methodName;
-                if (isAccessor(method))
-                {
-                    attrName = attrName.substring(3);
-                    if (attrName.length() > 1)
-                    {
-                        attrName = Character.toLowerCase(attrName.charAt(0)) + attrName.substring(1);
-                    }
-                    else
-                    {
-                        attrName = attrName.toLowerCase();
-                    }
-                }
-                else
-                {
-                    LOGGER.warning("ignoring attribute " + method.getName() + " for " + annotatedMBean.getName());
-                    continue;
-                }
+            operations.put(method.getName(), method);
 
-                if (methodName.startsWith("get"))
-                {
-                    getters.put(attrName, method);
-                }
-                else if (methodName.startsWith("set"))
-                {
-                    setters.put(attrName, method);
-                }
-            }
-            else if (method.getAnnotation(ManagedOperation.class) != null)
-            {
-                operations.put(method.getName(), method);
+            String operationDescr = getDescription(method.getAnnotation(JmxDescription.class),
+                annotatedMBean.getName() + "#" + method.getName());
 
-                String operationDescr = getDescription(method.getAnnotation(Description.class),
-                    annotatedMBean.getName() + "#" + method.getName());
-
-                operationInfos.add(new MBeanOperationInfo(operationDescr, method));
-            }
+            operationInfos.add(new MBeanOperationInfo(operationDescr, method));
         }
 
-        for (Map.Entry<String, Method> methodEntry : getters.entrySet())
-        {
-            final String key = methodEntry.getKey();
-            final Method method = methodEntry.getValue();
+        Class<?> clazz = annotatedMBean;
+        while (!Object.class.equals(clazz) && clazz != null) {
+            for (Field field : clazz.getDeclaredFields()) {
+                final JmxManaged annotation = field.getAnnotation(JmxManaged.class);
+                if (annotation != null) {
+                    field.setAccessible(true);
+
+                    final String name = field.getName();
+                    final String fieldDescription = getDescription(field.getAnnotation(JmxDescription.class),
+                            annotatedMBean.getClass() + "#" + name);
+                    final Class<?> type = field.getType();
+
+                    final String javaMtdName;
+                    if (name.length() > 1) {
+                        javaMtdName = Character.toUpperCase(name.charAt(0)) + name.substring(1);
+                    } else {
+                        javaMtdName = "" + Character.toUpperCase(name.charAt(0));
+                    }
 
-            String attrDescr = getDescription(method.getAnnotation(Description.class),
-                method.getDeclaringClass().getName() + "#" + method.getName());
+                    Method setter = null;
+                    Method getter = null;
+                    try {
+                        getter = clazz.getMethod("get" + javaMtdName);
+                    } catch (NoSuchMethodException e1) {
+                        try { // since we handle it ourself we treat it as a normal getter
+                            getter = clazz.getMethod("is" + javaMtdName);
+                        } catch (NoSuchMethodException e2) {
+                            // ignored
+                        }
+                    }
+                    try {
+                        setter = clazz.getMethod("set" + javaMtdName, field.getType());
+                    } catch (NoSuchMethodException e) {
+                        // ignored
+                    }
 
-            try
-            {
-                attributeInfos.add(new MBeanAttributeInfo(key, attrDescr, method, setters.get(key)));
-            }
-            catch (IntrospectionException ex)
-            {
-                LOGGER.log(Level.WARNING, "can't manage " + key + " for " + method.getName(), ex);
+                    attributeInfos.add(new MBeanAttributeInfo(name, type.getName(),
+                            fieldDescription, getter != null, setter != null, false));
+
+                    fields.put(name, new FieldInfo(field, getter, setter));
+                }
             }
+            clazz = clazz.getSuperclass();
         }
 
         info = new MBeanInfo(annotatedMBean.getName(),
@@ -182,14 +174,6 @@ public class DynamicMBeanWrapper implements DynamicMBean
                 notificationInfos.toArray(new MBeanNotificationInfo[notificationInfos.size()]));
     }
 
-    private static boolean isAccessor(final Method m)
-    {
-        final String name = m.getName();
-        return ((name.startsWith("get") && m.getParameterTypes().length == 0)
-                || (name.startsWith("set") && m.getParameterTypes().length == 1))
-                && name.length() > 3;
-    }
-
     private MBeanNotificationInfo getNotificationInfo(final NotificationInfo n, String sourceInfo)
     {
         return new MBeanNotificationInfo(n.types(),
@@ -197,7 +181,7 @@ public class DynamicMBeanWrapper implements DynamicMBean
                 new ImmutableDescriptor(n.descriptorFields()));
     }
 
-    private String getDescription(final Description description, String defaultDescription)
+    private String getDescription(final JmxDescription description, String defaultDescription)
     {
         if (description == null || "".equals(description.value()))
         {
@@ -233,13 +217,13 @@ public class DynamicMBeanWrapper implements DynamicMBean
     public Object getAttribute(final String attribute)
         throws AttributeNotFoundException, MBeanException, ReflectionException
     {
-        if (getters.containsKey(attribute))
+        if (fields.containsKey(attribute))
         {
             final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
             Thread.currentThread().setContextClassLoader(classloader);
             try
             {
-                return getters.get(attribute).invoke(instance());
+                return fields.get(attribute).get(instance());
             }
             catch (IllegalArgumentException e)
             {
@@ -265,13 +249,13 @@ public class DynamicMBeanWrapper implements DynamicMBean
     public void setAttribute(final Attribute attribute)
         throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
     {
-        if (setters.containsKey(attribute.getName()))
+        if (fields.containsKey(attribute.getName()))
         {
             final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
             Thread.currentThread().setContextClassLoader(classloader);
             try
             {
-                setters.get(attribute.getName()).invoke(instance(), attribute.getValue());
+                fields.get(attribute.getName()).set(instance(), attribute.getValue());
             }
             catch (IllegalArgumentException e)
             {
@@ -284,8 +268,7 @@ public class DynamicMBeanWrapper implements DynamicMBean
             catch (InvocationTargetException e)
             {
                 LOGGER.log(Level.SEVERE, "can't set " + attribute + " value", e);
-            }
-            finally
+            } finally
             {
                 Thread.currentThread().setContextClassLoader(oldCl);
             }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/FieldInfo.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/FieldInfo.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/FieldInfo.java
new file mode 100644
index 0000000..96188b5
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/jmx/FieldInfo.java
@@ -0,0 +1,52 @@
+/*
+ * 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.deltaspike.core.impl.jmx;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+public class FieldInfo {
+    private final Field field;
+    private final Method getter;
+    private final Method setter;
+
+    public FieldInfo(final Field field, final Method get, final Method set)
+    {
+        this.field = field;
+        this.setter = set;
+        this.getter = get;
+    }
+
+    public Object get(final Object instance) throws InvocationTargetException, IllegalAccessException
+    {
+        if (getter == null) {
+            throw new IllegalAccessException("This attribute has no getter");
+        }
+        return getter.invoke(instance);
+    }
+
+    public void set(final Object instance, final Object value) throws InvocationTargetException, IllegalAccessException
+    {
+        if (setter == null) {
+            throw new IllegalAccessException("This attribute has no setter");
+        }
+        setter.invoke(instance, value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/ae6b1771/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
index 3c4e188..d7840c8 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java
@@ -18,10 +18,9 @@
  */
 package org.apache.deltaspike.test.core.impl.jmx;
 
-import org.apache.deltaspike.core.api.jmx.annotation.Description;
+import org.apache.deltaspike.core.api.jmx.annotation.JmxDescription;
+import org.apache.deltaspike.core.api.jmx.annotation.JmxManaged;
 import org.apache.deltaspike.core.api.jmx.annotation.MBean;
-import org.apache.deltaspike.core.api.jmx.annotation.ManagedAttribute;
-import org.apache.deltaspike.core.api.jmx.annotation.ManagedOperation;
 import org.apache.deltaspike.core.impl.jmx.MBeanExtension;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
@@ -82,24 +81,22 @@ public class SimpleRegistrationTest {
     }
 
     @MBean
-    @Description("my mbean")
+    @JmxDescription("my mbean")
     @ApplicationScoped
     public static class MyMBean
     {
+        @JmxManaged
+        @JmxDescription("get counter")
         private int counter = 0;
 
-        @ManagedAttribute
-        @Description("get counter")
         public int getCounter()
         {
             return counter;
         }
 
-        @ManagedAttribute
-        @Description("set counter")
-        public void setCounter(final int counter)
+        public void setCounter(final int v)
         {
-            this.counter = counter;
+            counter = v;
         }
 
         public void resetTo(final int value)
@@ -107,8 +104,8 @@ public class SimpleRegistrationTest {
             counter = value;
         }
 
-        @ManagedOperation
-        @Description("multiply counter")
+        @JmxManaged
+        @JmxDescription("multiply counter")
         public int multiply(final int n)
         {
             return counter * n;