@Target ( ElementType. TYPE)
@Retention ( RetentionPolicy. RUNTIME)
@Documented
@Scope ( "singleton" )
@Component
@Inherited
public @interface SingletonComponent {
@AliasFor ( annotation = Component. class , attribute = "value" )
String value ( ) default "" ;
String name ( ) default "" ;
}
@SingletonComponent ( value = "parent/controller" , name = "parent" )
public class ParentController {
}
@SingletonComponent ( value = "child/controller" )
public class ChildController extends ParentController {
}
public class AnswerApp {
public static void main ( String[ ] args) throws Exception {
System. out. println ( "ParentController getAnnotation @SingletonComponent: " + AnnotationUtils. getAnnotation ( ParentController. class , SingletonComponent. class ) ) ;
System. out. println ( "ChildController getAnnotation @SingletonComponent: " + AnnotationUtils. getAnnotation ( ChildController. class , SingletonComponent. class ) ) ;
System. out. println ( ) ;
System. out. println ( "ParentController findAnnotation @SingletonComponent: " + AnnotationUtils. findAnnotation ( ParentController. class , SingletonComponent. class ) ) ;
System. out. println ( "ParentController findAnnotation @SingletonComponent: " + AnnotationUtils. findAnnotation ( ChildController. class , SingletonComponent. class ) ) ;
System. out. println ( ) ;
System. out. println ( "ParentController isAnnotated @SingletonComponent: " + AnnotatedElementUtils. isAnnotated ( ParentController. class , SingletonComponent. class ) ) ;
System. out. println ( "ParentController getMergedAnnotation @SingletonComponent: " + AnnotatedElementUtils. getMergedAnnotation ( ParentController. class , SingletonComponent. class ) ) ;
System. out. println ( "ChildController isAnnotated @SingletonComponent: " + AnnotatedElementUtils. isAnnotated ( ChildController. class , SingletonComponent. class ) ) ;
System. out. println ( "ChildController getMergedAnnotation @SingletonComponent: " + AnnotatedElementUtils. getMergedAnnotation ( ChildController. class , SingletonComponent. class ) ) ;
System. out. println ( ) ;
System. out. println ( "ParentController hasAnnotation @SingletonComponent: " + AnnotatedElementUtils. hasAnnotation ( ParentController. class , SingletonComponent. class ) ) ;
System. out. println ( "ParentController findMergedAnnotation @SingletonComponent: " + AnnotatedElementUtils. findMergedAnnotation ( ParentController. class , SingletonComponent. class ) ) ;
System. out. println ( "ChildController hasAnnotation @SingletonComponent: " + AnnotatedElementUtils. hasAnnotation ( ChildController. class , SingletonComponent. class ) ) ;
System. out. println ( "ChildController findMergedAnnotation @SingletonComponent: " + AnnotatedElementUtils. findMergedAnnotation ( ChildController. class , SingletonComponent. class ) ) ;
}
}
ParentController getAnnotation @SingletonComponent : @com . jaemon. aal. define. SingletonComponent ( name= parent, value= parent/ controller)
ChildController getAnnotation @SingletonComponent : @com . jaemon. aal. define. SingletonComponent ( name= , value= child/ controller)
ParentController findAnnotation @SingletonComponent : @com . jaemon. aal. define. SingletonComponent ( name= parent, value= parent/ controller)
ParentController findAnnotation @SingletonComponent : @com . jaemon. aal. define. SingletonComponent ( name= , value= child/ controller)
ParentController isAnnotated @SingletonComponent : true
ParentController getMergedAnnotation @SingletonComponent : @com . jaemon. aal. define. SingletonComponent ( name= parent, value= parent/ controller)
ChildController isAnnotated @SingletonComponent : true
ChildController getMergedAnnotation @SingletonComponent : @com . jaemon. aal. define. SingletonComponent ( name= , value= child/ controller)
ParentController hasAnnotation @SingletonComponent : true
ParentController findMergedAnnotation @SingletonComponent : @com . jaemon. aal. define. SingletonComponent ( name= parent, value= parent/ controller)
ChildController hasAnnotation @SingletonComponent : true
ChildController findMergedAnnotation @SingletonComponent : @com . jaemon. aal. define. SingletonComponent ( name= , value= child/ controller)