remove lazy list usage and remove mbean container in simple test
This commit is contained in:
parent
373526f8ca
commit
a945a30a37
|
@ -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<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
|
||||
List<MBeanConstructorInfo> constructors = new ArrayList<MBeanConstructorInfo>();
|
||||
List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>();
|
||||
List<MBeanNotificationInfo> notifications = new ArrayList<MBeanNotificationInfo>();
|
||||
|
||||
// Find list of classes that can influence the mbean
|
||||
Class<?> o_class=_managed.getClass();
|
||||
Object influences = findInfluences(null, _managed.getClass());
|
||||
List<Class<?>> influences = findInfluences(new ArrayList<Class<?>>(), _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<LazyList.size(influences);i++)
|
||||
for (int i=0;i<influences.size();i++)
|
||||
{
|
||||
Class<?> 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<Class<?>> findInfluences(List<Class<?>> 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<ifs.length;i++)
|
||||
influences=findInfluences(influences,ifs[i]);
|
||||
}
|
||||
|
||||
return influences;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,14 +44,8 @@ public class ObjectMBeanTest
|
|||
@Test
|
||||
public void testMbeanInfo() throws Exception
|
||||
{
|
||||
MBeanContainer container = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
|
||||
|
||||
container.start();
|
||||
|
||||
Derived derived = new Derived();
|
||||
//ObjectMBean mbean = new ObjectMBean(derived);
|
||||
ObjectMBean mbean = (ObjectMBean)ObjectMBean.mbeanFor(derived);
|
||||
mbean.setMBeanContainer(container);
|
||||
|
||||
assertTrue(mbean.getMBeanInfo()!=null);
|
||||
|
||||
|
|
Loading…
Reference in New Issue