Index: testsuite/imports/sections/jbossmx.xml
===================================================================
--- testsuite/imports/sections/jbossmx.xml	(revision 113641)
+++ testsuite/imports/sections/jbossmx.xml	(working copy)
@@ -26,5 +26,14 @@
             <include name="org/jboss/test/jbossmx/performance/**"/>
          </fileset>
       </jar>
+   	
+   	 <jar destfile="${build.lib}/mxbean-compliance.sar">
+   	     <fileset dir="${build.classes}">
+   	        <include name="org/jboss/test/jbossmx/compliance/registration/mxbean/*"/>
+   	     </fileset>
+   	     <fileset dir="${build.resources}/jbossmx/mxbean">
+   	        <include name="META-INF/jboss-service.xml"/>
+   	     </fileset>
+   	 </jar>
    </target>
 </project>
Index: testsuite/build.xml
===================================================================
--- testsuite/build.xml	(revision 113641)
+++ testsuite/build.xml	(working copy)
@@ -1303,7 +1303,7 @@
       <exclude name="**/test/passwordinjection/test/*UnitTestCase.class"/>
       <exclude name="**/test/security/test/authorization/secured/*.class"/>
    </patternset>
-   <!-- A patternset required for Common Criteria certification -->
+   <!-- A patternset required for Common Criteria certification: note this is never used ... -->
    <patternset id="cc.includes">
       <include name="**/test/tm/test/TxTimeout*TestCase.class"/>
       <include name="**/test/security/rmi/test/*TestCase.class"/>
@@ -1321,8 +1321,9 @@
       <include name="org/jboss/test/security/test/WebResourcePermissionUnitTestCase.class"/>
       <include name="org/jboss/test/security/test/WebUserDataPermissionUnitTestCase.class"/>
       <include name="org/jboss/test/security/test/auth.AppCallbackHandlerUnitTestCase.class"/>
-      <include name="org/jboss/test/jmx/test/RMIAdaptorAuthorizationUnitTestCase.class"/>
-      <include name="org/jboss/test/jmx/testRMIAdaptorUnitTestCase.class"/>
+   	  <include name="org/jboss/test/jmx/test/RMIAdaptorAuthorizationUnitTestCase.class"/>
+   	  <include name="org/jboss/test/jmx/test/RMIAdaptorUnitTestCase.class"/>
+   	  <include name="org/jboss/test/jmx/test/MXBeanBasicTestCase.class"/>
       <include name="org/jboss/test/web/test/ssl/SSLUnitTestCase.class"/>
       <include name="org/jboss/test/security/test/ClientLoginModuleEJBUnitTestCase.class"/>
       <include name="org/jboss/test/security/test/ClientLoginModuleUnitTestCase.class"/>
@@ -2086,6 +2087,8 @@
                <include name="org/jboss/test/security/test/auth.AppCallbackHandlerUnitTestCase.class"/>
                <include name="org/jboss/test/jmx/test/RMIAdaptorAuthorizationUnitTestCase.class"/>
                <include name="org/jboss/test/jmx/testRMIAdaptorUnitTestCase.class"/>
+               <include name="org/jboss/test/jmx/test/RMIAdaptorUnitTestCase.class"/>
+               <include name="org/jboss/test/jmx/test/MXBeanBasicTestCase.class"/>
                <include name="org/jboss/test/security/test/ClientLoginModuleEJBUnitTestCase.class"/>
                <include name="org/jboss/test/security/test/ClientLoginModuleUnitTestCase.class"/>
                <include name="org/jboss/test/security/test/CustomPrincipalPropagationUnitTestCase.class"/>
@@ -3695,7 +3698,8 @@
 
          <sysproperty key="build.testlog" value="${build.testlog}"/>
          <sysproperty key="log4j.configuration" value="file:${build.resources}/log4j.xml"/>
-
+      	 <sysproperty key="java.protocol.handler.pkgs" value="org.jboss.virtual.protocol"/>
+      	 <sysproperty key="jbosstest.deploy.dir" file="${build.lib}"/>
          <classpath>
             <pathelement location="${build.classes}"/>
             <pathelement location="${build.resources}"/>
Index: jmx/src/main/org/jboss/mx/server/registry/BasicMBeanRegistry.java
===================================================================
--- jmx/src/main/org/jboss/mx/server/registry/BasicMBeanRegistry.java	(revision 113641)
+++ jmx/src/main/org/jboss/mx/server/registry/BasicMBeanRegistry.java	(working copy)
@@ -60,6 +60,8 @@
 import org.jboss.mx.modelmbean.RequiredModelMBeanInvoker;
 import org.jboss.mx.modelmbean.XMBean;
 import org.jboss.mx.modelmbean.XMBeanConstants;
+import org.jboss.mx.mxbean.MXBeanMetaData;
+import org.jboss.mx.mxbean.MXBeanUtils;
 import org.jboss.mx.server.AbstractMBeanInvoker;
 import org.jboss.mx.server.MBeanInvoker;
 import org.jboss.mx.server.RawDynamicInvoker;
