Crossfire JXClient, Trunk
|
Public Member Functions | |
void | cleanup () throws IOException, JMException |
void | init () throws IOException, JMException |
ScanDirAgent () | |
void | waitForClose () throws IOException, JMException |
Static Public Member Functions | |
static void | main (String[] args) throws IOException, JMException |
Private Attributes | |
final NotificationListener | listener |
volatile ScanManagerMXBean | proxy = null |
final BlockingQueue< Notification > | queue |
Static Private Attributes | |
static final Logger | LOG |
The ScanDirAgent
is the Agent class for the scandir application. This class contains the main method to start a standalone scandir application.
The main() method simply registers a {} in the platform MBeanServer - see #init init}, and then waits for someone to call ScanManagerMXBean#close close} on that MBean.
When the ScanManagerMXBean state is switched to {CLOSED}, #cleanup cleanup} is called, the ScanManagerMXBean} is unregistered, and the application terminates (i.e. the main thread completes).
Definition at line 76 of file ScanDirAgent.java.
com.sun.jmx.examples.scandir.ScanDirAgent.ScanDirAgent | ( | ) |
Creates a new instance of ScanDirAgent You will need to call init() later on in order to initialize the application.
Definition at line 102 of file ScanDirAgent.java.
References com.sun.jmx.examples.scandir.ScanDirAgent.listener, com.sun.jmx.examples.scandir.ScanDirAgent.LOG, and com.sun.jmx.examples.scandir.ScanDirAgent.queue.
Referenced by com.sun.jmx.examples.scandir.ScanDirAgent.main().
void com.sun.jmx.examples.scandir.ScanDirAgent.cleanup | ( | ) | throws IOException, JMException |
Cleanup after close: unregister the ScanManagerMXBean singleton.
java.io.IOException | Cleanup failed for communication-related reasons. |
javax.management.JMException | Cleanup failed for JMX-related reasons. |
Definition at line 147 of file ScanDirAgent.java.
References com.sun.jmx.examples.scandir.ScanDirAgent.listener, com.sun.jmx.examples.scandir.ScanDirAgent.proxy, and com.sun.jmx.examples.scandir.ScanManager.SCAN_MANAGER_NAME.
void com.sun.jmx.examples.scandir.ScanDirAgent.init | ( | ) | throws IOException, JMException |
Initialize the application by registering a ScanManagerMXBean in the platform MBeanServer
java.io.IOException | Registration failed for communication-related reasons. |
javax.management.JMException | Registration failed for JMX-related reasons. |
Definition at line 129 of file ScanDirAgent.java.
References com.sun.jmx.examples.scandir.ScanDirAgent.listener, com.sun.jmx.examples.scandir.ScanDirAgent.proxy, and com.sun.jmx.examples.scandir.ScanManager.register().
|
static |
The agent's main: registers a ScanManagerMXBean, waits until its state is {CLOSED}, #cleanup cleanup} and exits. args the command line arguments - ignored java.io.IOException A communication problem occurred. javax.management.JMException A JMX problem occurred.
Definition at line 209 of file ScanDirAgent.java.
References agent, and com.sun.jmx.examples.scandir.ScanDirAgent.ScanDirAgent().
void com.sun.jmx.examples.scandir.ScanDirAgent.waitForClose | ( | ) | throws IOException, JMException |
Wait for someone to call 'close()' on the ScanManagerMXBean singleton. Every time its state changes, the ScanManagerMXBean emits a notification. We don't rely on the notification content (if we were using a remote connection, we could miss some notifications) - we simply use the state change notifications to react more quickly to state changes. We do so simply by polling the BlockingQueue in which our listener is pushing notifications, and checking the ScanManagerMXBean state every time that a notification is received.
We can do so because we know that once the ScanManagerMXBean state is switched to 'CLOSED', it will remain 'CLOSED' whatsoever.
Therefore we don't need to concern ourselves with the possibility of missing the window in which the ScanManagerMXBean state's will be CLOSED, because that particular window stays opened forever.
Had we wanted to wait for 'RUNNING', we would have needed to apply a different strategy - e.g. by taking into account the actual content of the state changed notifications we received.
java.io.IOException | wait failed - a communication problem occurred. |
javax.management.JMException | wait failed - the MBeanServer threw an exception. |
Definition at line 179 of file ScanDirAgent.java.
References com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState.CLOSED, com.sun.jmx.examples.scandir.ScanManagerMXBean.getState(), com.sun.jmx.examples.scandir.ScanDirAgent.proxy, and com.sun.jmx.examples.scandir.ScanDirAgent.queue.
|
private |
Definition at line 94 of file ScanDirAgent.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirAgent.cleanup(), com.sun.jmx.examples.scandir.ScanDirAgent.init(), and com.sun.jmx.examples.scandir.ScanDirAgent.ScanDirAgent().
|
staticprivate |
A logger for this class.
Definition at line 81 of file ScanDirAgent.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirAgent.ScanDirAgent().
|
private |
Definition at line 86 of file ScanDirAgent.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirAgent.cleanup(), com.sun.jmx.examples.scandir.ScanDirAgent.init(), and com.sun.jmx.examples.scandir.ScanDirAgent.waitForClose().
|
private |
Definition at line 90 of file ScanDirAgent.java.
Referenced by com.sun.jmx.examples.scandir.ScanDirAgent.ScanDirAgent(), and com.sun.jmx.examples.scandir.ScanDirAgent.waitForClose().