Java Reference
In-Depth Information
public DynamicMBeanSupport()
{
addMBeanAttribute( "description" , "java.lang.String",
true, true, false, "Description of the MBean");
addMBeanConstructor( this.getClass().getConstructors()[0],
"Default Constructor" );
}
public Object invoke( String method, Object args[],
String types[] )
throws MBeanException, ReflectionException
{
try
{
Class c = this.getClass();
Class sig[] = null;
if( types != null )
{
sig = new Class[ types.length ];
for( int i = 0; i < types.length; i++ )
{
sig[i] = Class.forName( types[i] );
}
}
Method m = c.getDeclaredMethod( method , sig );
Object returnObject = ( Object ) m.invoke( this, args );
return returnObject;
}
catch( Exception e )
{
e.printStackTrace();
return null;
}
}
Begin building
MBeanInfo object
public Object getAttribute( String name )
throws MBeanException, AttributeNotFoundException,
ReflectionException
{
try
{
Class c = this.getClass();
Method m = c.getDeclaredMethod( "get" + name, null );
return m.invoke( ( Object ) this, null );
}
catch( Exception e )
{
e.printStackTrace();
return null;
}
}
Implement
DynamicMBean
interface
B
Search WWH ::




Custom Search