@@ -181,11 +183,10 @@
       boolean invokedPreRegister = false;
       String magicToken          = null;
       MBeanInvoker invoker       = null;
-
+      
       if (object == null)
          throw new RuntimeOperationsException(
                new IllegalArgumentException("Attempting to register null object"));
-
       // get mbean type, dynamic or standard
       MBeanCapability mbcap = MBeanCapability.of(object.getClass());
 
@@ -209,8 +210,15 @@
          {
             if( object instanceof RequiredModelMBean )
                invoker = new RequiredModelMBeanInvoker((DynamicMBean)object);
-            else
+            else if(object instanceof DynamicMBean)
                invoker = new RawDynamicInvoker((DynamicMBean)object);
+            else {
+                //JBPAPP-9809
+                Class mxbeanInterface = MXBeanMetaData.findMXBeanInterface(object.getClass());
+                object = MXBeanUtils.createMXBean(object, mxbeanInterface);
+                invoker= new RawDynamicInvoker((DynamicMBean)object);
+            }
+                
          }
 
          // Perform the pregistration
Index: mbeans/src/main/org/jboss/mx/metadata/MBeanCapability.java
===================================================================
--- mbeans/src/main/org/jboss/mx/metadata/MBeanCapability.java	(revision 113641)
+++ mbeans/src/main/org/jboss/mx/metadata/MBeanCapability.java	(working copy)
@@ -21,7 +21,13 @@
  */
 package org.jboss.mx.metadata;
 
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+
 import javax.management.DynamicMBean;
+import javax.management.MXBean;
 import javax.management.NotCompliantMBeanException;
 
 /**
@@ -72,6 +78,23 @@
 
    public static MBeanCapability of(Class mbeanClass) throws NotCompliantMBeanException
    {
+       MBeanCapability cap = ofMBean(mbeanClass);
+       
+       //if null, check for MXBean, if it there is, return it, else, throw exception
+       if(cap == null){
+           //check for MXBeans
+           cap = ofMXBean(mbeanClass);
+           if(cap != null){
+               return cap;
+           } 
+       } else {
+           return cap;
+       }
+       throw new NotCompliantMBeanException("Class does not expose a management interface: " + mbeanClass.getName());
+   }
+   
+   private static MBeanCapability ofMBean(Class mbeanClass)
+   {
       if (null == mbeanClass)
       {
          throw new IllegalArgumentException("MBean class cannot be null");
@@ -97,9 +120,98 @@
       // If there is an ancestor called SuperClass that is an instance of SuperClassMBean
       Class superClass = mbeanClass.getSuperclass();
       if (superClass != null)
-         return of(superClass);
+         return ofMBean(superClass);
 
-      throw new NotCompliantMBeanException("Class does not expose a management interface: " + mbeanClass.getName());
+      return null;
    }
+   
+    @SuppressWarnings("rawtypes")
+    private static MBeanCapability ofMXBean(final Class mbeanClass) throws NotCompliantMBeanException {
+        // this is a bit different, than ofMBean ( I hope ). We need to dive into interfaces.
+        if (null == mbeanClass) {
+            throw new IllegalArgumentException("MBean class cannot be null");
+        }
+        Class workOnMe = mbeanClass;
+        // gather all interfaces(top defined - this could be done with recursion.
+        LinkedList<Class> ifaces = new LinkedList<Class>();
+        while (true) {
+            Class[] declaredIfaces = workOnMe.getInterfaces();
+            ifaces.addAll(Arrays.asList(declaredIfaces));
+            workOnMe = workOnMe.getSuperclass();
+            if (workOnMe == null || workOnMe.equals(Object.class))
+                break;
+        }
+        // set, to avoid duplicates
+        final Set<Class> score = new HashSet<Class>();
+        for (Class iface : ifaces) {
+            ofMXBeanInterface(mbeanClass,iface, score);
+        }
+        switch (score.size()) {
+            case 0:
+                return null;
+            case 1:
+                // Note ... in perfect world we would return: MX_BEAN defined above..( if it has been defined )
+                // This value will use AS5 mx.mxbean package and classes implemented there.
+                return new MBeanCapability(DYNAMIC_MBEAN);
+            default:
+                throw new NotCompliantMBeanException("Class '" + mbeanClass.getName()
+                        + "' exposes more than one MXBean interface '" + score + "'");
 
-}
+        }
+
+    }
+
+    @SuppressWarnings("rawtypes")
+    private static void ofMXBeanInterface(final Class baseClass,final Class mbeanInterface,final Set<Class> score) throws NotCompliantMBeanException {
+        //this is a bit messy, we have two annotations...
+        boolean failedWithaAnnotation=false;
+        //we actually should mess with this?
+        org.jboss.mx.mxbean.MXBean jbossAnnotation = (org.jboss.mx.mxbean.MXBean) mbeanInterface
+                .getAnnotation(org.jboss.mx.mxbean.MXBean.class);        
+        // we need to check for:
+        // - @MXBean || @MXBean(true)
+        // - zxcMXBean interface
+        MXBean jdkAnnodation = (MXBean) mbeanInterface.getAnnotation(MXBean.class);
+        if(jdkAnnodation!=null && jbossAnnotation!=null){
+            //thats just wrong
+            throw new NotCompliantMBeanException("Class '" + baseClass.getName()
+                    + "' has interface '" + mbeanInterface.getName() + "' which exposes more than on MXBean annotation!");
+        }
+        
+        if(jbossAnnotation!=null){
+            if(jbossAnnotation.value()){
+                score.add(mbeanInterface);
+            }else{
+                failedWithaAnnotation = true;
+            }
+        }
+        
+        if(jdkAnnodation!=null){
+            if(jdkAnnodation.value()){
+                score.add(mbeanInterface);
+            }else{
+                failedWithaAnnotation = true;
+            }
+        }
+        //consider name only in case annotation dont deny
+        if(!failedWithaAnnotation)
+       {
+            // check interface name
+            final String ifaceName = mbeanInterface.getName();
+            if (ifaceName.endsWith("MXBean") && ifaceName.lastIndexOf("MXBean") > 0) {
+                score.add(mbeanInterface);
+            }
+
+        }
+        // now we need to check super interfaces
+        // NOTE: there is no word on double def -
+        // @MXBean public interface XX{}
+        // @MXBean public interface YY extends XX{} ...
+        // so we assume thats a no no. Same for class names?
+        Class[] ifaces = mbeanInterface.getInterfaces();
+        if (ifaces != null) // just in case some JVMs dont behave here
+            for (Class i : ifaces) {
+                ofMXBeanInterface(baseClass,i, score);
+            }
+    }
+}
\ No newline at end of file
Index: mbeans/src/main/org/jboss/mx/mxbean/MXBeanMetaData.java
===================================================================
--- mbeans/src/main/org/jboss/mx/mxbean/MXBeanMetaData.java	(revision 113641)
+++ mbeans/src/main/org/jboss/mx/mxbean/MXBeanMetaData.java	(working copy)
@@ -33,6 +33,7 @@
 import javax.management.MBeanInfo;
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanOperationInfo;
+import javax.management.MXBean;
 import javax.management.NotCompliantMBeanException;
 import javax.management.NotificationBroadcaster;
 import javax.management.openmbean.OpenMBeanAttributeInfo;
@@ -78,9 +79,10 @@
       Class<?> concrete = mbeanClass;
       while (null != concrete)
       {
-         Class result = findMXBeanInterface(concrete, concrete.getInterfaces());
+         Class result = findMXBeanInterface(concrete.getInterfaces());
          if (null != result)
             return result;
+         
          concrete = concrete.getSuperclass();
       }
       return null;
@@ -93,24 +95,41 @@
     * @param interfaces the interfaces to consider
     * @return the interface
     */
