Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-1312

Extend Compoent.initInterceptors to scan Annnotations on methods for additional interceptors

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Duplicate Issue
    • Affects Version/s: 1.2.1.GA
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      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) ); }

      }
      }
      }

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  cmrudd Chris Rudd
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: