|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
Package javax.management.modelmbeanProvides the definition of the ModelMBean classes.
See:
Package javax.management.modelmbean Description
Provides the definition of the ModelMBean classes. A Model MBean is an MBean that acts as a bridge between the management interface and the underlying managed resource. Both the management interface and the managed resource are specified as Java objects. The same Model MBean implementation can be reused many times with different management interfaces and managed resources, and it can provide common functionality such as persistence and caching. A Model MBean implements the Every MBean has an The class The following example shows a Model MBean being used to make
the import java.lang.reflect.Method; import java.util.HashMap; import javax.management.*; import javax.management.modelmbean.*; // ... MBeanServer mbs = MBeanServerFactory.createMBeanServer(); // The MBean Server HashMap map = new HashMap(); // The resource that will be managed // Construct the management interface for the Model MBean Method getMethod = HashMap.class.getMethod("get", new Class[] {Object.class}); ModelMBeanOperationInfo getInfo = new ModelMBeanOperationInfo("Get value for key", getMethod); ModelMBeanInfo mmbi = new ModelMBeanInfoSupport(HashMap.class.getName(), "Map of keys and values", null, // no attributes null, // no constructors new ModelMBeanOperationInfo[] {getInfo}, null); // no notifications // Make the Model MBean and link it to the resource ModelMBean mmb = new RequiredModelMBean(mmbi); mmb.setManagedResource(map, "ObjectReference"); // Register the Model MBean in the MBean Server ObjectName mapName = new ObjectName(":type=Map,name=whatever"); mbs.registerMBean(mmb, mapName); // Resource can evolve independently of the MBean map.put("key", "value"); // Can access the "get" method through the MBean Server mbs.invoke(mapName, "get", new Object[] {"key"}, new String[] {Object.class.getName()}); // returns "value" Package Specification
Copyright 2003 Sun Microsystems, Inc. All rights reserved
|