Crossfire JXClient, Trunk
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
com.sun.jmx.examples.scandir.ScanDirAgent Class Reference
Collaboration diagram for com.sun.jmx.examples.scandir.ScanDirAgent:
Collaboration graph

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
 

Detailed Description

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).

Author
Sun Microsystems, 2006 - All rights reserved.

Definition at line 76 of file ScanDirAgent.java.

Constructor & Destructor Documentation

◆ ScanDirAgent()

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.

See also
main

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().

Here is the caller graph for this function:

Member Function Documentation

◆ cleanup()

void com.sun.jmx.examples.scandir.ScanDirAgent.cleanup ( ) throws IOException, JMException

Cleanup after close: unregister the ScanManagerMXBean singleton.

Exceptions
java.io.IOExceptionCleanup failed for communication-related reasons.
javax.management.JMExceptionCleanup 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.

◆ init()

void com.sun.jmx.examples.scandir.ScanDirAgent.init ( ) throws IOException, JMException

Initialize the application by registering a ScanManagerMXBean in the platform MBeanServer

Exceptions
java.io.IOExceptionRegistration failed for communication-related reasons.
javax.management.JMExceptionRegistration 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().

Here is the call graph for this function:

◆ main()

static void com.sun.jmx.examples.scandir.ScanDirAgent.main ( String[]  args) throws IOException, JMException
static

◆ waitForClose()

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.

Exceptions
java.io.IOExceptionwait failed - a communication problem occurred.
javax.management.JMExceptionwait 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.

Here is the call graph for this function:

Member Data Documentation

◆ listener

final NotificationListener com.sun.jmx.examples.scandir.ScanDirAgent.listener
private

◆ LOG

final Logger com.sun.jmx.examples.scandir.ScanDirAgent.LOG
staticprivate
Initial value:
=
Logger.getLogger(ScanDirAgent.class.getName())

A logger for this class.

Definition at line 81 of file ScanDirAgent.java.

Referenced by com.sun.jmx.examples.scandir.ScanDirAgent.ScanDirAgent().

◆ proxy

volatile ScanManagerMXBean com.sun.jmx.examples.scandir.ScanDirAgent.proxy = null
private

◆ queue

final BlockingQueue<Notification> com.sun.jmx.examples.scandir.ScanDirAgent.queue
private

The documentation for this class was generated from the following file:
com.sun.jmx.examples.scandir.ScanDirAgent.ScanDirAgent
ScanDirAgent()
Definition: ScanDirAgent.java:102