[cdi-dev] [JBoss JIRA] (CDI-43) Allow Extensions to specify the annotations that they are interested in
Jozef Hartinger (JIRA)
jira-events at lists.jboss.org
Tue Aug 21 06:59:15 EDT 2012
[ https://issues.jboss.org/browse/CDI-43?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712652#comment-12712652 ]
Jozef Hartinger commented on CDI-43:
------------------------------------
I don't think this should be a type-level annotation - I like the original proposal much more. Bootstrap optimization that a container may perform based on this metadata is one of the benefits of this change. In addition, this could also serve as a convenient method of filtering container lifecycle events for extension authors - not unlike how qualifiers can be used to filter normal events. For that, per observer method declarations would be necessary.
{code:JAVA}
public class SeamExtension implements Extension {
public void registerRestClientInjectionPoints(@Observes @HandlesTypes(RestClient.class) ProcessAnnotatedType<?> type) {
// TODO register @RestClient injection points
}
public void registerExceptionHandlerClasses(@Observes @HandlesTypes(HandlesExceptions.class) ProcessAnnotatedType<?> type) {
// TODO register exception handlers
}
}
{code}
It would be guaranteed that if the "registerExceptionHandlerClasses" observer method is called, the annotated type is annotated with the @HandlesException annotation.
Furthermore, if we choose a different name for the annotation than "HandlesTypes", I would suggest to drop the option to use the annotation to specify superclasses and interfaces implemented by the event (since this can already be done by a wildcard in the observer method declaration) and leave only the option of filtering based on annotations.
> 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