KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > xml > SynchronizedNutsFunction


1 package jfun.yan.xml;
2
3 /**
4  * A synchronization wrapper for NutsFunction.
5  * Calls through this class are synchronized.
6  * <p>
7  * @author Ben Yu
8  * Nov 27, 2005 11:50:32 AM
9  */

10 public class SynchronizedNutsFunction
11 extends DelegatingNutsFunction {
12   
13   /**
14    * To create a SynchronizedNutsFunction object.
15    * @param fun the NutsFunction object to synchronize access to.
16    */

17   public SynchronizedNutsFunction(NutsFunction fun) {
18     super(fun);
19   }
20
21   /**
22    * synchronize against "this", then forward the call
23    * to the delegate target.
24    */

25   public synchronized Object JavaDoc call(Object JavaDoc[] args) {
26     return super.call(args);
27   }
28
29   public boolean equals(Object JavaDoc obj) {
30     if(obj instanceof SynchronizedNutsFunction){
31       SynchronizedNutsFunction other = (SynchronizedNutsFunction)obj;
32       final NutsFunction fun = getDelegateTarget();
33       final NutsFunction fun2 = other.getDelegateTarget();
34       return fun==null?fun2==null:fun.equals(fun2);
35     }
36     else return false;
37   }
38   
39 }
40
Popular Tags