1 package jfun.yan.xml.nuts; 2 3 import jfun.yan.Component; 4 5 6 12 public class BeanNut extends ConstructorNut 13 implements LifecycleDeclaration{ 14 private static final Class [] no_params = {}; 15 private Component cc; 16 private void checkComponentClass(Object 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 type){ 31 checkComponentClass(cc); 32 super.setClass(type); 33 } 36 37 protected boolean isBeanByDefault(){ 38 return true; 39 } 40 44 protected Component evaluateNoLifecycle(){ 45 if(cc==null){ 54 if(getParameterTypes()==null && getMaxArgsCount()<0){ 55 super.setParams(no_params); 56 } 57 this.cc = super.evaluateNoLifecycle(); 58 } 59 else{ 60 this.cc = decorateComponent(this.cc); 62 } 63 return this.cc; 64 } 66 } 67 | Popular Tags |