[
https://issues.jboss.org/browse/CDI-551?page=com.atlassian.jira.plugin.sy...
]
Chris Rankin updated CDI-551:
-----------------------------
Description:
I would like to extend {{javax.enterprise.inject.spi.InjectionPoint}} for easier analysis
of both static and dynamic qualifiers.
I have previously used {{InjectionPoint.getAnnotated()}}, but have now realised that this
is not enough because it cannot include {{AnnotationLiteral}} qualifiers added via
{{Instance.select(...)}}. The only reliable way to analyse _all_ of the qualifiers is
currently via {{InjectionPoint.getQualifiers()}}, which unfortunately returns
{{Set<Annotated>}}.
A {{Set<Annotated>>}} is not immediately useful to me; about the only thing that
I can do with it is iterate over it every time. So I must convert it into something more
like this first:
{code:language=java}
@SuppressWarnings("unchecked")
public class QualifierMap extends HashMap<Class<? extends Annotation>,
Annotation> {
private static final long serialVersionUID = 1L;
public QualifierMap(Iterable<? extends Annotation> qualifiers) {
for (Annotation qualifier : qualifiers) {
put(qualifier.annotationType(), qualifier);
}
}
public <T extends Annotation> T get(Class<T> key) {
return (T) super.get(key);
}
}
{code}
However, it would be much _more_ convenient if {{InjectionPoint}} could export this
functionality automatically instead:
{code:language=java}
public interface InjectionPoint {
...
boolean isQualifierPresent(Class<? extends Annotation> annotationType);
<T extends Annotation> T getQualifier(Class<T> annotationType);
....
}
{code}
was:
I would like to extend {{javax.enterprise.inject.spi.InjectionPoint}} for easier analysis
of both static and dynamic qualifiers.
I have previously used {{InjectionPoint.getAnnotated()}}, but have now realised that is
not enough because it cannot include {{AnnotationLiteral}} qualifiers added via
{{Instance.select(...)}}. The only reliable way to analyse _all_ of the qualifiers is
currently via {{InjectionPoint.getQualifiers()}}, which unfortunately returns
{{Set<Annotated>}}.
A {{Set<Annotated>>}} is not immediately useful to me; about the only thing that
I can do with it is iterate over it every time. So I must convert it into something more
like this first:
{code:language=java}
@SuppressWarnings("unchecked")
public class QualifierMap extends HashMap<Class<? extends Annotation>,
Annotation> {
private static final long serialVersionUID = 1L;
public QualifierMap(Iterable<? extends Annotation> qualifiers) {
for (Annotation qualifier : qualifiers) {
put(qualifier.annotationType(), qualifier);
}
}
public <T extends Annotation> T get(Class<T> key) {
return (T) super.get(key);
}
}
{code}
However, it would be much _more_ convenient if {{InjectionPoint}} could export this
functionality automatically instead:
{code:language=java}
public interface InjectionPoint {
...
boolean isQualifierPresent(Class<? extends Annotation> annotationType);
<T extends Annotation> T getQualifier(Class<T> annotationType);
....
}
{code}
Easier access to InjectionPoint qualifiers.
-------------------------------------------
Key: CDI-551
URL:
https://issues.jboss.org/browse/CDI-551
Project: CDI Specification Issues
Issue Type: Feature Request
Components: Beans
Affects Versions: 1.2.Final
Reporter: Chris Rankin
I would like to extend {{javax.enterprise.inject.spi.InjectionPoint}} for easier analysis
of both static and dynamic qualifiers.
I have previously used {{InjectionPoint.getAnnotated()}}, but have now realised that this
is not enough because it cannot include {{AnnotationLiteral}} qualifiers added via
{{Instance.select(...)}}. The only reliable way to analyse _all_ of the qualifiers is
currently via {{InjectionPoint.getQualifiers()}}, which unfortunately returns
{{Set<Annotated>}}.
A {{Set<Annotated>>}} is not immediately useful to me; about the only thing that
I can do with it is iterate over it every time. So I must convert it into something more
like this first:
{code:language=java}
@SuppressWarnings("unchecked")
public class QualifierMap extends HashMap<Class<? extends Annotation>,
Annotation> {
private static final long serialVersionUID = 1L;
public QualifierMap(Iterable<? extends Annotation> qualifiers) {
for (Annotation qualifier : qualifiers) {
put(qualifier.annotationType(), qualifier);
}
}
public <T extends Annotation> T get(Class<T> key) {
return (T) super.get(key);
}
}
{code}
However, it would be much _more_ convenient if {{InjectionPoint}} could export this
functionality automatically instead:
{code:language=java}
public interface InjectionPoint {
...
boolean isQualifierPresent(Class<? extends Annotation> annotationType);
<T extends Annotation> T getQualifier(Class<T> annotationType);
....
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)