KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > nuts > annotations > AnnotationAwareBeanNut


1 package jfun.yan.nuts.annotations;
2
3 import java.beans.IntrospectionException JavaDoc;
4 import java.lang.annotation.Annotation JavaDoc;
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 JavaDoc<? extends Annotation JavaDoc> annotation = Inject.class;
12
13   public Class JavaDoc<? extends Annotation JavaDoc> getAnnotation() {
14     return annotation;
15   }
16
17   public void setAnnotation(Class JavaDoc<? extends Annotation JavaDoc> 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 JavaDoc{
25     if(!isAll){
26       if(annotation!=null &&
27           super.getPropertyAutowireMode() != null && super.getPropertyNames()==null){
28         //autowiring
29
//no property names specified
30
return Components.makeBean(c,
31             AnnotationFilteredPropertiesInjector.instance(c.getType(), annotation));
32       }
33     }
34     return super.defineBean(c, isAll);
35   }
36 }
37
Popular Tags