Java Reference
In-Depth Information
theater system, but it will also provide access into the system for outside manage-
ment tools.
13.3.1
Writing the example
For this example, you will use the JBoss open-source
J2EE
container as the pro-
vider for
JMS
. You will configure the JBoss environment after writing all the code.
Fo r t h i s
JMS
system, you need to configure two
topics
for message publishing. The
system has one topic called
controlMessages
and another called
deviceMessages
.
The MBean will subscribe to the
controlMessages
topic in order to observe
lighting commands from the remote control. The debugging client (
IR
signal
transmitter) for the devices will subscribe to the
deviceMessages
topic. When the
MBean recognizes the
MOVIELIGHTSOn
control message, it will publish the
Sur-
roundOn
and
ScreenDown
messages to the
deviceMessages
topic. Alternatively,
when the MBean sees the
MOVIELIGHTSOff
message, it will send the
SurroundOff
and
ScreenUp
device messages.
The following list shows the tasks you must complete to construct this example:
■
Create the application's MBean.
■
Construct the
IR
signal transmitter (your debugger).
■
Write the setup class to register the MBean in a
JMX
agent.
■
Construct the
IR
signal processor (your publisher).
The next section begins the example by constructing the controller MBean.
Constructing the main controller MBean
The MBean for this application will listen to all messages published to the
con-
trolMessages
topic. It will make decisions based on the messages received and
publish messages to each device in order to complete a designated macro. In
addition, its management interface will provide direct access to its macros for a
management application. Listing 13.1 shows the interface for the MBean.
Listing 13.1
JMSControllerMBean.java
package jmxbook.ch13;
public interface JMSControllerMBean
{
public void turnOnHomeTheater();
public void turnOffHomeTheater();
}