KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > xml > nuts > BindNut


1 package jfun.yan.xml.nuts;
2
3 import jfun.yan.Binder;
4 import jfun.yan.Component;
5
6 /**
7  * Nut class for <bind> tag.
8  * <p>
9  * The "followup" attribute specifies if the binder is only intended to do some
10  * side-effect, and the object returned by the bound component is still used
11  * as return value.
12  * </p>
13  * <p>
14  * "followup"="true" allows mutual dependency on singleton because the return object
15  * can be cached in the singleton before the mutaion is executed.
16  * </p>
17  * <p>
18  * default value for "followup" is false.
19  * </p>
20  * <p>
21  * @author Ben Yu
22  * Nov 9, 2005 11:41:18 PM
23  */

24 public class BindNut extends DelegatingNut {
25   private Binder binder;
26   private boolean followup = false;
27   
28   public boolean isFollowup() {
29     return followup;
30   }
31
32   public void setFollowup(boolean followup) {
33     this.followup = followup;
34   }
35
36   public Binder getBinder() {
37     return binder;
38   }
39
40   public void setBinder(Binder binder) {
41     this.binder = binder;
42   }
43
44
45   public Component eval(){
46     final Component c1 = getMandatory();
47     checkMandatory("binder", binder);
48     return followup?c1.followedBy(binder):c1.bind(binder);
49   }
50
51 }
52
Popular Tags