[cdi-dev] [JBoss JIRA] (CDI-43) Allow Extensions to specify the annotations that they are interested in

Pete Muir (JIRA) jira-events at lists.jboss.org
Mon Aug 20 13:48:16 EDT 2012


    [ https://issues.jboss.org/browse/CDI-43?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712513#comment-12712513 ] 

Pete Muir edited comment on CDI-43 at 8/20/12 1:47 PM:
-------------------------------------------------------

A more formal proposal:

Add

{code}
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface HandlesTypes {
    Class[] value();
}
{code}

(Name is a strawman...)

This annotation can be applied to an extension class, and provides a hint to the container about classes or annotations which this extension is interested in.

If this annotation is used, the container, as a performance optimisation, may only call ProcessAnnotatedType observer methods:

* that have the event type (or a super class or super interface of the event type) in the set of handled types
* that have an annotation (applied to the type, constructor, constructor parameter, method, method parameter or field) that is in the set of handled types

and may not call a ProcessAnnotatedType observer method for other event types.
                
      was (Author: pmuir):
    A more formal proposal:

Add

{code}
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface HandlesTypes {
    Class[] value();
}
{code}

(Name is a strawman...)

This annotation can be applied to an extension class, and provides a hint to the container about classes or annotations which this extension is interested in.

If this annotation is used, the container, as a performance optimisation, may only call ProcessAnnotatedType observer methods:

* that have the event type (or a super class or super interface of the event type) in the set of handled types
* that have an annotation (applied to the type, constructor, constructor parameter, method, method parameter or field) that is in the set of handled types

and may not call a ProcessAnnotatedType observer method for other event types.
                  
> Allow Extensions to specify the annotations that they are interested in
> -----------------------------------------------------------------------
>
>                 Key: CDI-43
>                 URL: https://issues.jboss.org/browse/CDI-43
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Portable Extensions
>    Affects Versions: 1.0
>            Reporter: Stuart Douglas
>             Fix For: 1.1 (Proposed)
>
>
> Currently portable extensions that wish to look for a specific annotation have to look through all availible classes in the ProcessAnnotatatedType event, which is quite inefficient. It would be good if extensions could do something like:
> public void processAnnotatedType(@Observes @RequireAnnotations({@Unwraps.class}) ProcessAnnotatedType pat) 
> This could allow the container to take advantage of annotation indexing to improve boot time performance, as well as reducing uneeded processing in the observer.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the cdi-dev mailing list