-   private static Class<?> findMXBeanInterface(Class<?> concrete, Class<?>[] interfaces)
-   {
-      String mxName = concrete.getName() + "MXBean";
-      String stdName = concrete.getName() + "MBean";
+    private static Class<?> findMXBeanInterface(Class<?>[] interfaces) {
+        //NOTE: returns first encountered result, MBeanCapability.of(...) checks for error conditions.
+        for (Class<?> intf : interfaces) {
+            // JBoss AS annotation, simulating false value as in case of JDK annotation
+            org.jboss.mx.mxbean.MXBean jbossAnnotation = intf.getAnnotation(org.jboss.mx.mxbean.MXBean.class);
 
-      for (Class<?> intf : interfaces)
-      {
-         String name = intf.getName();
-         if (mxName.equals(name) || stdName.equals(name))
-            return intf;
-         
-         MXBean mxBean = intf.getAnnotation(MXBean.class);
-         if (mxBean != null && mxBean.value())
-            return intf;
-      }
-      return null;
-   }
+            if (jbossAnnotation != null)
+            {
+                if(jbossAnnotation.value())
+                    return intf;
+                else
+                    continue;
+            }
+            
+            MXBean jdkAnnodation = (MXBean) intf.getAnnotation(MXBean.class);
+            if (jdkAnnodation != null) {
+                if(jdkAnnodation.value())
+                    return intf;
+                else
+                    continue;
+                // if annotation is there its ok, else we check interface name
+            }
 
+            // check interface name
+            final String ifaceName = intf.getName();
+            if (ifaceName.endsWith("MXBean") && ifaceName.lastIndexOf("MXBean") > 0) {
+                return intf;
+            }
+            
+            //dive into super interfaces
+            return findMXBeanInterface(intf.getInterfaces());
+        }
+        return null;
+    }
+
    /**
     * Create a new MXBeanMetaData.
     * 
