[jboss-cvs] JBossAS SVN: r94665 - in projects/jbossmx/trunk: mbeans/src/main/org/jboss/mx/metadata and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 12 04:30:32 EDT 2009
Author: alesj
Date: 2009-10-12 04:30:32 -0400 (Mon, 12 Oct 2009)
New Revision: 94665
Modified:
projects/jbossmx/trunk/jmx/src/main/org/jboss/mx/server/registry/BasicMBeanRegistry.java
projects/jbossmx/trunk/mbeans/src/main/org/jboss/mx/metadata/MBeanCapability.java
Log:
Remove useless instance creation, as all we need is an int.
Modified: projects/jbossmx/trunk/jmx/src/main/org/jboss/mx/server/registry/BasicMBeanRegistry.java
===================================================================
--- projects/jbossmx/trunk/jmx/src/main/org/jboss/mx/server/registry/BasicMBeanRegistry.java 2009-10-12 07:10:40 UTC (rev 94664)
+++ projects/jbossmx/trunk/jmx/src/main/org/jboss/mx/server/registry/BasicMBeanRegistry.java 2009-10-12 08:30:32 UTC (rev 94665)
@@ -190,17 +190,16 @@
throw new RuntimeOperationsException(
new IllegalArgumentException("Attempting to register null object"));
- // get mbean type, dynamic or standard
- MBeanCapability mbcap = MBeanCapability.of(object.getClass());
-
try
{
if (valueMap != null)
magicToken = (String) valueMap.get(JMI_DOMAIN);
+ // get mbean type, dynamic or standard
+ int mbeanType = MBeanCapability.of(object.getClass());
+
// TODO: allow custom factory for diff invoker types
- int mbeanType = mbcap.getMBeanType();
if (mbeanType == MBeanCapability.STANDARD_MBEAN)
{
invoker = new XMBean(object, XMBeanConstants.STANDARD_MBEAN);
Modified: projects/jbossmx/trunk/mbeans/src/main/org/jboss/mx/metadata/MBeanCapability.java
===================================================================
--- projects/jbossmx/trunk/mbeans/src/main/org/jboss/mx/metadata/MBeanCapability.java 2009-10-12 07:10:40 UTC (rev 94664)
+++ projects/jbossmx/trunk/mbeans/src/main/org/jboss/mx/metadata/MBeanCapability.java 2009-10-12 08:30:32 UTC (rev 94665)
@@ -52,6 +52,7 @@
*
* @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
* @author thomas.diesler at jboss.org
+ * @author ales.justin at jboss.org
*/
public class MBeanCapability
{
@@ -59,20 +60,12 @@
public static final int STANDARD_MBEAN = 0x123;
public static final int NOT_AN_MBEAN = 0xc0de;
- protected int mbeanType = NOT_AN_MBEAN;
-
- private MBeanCapability(int type)
+ private MBeanCapability()
{
- mbeanType = type;
}
- public int getMBeanType()
+ public static int of(Class<?> mbeanClass) throws NotCompliantMBeanException
{
- return mbeanType;
- }
-
- public static MBeanCapability of(Class<?> mbeanClass) throws NotCompliantMBeanException
- {
if (null == mbeanClass)
{
throw new IllegalArgumentException("MBean class cannot be null");
@@ -81,21 +74,22 @@
// If MyClass is an instance of the DynamicMBean interface, MyClass is a dynamic MBean.
if (DynamicMBean.class.isAssignableFrom(mbeanClass))
{
- return new MBeanCapability(DYNAMIC_MBEAN);
+ return DYNAMIC_MBEAN;
}
// Class is annotated with @MBean
if (mbeanClass.isAnnotationPresent(MBean.class))
- return new MBeanCapability(STANDARD_MBEAN);
+ {
+ return STANDARD_MBEAN;
+ }
// If the MyClass MBean is an instance of a MyClassMBean interface, MyClass is a standard MBean
Class<?> [] interfaces = mbeanClass.getInterfaces();
- for (int i = 0; i < interfaces.length; i++)
+ for (Class<?> anInterface : interfaces)
{
- Class<?> anInterface = interfaces[i];
if (anInterface.getName().equals(mbeanClass.getName() + "MBean"))
{
- return new MBeanCapability(STANDARD_MBEAN);
+ return STANDARD_MBEAN;
}
}
@@ -106,5 +100,4 @@
throw new NotCompliantMBeanException("Class does not expose a management interface: " + mbeanClass.getName());
}
-
}
More information about the jboss-cvs-commits
mailing list