KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > dwrp > NotifyWaitController


1 package org.directwebremoting.dwrp;
2
3 import org.directwebremoting.extend.WaitController;
4 import org.directwebremoting.util.Logger;
5
6 /**
7  * A {@link WaitController} that works with {@link Object#wait(long)}
8  * @author Joe Walker [joe at getahead dot ltd dot uk]
9  */

10 public class NotifyWaitController implements WaitController
11 {
12     /**
13      * @param lock
14      */

15     public NotifyWaitController(Object JavaDoc lock)
16     {
17         this.lock = lock;
18     }
19
20     /* (non-Javadoc)
21      * @see org.directwebremoting.extend.WaitController#shutdown()
22      */

23     public void shutdown()
24     {
25         try
26         {
27             synchronized (lock)
28             {
29                 lock.notifyAll();
30             }
31         }
32         catch (Exception JavaDoc ex)
33         {
34             log.warn("Failed to notify all ScriptSession users", ex);
35         }
36
37         shutdown = true;
38     }
39
40     /* (non-Javadoc)
41      * @see org.directwebremoting.extend.WaitController#isShutdown()
42      */

43     public boolean isShutdown()
44     {
45         return shutdown;
46     }
47
48     /**
49      * The object that is being {@link Object#wait(long)} on so we can
50      * move it on with {@link Object#notifyAll()}.
51      */

52     private Object JavaDoc lock;
53
54     /**
55      * The log stream
56      */

57     private static final Logger log = Logger.getLogger(NotifyWaitController.class);
58
59     /**
60      * Has {@link #shutdown()} been called on this object?
61      */

62     private boolean shutdown = false;
63 }
Popular Tags