| Base class for chained MBeanServerBuilders.
By default this class delegates all method calls to the nested
MBeanServerBuilder.
See the MX4J documentation on how to use correctly this class.
Example implementation:
public class LoggingBuilder extends ChainedMBeanServerBuilder
{
public LoggingBuilder()
{
super(new MBeanServerBuilder());
}
public MBeanServer newMBeanServer(String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate)
{
LoggingMBeanServer external = new LoggingMBeanServer();
MBeanServer nested = getBuilder().newMBeanServer(defaultDomain, outer == null ? external : outer, delegate);
external.setMBeanServer(nested);
return external;
}
}
public class LoggingMBeanServer extends ChainedMBeanServer
{
protected void setMBeanServer(MBeanServer server)
{
super.setMBeanServer(server);
}
public Object getAttribute(ObjectName objectName, String attribute)
throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
{
Object value = super.getAttribute(objectName, attribute);
System.out.println("Value is: " + value);
return value;
}
...
}
author: Marc Wick version: 1.0 |