1 package jfun.yan.nuts.annotations; 2 3 import java.beans.IntrospectionException ; 4 import java.lang.annotation.Annotation ; 5 6 import jfun.yan.Component; 7 import jfun.yan.Components; 8 import jfun.yan.xml.nuts.BeanNut; 9 10 public class AnnotationAwareBeanNut extends BeanNut { 11 private Class <? extends Annotation > annotation = Inject.class; 12 13 public Class <? extends Annotation > getAnnotation() { 14 return annotation; 15 } 16 17 public void setAnnotation(Class <? extends Annotation > annotation) { 18 this.annotation = annotation; 19 } 20 protected boolean isBeanByDefault(){ 21 return true; 22 } 23 protected Component defineBean(Component c, boolean isAll) 24 throws IntrospectionException { 25 if(!isAll){ 26 if(annotation!=null && 27 super.getPropertyAutowireMode() != null && super.getPropertyNames()==null){ 28 return Components.makeBean(c, 31 AnnotationFilteredPropertiesInjector.instance(c.getType(), annotation)); 32 } 33 } 34 return super.defineBean(c, isAll); 35 } 36 } 37 | Popular Tags |