Java Reference
In-Depth Information
B
The JINIServiceManager Dynamic MBean doesn't provide much of an imple-
mentation for the get and set attribute methods. By examining the manage-
ment interface of this MBean exposed by its getMBeanInfo() method, you can
see that it does not expose any attributes. Therefore, the MBean should not sup-
port any methods that read or write attributes. In fact, both the getAttribute()
and setAttribute() methods throw an AttributeNotFoundException exception
when invoked.
Because this MBean is intended to manage the Jini service that created it, it must
be able to find that service. The MBean's constructor accepts a single argument:
an Entry object that initially identifies the Jini service. The MBean also expects
the Jini service to implement the jmxbook.ch5.ManagedJINIService interface. The
MBean uses the interface, combined with the Entry object, to identify the Jini
service. The lookUpService() method uses an object called RegistryFinder to find
the nearest service registry. You should replace the implementation of this method
with your own.
This example does not expose any operations or attributes from the Jini ser-
vice; instead, it exposes the view of the Jini service.
C
5.5.2
Rebuilding a management interface at runtime
As described earlier in this chapter, Dynamic MBeans provide their management
interface at runtime. This ability equips Dynamic MBeans to manage evolving
resources over time. Developers can easily adapt Dynamic MBeans as their
resources change. However, wouldn't it be useful to have an MBean that is truly
dynamic? Consider the Dynamic MBean that reads a flat file to determine which
of its manageable resource's methods to expose.
The MBean could monitor its flat file and watch for changes. When it detects
a change, it could reload the file, rebuild its management interface (by creating a
new MBeanInfo return value for the getMBeanInfo() method), and be ready to
manage its resource in an entirely new way. However, this approach would pose a
few problems.
Each time you tried using this Dynamic MBean, the attribute or operation
you were trying to access could be different (or missing!). In fact, in order to
ensure that you would not be incorrectly using a management interface, you
would have to reacquire before every attempt.
JMX agents are not required by the JMX specification to ensure that a man-
agement interface does not change over the lifetime of an MBean. However, the
Search WWH ::




Custom Search