KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.directwebremoting.dwrp;
2
3 import org.directwebremoting.ScriptBuffer;
4 import org.directwebremoting.extend.ScriptConduit;
5 import org.directwebremoting.util.Logger;
6
7 /**
8  * Implementation of ScriptConduit that simply calls <code>notifyAll()</code>
9  * if a script is added.
10  * No actual script adding is done here.
11  * Useful in conjunction with a streamWait()
12  */

13 public class NotifyOnlyScriptConduit extends ScriptConduit
14 {
15     /**
16      * @param lock Object to wait and notifyAll with
17      */

18     public NotifyOnlyScriptConduit(Object JavaDoc lock)
19     {
20         super(RANK_PROCEDURAL);
21         this.lock = lock;
22     }
23
24     /* (non-Javadoc)
25      * @see org.directwebremoting.ScriptConduit#addScript(org.directwebremoting.ScriptBuffer)
26      */

27     public boolean addScript(ScriptBuffer script)
28     {
29         try
30         {
31             synchronized (lock)
32             {
33                 lock.notifyAll();
34             }
35         }
36         catch (Exception JavaDoc ex)
37         {
38             log.warn("Failed to notify all ScriptSession users", ex);
39         }
40
41         // We have not done anything with the script, so
42
return false;
43     }
44
45     /**
46      * The object to notify lock holders on
47      */

48     private final Object JavaDoc lock;
49
50     /**
51      * The log stream
52      */

53     private static final Logger log = Logger.getLogger(NotifyOnlyScriptConduit.class);
54 }
Popular Tags