Java Code Examples for javax.enterprise.inject.spi.InjectionPoint#getQualifiers()
The following examples show how to use
javax.enterprise.inject.spi.InjectionPoint#getQualifiers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChannelProducer.java From smallrye-reactive-messaging with Apache License 2.0 | 6 votes |
static Channel getChannelQualifier(InjectionPoint injectionPoint) { for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(Channel.class)) { return (Channel) qualifier; } if (qualifier.annotationType().equals(io.smallrye.reactive.messaging.annotations.Channel.class)) { return new Channel() { @Override public Class<? extends Annotation> annotationType() { return Channel.class; } @Override public String value() { return ((io.smallrye.reactive.messaging.annotations.Channel) qualifier).value(); } }; } } return null; }
Example 2
Source File: ConfigProducerUtil.java From smallrye-config with Apache License 2.0 | 6 votes |
public static String getDefaultValue(InjectionPoint injectionPoint) { for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(ConfigProperty.class)) { String str = ((ConfigProperty) qualifier).defaultValue(); if (!ConfigProperty.UNCONFIGURED_VALUE.equals(str)) { return str; } Class<?> rawType = rawTypeOf(injectionPoint.getType()); if (rawType.isPrimitive()) { if (rawType == char.class) { return null; } else if (rawType == boolean.class) { return "false"; } else { return "0"; } } return null; } } return null; }
Example 3
Source File: MailTemplateProducer.java From quarkus with Apache License 2.0 | 6 votes |
@ResourcePath("ignored") @Produces MailTemplate get(InjectionPoint injectionPoint) { ResourcePath path = null; for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(ResourcePath.class)) { path = (ResourcePath) qualifier; break; } } if (path == null || path.value().isEmpty()) { throw new IllegalStateException("No template resource path specified"); } final String name = path.value(); return new MailTemplate() { @Override public MailTemplateInstance instance() { return new MailTemplateInstanceImpl(mailer, template.select(new ResourcePath.Literal(name)).get().instance()); } }; }
Example 4
Source File: TemplateProducer.java From quarkus with Apache License 2.0 | 6 votes |
@Produces @ResourcePath("ignored") Template getTemplate(InjectionPoint injectionPoint) { ResourcePath path = null; for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(ResourcePath.class)) { path = (ResourcePath) qualifier; break; } } if (path == null || path.value().isEmpty()) { throw new IllegalStateException("No template reource path specified"); } // We inject a delegating template in order to: // 1. Be able to select an appropriate variant if needed // 2. Be able to reload the template when needed, i.e. when the cache is cleared return new InjectableTemplate(path.value(), templateVariants, engine); }
Example 5
Source File: InjectionPointMetadataTest.java From quarkus with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked", "serial" }) @Test public void testObserverInjectionPointMetadata() { AtomicReference<InjectionPoint> ip = new AtomicReference<>(); Arc.container().beanManager().getEvent().select(new TypeLiteral<AtomicReference<InjectionPoint>>() { }).fire(ip); InjectionPoint injectionPoint = ip.get(); assertNotNull(injectionPoint); assertEquals(Controlled.class, injectionPoint.getType()); Set<Annotation> qualifiers = injectionPoint.getQualifiers(); assertEquals(1, qualifiers.size()); assertEquals(Default.class, qualifiers.iterator().next().annotationType()); Assertions.assertNull(injectionPoint.getBean()); assertNotNull(injectionPoint.getAnnotated()); assertTrue(injectionPoint.getAnnotated() instanceof AnnotatedParameter); AnnotatedParameter<Controller> annotatedParam = (AnnotatedParameter<Controller>) injectionPoint.getAnnotated(); assertEquals(Controlled.class, annotatedParam.getBaseType()); assertEquals(1, annotatedParam.getAnnotations().size()); assertFalse(annotatedParam.isAnnotationPresent(Inject.class)); assertTrue(annotatedParam.isAnnotationPresent(FooAnnotation.class)); assertTrue(annotatedParam.getAnnotation(Singleton.class) == null); assertTrue(annotatedParam.getAnnotations(Singleton.class).isEmpty()); }
Example 6
Source File: InjectableResourceProducer.java From deltaspike with Apache License 2.0 | 5 votes |
private InjectableResource getAnnotation(final InjectionPoint injectionPoint) { for (Annotation annotation : injectionPoint.getQualifiers()) { if (annotation instanceof InjectableResource) { return (InjectableResource)annotation; } } return null; }
Example 7
Source File: RawClaimTypeProducer.java From smallrye-jwt with Apache License 2.0 | 5 votes |
static String getName(InjectionPoint ip) { String name = null; for (Annotation ann : ip.getQualifiers()) { if (ann instanceof Claim) { Claim claim = (Claim) ann; name = claim.standard() == Claims.UNKNOWN ? claim.value() : claim.standard().name(); } } return name; }
Example 8
Source File: ConfigurationValueProducer.java From thorntail with Apache License 2.0 | 5 votes |
private String getName(InjectionPoint injectionPoint) { for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(ConfigurationValue.class)) { return ((ConfigurationValue) qualifier).value(); } } return null; }
Example 9
Source File: ConfigPropertyProducer.java From microprofile-jwt-auth with Apache License 2.0 | 5 votes |
private String getDefaultValue(InjectionPoint injectionPoint) { String defaultValue = null; for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(ConfigProperty.class)) { // Check for a non-default value defaultValue = ((ConfigProperty) qualifier).defaultValue(); if(defaultValue.length() == 0) { defaultValue = null; } break; } } return defaultValue; }
Example 10
Source File: ConfigPropertyProducer.java From microprofile-jwt-auth with Apache License 2.0 | 5 votes |
private String getName(InjectionPoint injectionPoint) { for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(ConfigProperty.class)) { // Check for a non-default value String name = ((ConfigProperty) qualifier).name(); if(name.length() == 0) { // name = injectionPoint.getBean().getBeanClass().getTypeName() + "." + injectionPoint.getMember().getName(); } return name; } } return null; }
Example 11
Source File: InfinispanClientProducer.java From quarkus with Apache License 2.0 | 5 votes |
@io.quarkus.infinispan.client.Remote @Produces public <K, V> RemoteCache<K, V> getRemoteCache(InjectionPoint injectionPoint, RemoteCacheManager cacheManager) { Set<Annotation> annotationSet = injectionPoint.getQualifiers(); final io.quarkus.infinispan.client.Remote remote = getRemoteAnnotation(annotationSet); if (remote != null && !remote.value().isEmpty()) { return cacheManager.getCache(remote.value()); } return cacheManager.getCache(); }
Example 12
Source File: ConfigBeanCreator.java From quarkus with Apache License 2.0 | 5 votes |
private ConfigProperty getConfigProperty(InjectionPoint injectionPoint) { for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(ConfigProperty.class)) { return (ConfigProperty) qualifier; } } return null; }
Example 13
Source File: ErasedGenericTest.java From quarkus with Apache License 2.0 | 5 votes |
String getName(InjectionPoint ip) { String name = null; for (Annotation ann : ip.getQualifiers()) { if (ann instanceof Claim) { Claim claim = (Claim) ann; name = claim.value(); } } return name; }
Example 14
Source File: InstanceBean.java From quarkus with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public Instance<?> get(CreationalContext<Instance<?>> creationalContext) { // Obtain current IP to get the required type and qualifiers InjectionPoint ip = InjectionPointProvider.get(); InstanceImpl<Instance<?>> instance = new InstanceImpl<Instance<?>>((InjectableBean<?>) ip.getBean(), ip.getType(), ip.getQualifiers(), (CreationalContextImpl<?>) creationalContext, Collections.EMPTY_SET, ip.getMember(), 0); CreationalContextImpl.addDependencyToParent((InjectableBean<Instance<?>>) ip.getBean(), instance, creationalContext); return instance; }
Example 15
Source File: ConfigProducerUtil.java From smallrye-config with Apache License 2.0 | 5 votes |
public static String getName(InjectionPoint injectionPoint) { for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(ConfigProperty.class)) { ConfigProperty configProperty = ((ConfigProperty) qualifier); return getConfigKey(injectionPoint, configProperty); } } return null; }
Example 16
Source File: ConfigSourceProvider.java From smallrye-config with Apache License 2.0 | 5 votes |
@Produces @Name("") public ConfigSource produceConfigSource(final InjectionPoint injectionPoint) { Set<Annotation> qualifiers = injectionPoint.getQualifiers(); String name = getName(qualifiers); return configSourceMap.get(name); }
Example 17
Source File: ChannelProducer.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
static String getChannelName(InjectionPoint injectionPoint) { for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(Channel.class)) { return ((Channel) qualifier).value(); } if (qualifier.annotationType().equals(io.smallrye.reactive.messaging.annotations.Channel.class)) { return ((io.smallrye.reactive.messaging.annotations.Channel) qualifier).value(); } } throw ex.illegalStateForAnnotationNotFound("@Channel", injectionPoint); }
Example 18
Source File: CommonJwtProducer.java From smallrye-jwt with Apache License 2.0 | 5 votes |
public String getName(InjectionPoint ip) { String name = null; for (Annotation ann : ip.getQualifiers()) { if (ann instanceof Claim) { Claim claim = (Claim) ann; name = claim.standard() == Claims.UNKNOWN ? claim.value() : claim.standard().name(); } } return name; }
Example 19
Source File: EventBean.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Event<?> get(CreationalContext<Event<?>> creationalContext) { // Obtain current IP to get the required type and qualifiers InjectionPoint ip = InjectionPointProvider.get(); return new EventImpl<>(ip.getType(), ip.getQualifiers()); }
Example 20
Source File: SubscriptionPublisherCdiExtension.java From joynr with Apache License 2.0 | 4 votes |
public void alterSubscriptionPublishInjectionPoints(@Observes ProcessInjectionPoint processInjectionPoint) { final InjectionPoint injectionPoint = processInjectionPoint.getInjectionPoint(); logger.info("Looking at injection point: {}", injectionPoint); if (injectionPoint.getType() instanceof Class && SubscriptionPublisher.class.isAssignableFrom((Class) injectionPoint.getType())) { logger.info("Re-writing injection point type from {} to {} on bean {}", injectionPoint.getType(), SubscriptionPublisher.class, injectionPoint.getBean()); final Bean<?> bean = injectionPoint.getBean(); InjectionPoint newInjectionPoint = new InjectionPoint() { @Override public Type getType() { return SubscriptionPublisher.class; } @Override public Set<Annotation> getQualifiers() { return injectionPoint.getQualifiers(); } @Override public Bean<?> getBean() { return bean; } @Override public Member getMember() { return injectionPoint.getMember(); } @Override public Annotated getAnnotated() { return injectionPoint.getAnnotated(); } @Override public boolean isDelegate() { return injectionPoint.isDelegate(); } @Override public boolean isTransient() { return injectionPoint.isTransient(); } }; processInjectionPoint.setInjectionPoint(newInjectionPoint); } }