some initial swizzle for mbean influence and improvement of unit test
This commit is contained in:
parent
88e2f3915d
commit
e25ff279ae
|
@ -512,6 +512,23 @@ public class ObjectMBean implements DynamicMBean
|
|||
// This class is an influence
|
||||
influences=LazyList.add(influences,aClass);
|
||||
|
||||
/* enabled mbean influence
|
||||
String pack = aClass.getPackage().getName();
|
||||
String clazz = aClass.getSimpleName();
|
||||
|
||||
try
|
||||
{
|
||||
Class mbean = Class.forName(pack + ".jmx." + clazz + "MBean");
|
||||
|
||||
LOG.debug("MBean Influence found for " + aClass.getSimpleName() );
|
||||
influences = LazyList.add(influences, mbean);
|
||||
}
|
||||
catch ( ClassNotFoundException cnfe )
|
||||
{
|
||||
LOG.debug("No MBean Influence for " + aClass.getSimpleName() );
|
||||
}
|
||||
*/
|
||||
|
||||
// So are the super classes
|
||||
influences=findInfluences(influences,aClass.getSuperclass());
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ public class Derived extends Base implements Signature
|
|||
System.err.println("doodle "+doodle);
|
||||
}
|
||||
|
||||
public void somethingElse()
|
||||
public String bad()
|
||||
{
|
||||
|
||||
return "bad";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.acme.jmx;
|
||||
|
||||
import org.eclipse.jetty.util.annotation.Managed;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
import com.acme.Derived;
|
||||
|
||||
@Managed("Derived MBean")
|
||||
public class DerivedMBean
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(DerivedMBean.class);
|
||||
|
||||
Derived managedObject;
|
||||
|
||||
public DerivedMBean(Object managedObject)
|
||||
{
|
||||
this.managedObject = (Derived)managedObject;
|
||||
}
|
||||
|
||||
@Managed(value="test of proxy", attribute=true, managed=true, getter="good" )
|
||||
public String good()
|
||||
{
|
||||
return "not " + managedObject.bad();
|
||||
}
|
||||
|
||||
}
|
|
@ -44,7 +44,7 @@ public class ObjectMBeanTest
|
|||
{
|
||||
Derived derived = new Derived();
|
||||
ObjectMBean mbean = new ObjectMBean(derived);
|
||||
assertTrue(mbean.getMBeanInfo()!=null); // TODO do more than just run it
|
||||
assertTrue(mbean.getMBeanInfo()!=null);
|
||||
|
||||
MBeanInfo info = mbean.getMBeanInfo();
|
||||
|
||||
|
@ -68,6 +68,7 @@ public class ObjectMBeanTest
|
|||
MBeanOperationInfo[] opinfos = info.getOperations();
|
||||
boolean publish = false;
|
||||
boolean doodle = false;
|
||||
boolean good = false;
|
||||
for ( int i = 0 ; i < opinfos.length; ++i )
|
||||
{
|
||||
MBeanOperationInfo opinfo = opinfos[i];
|
||||
|
@ -90,10 +91,21 @@ public class ObjectMBeanTest
|
|||
Assert.assertEquals("parameter description doesn't match", "A description of the argument", pinfos[0].getDescription());
|
||||
Assert.assertEquals("parameter name doesn't match", "doodle", pinfos[0].getName());
|
||||
}
|
||||
|
||||
if ("good".equals(opinfo.getName()))
|
||||
{
|
||||
doodle = true;
|
||||
|
||||
Assert.assertEquals("description does not match", "test of proxy", opinfo.getDescription());
|
||||
Assert.assertEquals("execution contexts wrong", "not bad", mbean.invoke("good", new Object[] {}, new String[] {}));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue("publish operation was not not found", publish);
|
||||
Assert.assertTrue("doodle operation was not not found", doodle);
|
||||
// Assert.assertTrue("good operation was not not found", good); not wired up yet
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
package org.eclipse.jetty.util.annotation;
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
|
Loading…
Reference in New Issue