Details

    • Type: Feature Request
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Duplicate Issue
    • Affects Version/s: 1.2.Final
    • Fix Version/s: None
    • Component/s: Portable Extensions
    • Labels:
      None

      Description

      The decorator design pattern is commonly used in CDI extensions to modify existing metadata by wrapping it with a wrapper implementation that overrides certain method. This can be done in the following callbacks: ProcessAnnotatedType, ProcessProducer, ProcessInjectionTarget, ProcessInjectionPoint and ProcessBeanAttributes.

      In order to do this it is often very convenient to have a forwarding implementation available, e.g.:

          void wrap(@Observes ProcessAnnotatedType<Foo> event) {
              final AnnotatedType<Foo> delegate = event.getAnnotatedType();
              event.setAnnotatedType(new ForwardingAnnotatedType<Foo>(delegate) {
      
                  @Override
                  public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
                      return null;
                  }
      
                  @Override
                  public Set<Annotation> getAnnotations() {
                      return Collections.emptySet();
                  }
      
                  @Override
                  public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
                      return false;
                  }
      }
      

      We should consider providing these utility forwarding implementations as part of the CDI API. This is similar to e.g. Servlet specification doing this for their decorable APIs (http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletRequestWrapper.html)

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  jharting Jozef Hartinger
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: