From a945a30a37d87cfd04008c36f3e1316c1cc44b5b Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Thu, 2 Aug 2012 16:47:56 -0500 Subject: [PATCH] remove lazy list usage and remove mbean container in simple test --- .../org/eclipse/jetty/jmx/ObjectMBean.java | 45 +++++++++---------- .../eclipse/jetty/jmx/ObjectMBeanTest.java | 6 --- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java index 00cd6c9fca4..50427efd7da 100644 --- a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java +++ b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java @@ -20,15 +20,14 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.ArrayList; import java.util.Collection; -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.Locale; +import java.util.List; import java.util.Map; import java.util.MissingResourceException; -import java.util.ResourceBundle; import java.util.Set; import javax.management.Attribute; @@ -47,7 +46,6 @@ import javax.management.ObjectName; import javax.management.ReflectionException; import javax.management.modelmbean.ModelMBean; -import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.annotation.ManagedAttribute; @@ -226,25 +224,25 @@ public class ObjectMBean implements DynamicMBean { // Start with blank lazy lists attributes etc. String desc=null; - Object attributes=null; - Object constructors=null; - Object operations=null; - Object notifications=null; + List attributes = new ArrayList(); + List constructors = new ArrayList(); + List operations = new ArrayList(); + List notifications = new ArrayList(); // Find list of classes that can influence the mbean Class o_class=_managed.getClass(); - Object influences = findInfluences(null, _managed.getClass()); + List> influences = findInfluences(new ArrayList>(), _managed.getClass()); - LOG.debug("Influence Count: " + LazyList.size(influences) ); + LOG.debug("Influence Count: " + influences.size() ); // Process Type Annotations ManagedObject primary = o_class.getAnnotation( ManagedObject.class); desc = primary.value(); // For each influence - for (int i=0;i oClass = (Class)LazyList.get(influences, i); + Class oClass = influences.get(i); ManagedObject typeAnnotation = oClass.getAnnotation( ManagedObject.class); @@ -266,7 +264,7 @@ public class ObjectMBean implements DynamicMBean if ( fieldAnnotation != null ) { LOG.debug("Field Annotation found for: " + field.getName() ); - attributes=LazyList.add(attributes, defineAttribute(field.getName(), fieldAnnotation)); + attributes.add( defineAttribute(field.getName(), fieldAnnotation)); } } @@ -280,7 +278,7 @@ public class ObjectMBean implements DynamicMBean { // TODO sort out how a proper name could get here, its a method name as an attribute at this point. LOG.debug("Attribute Annotation found for: " + method.getName() ); - attributes=LazyList.add(attributes,defineAttribute(method.getName(),methodAttributeAnnotation)); + attributes.add(defineAttribute(method.getName(),methodAttributeAnnotation)); } ManagedOperation methodOperationAnnotation = method.getAnnotation(ManagedOperation.class); @@ -288,7 +286,7 @@ public class ObjectMBean implements DynamicMBean if (methodOperationAnnotation != null) { LOG.debug("Method Annotation found for: " + method.getName()); - operations = LazyList.add(operations,defineOperation(method,methodOperationAnnotation)); + operations.add(defineOperation(method,methodOperationAnnotation)); } } @@ -301,10 +299,10 @@ public class ObjectMBean implements DynamicMBean _info = new MBeanInfo(o_class.getName(), desc, - (MBeanAttributeInfo[])LazyList.toArray(attributes, MBeanAttributeInfo.class), - (MBeanConstructorInfo[])LazyList.toArray(constructors, MBeanConstructorInfo.class), - (MBeanOperationInfo[])LazyList.toArray(operations, MBeanOperationInfo.class), - (MBeanNotificationInfo[])LazyList.toArray(notifications, MBeanNotificationInfo.class)); + (MBeanAttributeInfo[])attributes.toArray(), + (MBeanConstructorInfo[])constructors.toArray(), + (MBeanOperationInfo[])operations.toArray(), + (MBeanNotificationInfo[])notifications.toArray()); } } catch(RuntimeException e) @@ -516,12 +514,12 @@ public class ObjectMBean implements DynamicMBean } } - private static Object findInfluences(Object influences, Class aClass) - { + private static List> findInfluences(List> influences, Class aClass) + { if (aClass!=null) { // This class is an influence - influences=LazyList.add(influences,aClass); + influences.add(aClass); // check for mbean influence ManagedObject mo = aClass.getAnnotation(ManagedObject.class); @@ -535,7 +533,7 @@ public class ObjectMBean implements DynamicMBean Class mbean = Class.forName(clazz); LOG.debug("MBean Influence found for " + aClass.getSimpleName() ); - influences = LazyList.add(influences, mbean); + influences.add(mbean); } catch ( ClassNotFoundException cnfe ) { @@ -551,6 +549,7 @@ public class ObjectMBean implements DynamicMBean for (int i=0;ifs!=null && i