[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-1312) Extend Compoent.initInterceptors to scan Annnotations on methods for additional interceptors

Chris Rudd (JIRA) jira-events at lists.jboss.org
Wed May 9 19:09:52 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-1312?page=comments#action_12361945 ] 
            
Chris Rudd commented on JBSEAM-1312:
------------------------------------

Maybe Im not being clear.

Currently if I have an annotation

@Interceptor(MyInterceptor.class)
@Retention(RetentionType.RUNTIME)
public @interface MyAnnotation
{
     public value();
};


If I place that on a class like this :

@Name("myComponent")
@MyAnnotation
public class MyComponent
{
}

Then seam will automatically add MyInterceptor.class in to the interceptors that are applied via the Component.

All im asking is that If I do the following I get the same result, so that I dont have to either 
   A) put the annotation on the class as well
   B) explicitly specify the interceptor using @Interceptor(MyInterceptor.class) on the class  (which isnt supported for pojo components)

@Name("myComponent2")
public class MyComponent
{
     @MyAnnotation
     public void myMethod()
     {
     }
}

> Extend Compoent.initInterceptors to scan Annnotations on methods for additional interceptors
> --------------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-1312
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1312
>             Project: JBoss Seam
>          Issue Type: Feature Request
>          Components: Core
>    Affects Versions: 1.2.1.GA
>            Reporter: Chris Rudd
>         Assigned To: Pete Muir
>
> It would be nice if the Component.initInterceptors method not only scanned the annotations on the class for additional interceptors but also scanned the methods / fields for additional interceptors.
> This would allow more flexability. 
> EG the @LoggedIn from the examples could be extended so that it checked for a class level or method level @LoggedIn annotation to instruct it to do the check (instead of only the class level as it is now). Naturally you would want to remove the class level annotation and only put it on the methods that require being logged in. BUT if you do that, the auto-magic initInterceptor code wont know to add the LoggedInInterceptor.
> Altered initInterceptors:
>     private void initInterceptors()
>     {
>        initDefaultInterceptors();
>        findInterceptors(new AnnotatedElement[] { component.getBeanClass() });
>        for (Class clazz = component.getBeanClass(); clazz != Object.class; clazz = clazz
>                  .getSuperclass())
>        {
>            findInterceptors(clazz.getDeclaredFields());
>            findInterceptors(clazz.getDeclaredMethods());
>        }
>     }
>     
> Additional support method :
>     protected void findInterceptors(AnnotatedElement[] aes)
>     {
>         for (AnnotatedElement ae : aes)
>         {
>             for (Annotation annotation : ae.getAnnotations())
>             {
>                 if ( annotation.annotationType().isAnnotationPresent(INTERCEPTORS) )
>                 {
>                     Class[] classes = value( annotation.annotationType().getAnnotation(INTERCEPTORS) );
>                     addInterceptor( new Interceptor(classes, annotation, this) );
>                 }
>                 if ( annotation.annotationType().isAnnotationPresent(Interceptors.class) )
>                 {
>                     Class[] classes = annotation.annotationType().getAnnotation(Interceptors.class).value();
>                     addInterceptor( new Interceptor(classes, annotation, this) );
>                 }
>             }
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list