javax.enterprise.inject.spi.ProcessInjectionPoint Java Examples

The following examples show how to use javax.enterprise.inject.spi.ProcessInjectionPoint. 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: ProviderExtensionSupport.java    From smallrye-jwt with Apache License 2.0 6 votes vote down vote up
/**
 * Collect the types of all {@linkplain Provider} injection points annotated with {@linkplain Claim}.
 *
 * @param pip - the injection point event information
 */
void processClaimProviderInjections(@Observes ProcessInjectionPoint<?, ? extends Provider> pip) {
    CDILogging.log.pip(pip.getInjectionPoint());
    final InjectionPoint ip = pip.getInjectionPoint();
    if (ip.getAnnotated().isAnnotationPresent(Claim.class)) {
        Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
        if (claim.value().length() == 0 && claim.standard() == Claims.UNKNOWN) {
            pip.addDefinitionError(CDIMessages.msg.claimHasNoNameOrValidStandardEnumSetting(ip));
        }
        boolean usesEnum = claim.standard() != Claims.UNKNOWN;
        final String claimName = usesEnum ? claim.standard().name() : claim.value();
        CDILogging.log.checkingProviderClaim(claimName, ip);
        Type matchType = ip.getType();
        // The T from the Provider<T> injection site
        Type actualType = ((ParameterizedType) matchType).getActualTypeArguments()[0];
        // Don't add Optional or JsonValue as this is handled specially
        if (isOptional(actualType)) {
            // Validate that this is not an Optional<JsonValue>
            Type innerType = ((ParameterizedType) actualType).getActualTypeArguments()[0];
            if (!isJson(innerType)) {
                providerOptionalTypes.add(actualType);
                providerQualifiers.add(claim);
            }
        }
    }
}
 
Example #2
Source File: MPConfigExtension.java    From microprofile-jwt-auth with Apache License 2.0 5 votes vote down vote up
/**
 * Collect the types of all injection points annotated with @ConfigProperty.
 * @param pip - the injection point event information
 */
void processConfigPropertyInjections(@Observes ProcessInjectionPoint pip) {
    System.out.printf("pip: %s\n", pip.getInjectionPoint());
    InjectionPoint ip = pip.getInjectionPoint();
    if (ip.getAnnotated().isAnnotationPresent(ConfigProperty.class)) {
        configPropertyTypes.add(ip.getType());
        System.out.printf("+++ Added ConfigProperty target type: %s\n", ip.getType());
    }
}
 
Example #3
Source File: ConfigExtension.java    From smallrye-config with Apache License 2.0 4 votes vote down vote up
protected void collectConfigPropertyInjectionPoints(@Observes ProcessInjectionPoint<?, ?> pip) {
    if (pip.getInjectionPoint().getAnnotated().isAnnotationPresent(ConfigProperty.class)) {
        injectionPoints.add(pip.getInjectionPoint());
    }
}
 
Example #4
Source File: VertxExtension.java    From weld-vertx with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
void processAsyncReferenceInjectionPoints(@Observes ProcessInjectionPoint<?, ? extends AsyncReference> event) {
    asyncReferenceQualifiers.addAll(event.getInjectionPoint().getQualifiers());
}
 
Example #5
Source File: MPJWTCDIExtension.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void collectConfigProducer(@Observes final ProcessInjectionPoint<?, ?> pip) {
    final Claim claim = pip.getInjectionPoint().getAnnotated().getAnnotation(Claim.class);
    if (claim != null) {
        injectionPoints.add(pip.getInjectionPoint());
    }
}
 
Example #6
Source File: SubscriptionPublisherCdiExtension.java    From joynr with Apache License 2.0 4 votes vote down vote up
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);
    }
}