Search in sources :

Example 6 with ScanState

use of com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState in project jdk8u_jdk by JetBrains.

the class DirectoryScannerTest method testGetState.

/**
     * Test of getState method, of class com.sun.jmx.examples.scandir.DirectoryScanner.
     */
public void testGetState() {
    System.out.println("getState");
    final DirectoryScannerConfig bean = new DirectoryScannerConfig("test");
    bean.setRootDirectory(System.getProperty("java.io.tmpdir"));
    final ResultLogManager log = new ResultLogManager();
    DirectoryScanner instance = new DirectoryScanner(bean, log);
    ScanState expResult = STOPPED;
    ScanState result = instance.getState();
    assertEquals(STOPPED, result);
    instance.scan();
    result = instance.getState();
    assertEquals(COMPLETED, result);
}
Also used : DirectoryScannerConfig(com.sun.jmx.examples.scandir.config.DirectoryScannerConfig) ScanState(com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState)

Example 7 with ScanState

use of com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState in project jdk8u_jdk by JetBrains.

the class DirectoryScanner method setStateAndNotify.

// Switch this object state to the desired value an send
// a notification. Don't call this method from within a
// synchronized block!
//
private final void setStateAndNotify(ScanState desired) {
    final ScanState old = state;
    if (old == desired)
        return;
    state = desired;
    final AttributeChangeNotification n = new AttributeChangeNotification(this, getNextSeqNumber(), System.currentTimeMillis(), "state change", "State", ScanState.class.getName(), String.valueOf(old), String.valueOf(desired));
    broadcaster.sendNotification(n);
}
Also used : AttributeChangeNotification(javax.management.AttributeChangeNotification) ScanState(com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState)

Aggregations

ScanState (com.sun.jmx.examples.scandir.ScanManagerMXBean.ScanState)7 AttributeChangeNotification (javax.management.AttributeChangeNotification)3 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)2 Notification (javax.management.Notification)2 NotificationEmitter (javax.management.NotificationEmitter)2 NotificationFilter (javax.management.NotificationFilter)2 NotificationListener (javax.management.NotificationListener)2 DirectoryScannerConfig (com.sun.jmx.examples.scandir.config.DirectoryScannerConfig)1 IOException (java.io.IOException)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 JMException (javax.management.JMException)1 ListenerNotFoundException (javax.management.ListenerNotFoundException)1