KickJava   Java API By Example, From Geeks To Geeks.

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


1 package jfun.yan.xml.nuts;
2
3 import jfun.yan.Component;
4
5
6 /**
7  * Nut class for <bean> tag.
8  * <p>
9  * @author Ben Yu
10  * Nov 9, 2005 11:39:54 PM
11  */

12 public class BeanNut extends ConstructorNut
13 implements LifecycleDeclaration{
14   private static final Class JavaDoc[] no_params = {};
15   private Component cc;
16   //private Class beanclass;
17
private void checkComponentClass(Object JavaDoc attr){
18     if(attr!=null){
19       throw raise("only one of component and class can be specified.");
20     }
21   }
22   public void setComponent(Component c){
23     checkComponentClass(getDeclaringClass());
24     this.cc = c;
25   }
26   public void add(Component c){
27     checkDuplicate("component", this.cc);
28     setComponent(c);
29   }
30   public void setClass(Class JavaDoc type){
31     checkComponentClass(cc);
32     super.setClass(type);
33     //this.beanclass = type;
34
//this.cc = Components.ctor(type, null);
35
}
36   
37   protected boolean isBeanByDefault(){
38     return true;
39   }
40   /**
41    * Evaluate the Component without applying life cycle.
42    * Subclass can call this method and apply customized lifecycle.
43    */

44   protected Component evaluateNoLifecycle(){
45     //first check the property names. no dup.
46
//do not check if they are real properties because the type
47
//may not represent the runtime type.
48
//then check the property values, they should not duplicate.
49
//then check the property values. they should be among the property names specified.
50
//if the resolution is manual wire, and if the property names are not specified,
51
//use the keys of the property values.
52
//if manual, all property names should have a property value unless optional is specified.
53
if(cc==null){
54       if(getParameterTypes()==null && getMaxArgsCount()<0){
55         super.setParams(no_params);
56       }
57       this.cc = super.evaluateNoLifecycle();
58     }
59     else{
60       //decorate the arguments.
61
this.cc = decorateComponent(this.cc);
62     }
63     return this.cc;
64     //return applyProperties(this.cc);
65
}
66 }
67
Popular Tags