Java Reference
In-Depth Information
In this case, the class CopierPrinter does not directly implement an MBean inter-
face. However, its super class, Printer , does implement the PrinterMBean interface.
The CopierPrinter class therefore is a PrinterMBean : it inherits the management
interface of its super class.
This technique is useful if you want to change the behavior of an MBean but
keep the interface unchanged. When you inherit the interface, you cannot add to
it, but you can override methods in order to provide a new implementation in
the subclass.
Keep in mind that the CopierPrinter class must still follow the other MBean
rules. Thus it must not be an abstract class, and it must provide a public con-
structor because constructors cannot be inherited.
4.3.3
Overriding the management interface
The previous case mentioned overriding methods from an inherited MBean
interface implementation. This scenario shows you how to override a manage-
ment interface entirely with a new one (see figure 4.3).
Remember that one of the rules for writing an MBean is that it can only
implement a single MBean interface. However, notice in this case that both the
Printer and CopierPrinter classes implement an MBean interface. In this sce-
nario, the CopierPrinterMBean interface replaces the management interface of
the PrinterMBean interface. The CopierPrinter class still inherits the methods
and implementation from its super class, but JMX agents will not recognize those
methods as part of the CopierPrinter MBean's management interface. Only the
Figure 4.3
Overriding a management
interface inherited from a
super class. The
management interface of
the CopierPrinter
MBean is declared by the
CopierPrinterMBean
interface. Nothing from the
super class or the
PrinterMBean interface
is used.
Search WWH ::




Custom Search