Java 类javax.enterprise.inject.spi.ProcessInjectionPoint 实例源码

项目:wildfly-swarm    文件:MPJWTExtension.java   
void processClaimValueInjections(@Observes ProcessInjectionPoint pip) {
    log.debugf("pipRaw: %s", pip.getInjectionPoint());
    InjectionPoint ip = pip.getInjectionPoint();
    if (ip.getAnnotated().isAnnotationPresent(Claim.class) && ip.getType() instanceof Class) {
        Class rawClass = (Class) ip.getType();
        if (Modifier.isFinal(rawClass.getModifiers())) {
            Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
            rawTypes.add(ip.getType());
            rawTypeQualifiers.add(claim);
            log.debugf("+++ Added Claim raw type: %s", ip.getType());
            Class declaringClass = ip.getMember().getDeclaringClass();
            Annotation[] appScoped = declaringClass.getAnnotationsByType(ApplicationScoped.class);
            Annotation[] sessionScoped = declaringClass.getAnnotationsByType(SessionScoped.class);
            if ((appScoped != null && appScoped.length > 0) || (sessionScoped != null && sessionScoped.length > 0)) {
                String err = String.format("A raw type cannot be injected into application/session scope: IP=%s", ip);
                pip.addDefinitionError(new DeploymentException(err));
            }

        }
    }
}
项目:testee.fi    文件:MockingExtension.java   
public <T, X> void injectionPoints(
        final @Observes ProcessInjectionPoint<T, X> processInjectionPoint
) {
    final Type type = processInjectionPoint.getInjectionPoint().getType();
    final Object mock = mockStore.findFor(type);
    if (mock == null) {
        return;
    }

    LOG.debug("Mocking injection point: {}", processInjectionPoint.getInjectionPoint());
    final InjectionPoint original = processInjectionPoint.getInjectionPoint();
    processInjectionPoint.setInjectionPoint(new ForwardingInjectionPoint() {
        @Override
        public Set<Annotation> getQualifiers() {
            final Set<Annotation> ret = new HashSet<>(super.getQualifiers()).stream()
                    .filter(it -> !(it instanceof Default))
                    .collect(toSet());
            ret.add(MOCKED);
            return ret;
        }

        @Override
        protected InjectionPoint delegate() {
            return original;
        }
    });
    mockedInjectionPoints.add(original);
}
项目:cito    文件:BodyProducerExtensionTest.java   
@Test
public void captureProducerTypes() {
    final ProcessInjectionPoint<?, ?> pip = mock(ProcessInjectionPoint.class);
    final InjectionPoint ip = mock(InjectionPoint.class);
    when(pip.getInjectionPoint()).thenReturn(ip);
    final Annotated annotated = mock(Annotated.class);
    when(ip.getAnnotated()).thenReturn(annotated);
    when(annotated.isAnnotationPresent(Body.class)).thenReturn(true);
    when(ip.getType()).thenReturn(COLLECTION.getClass());
    @SuppressWarnings("unchecked")
    final InjectionTarget<Object> injectionTarget = mock(InjectionTarget.class);
    when(this.beanManager.createInjectionTarget(Mockito.any())).thenReturn(injectionTarget);
    final Member member = mock(Member.class);
    when(ip.getMember()).thenReturn(member);

    final List<Bean<?>> found = ReflectionUtil.get(this.extension, "found");
    assertTrue(found.isEmpty());

    this.extension.captureProducerTypes(pip, this.beanManager);

    assertEquals(1, found.size());

    verify(pip, times(2)).getInjectionPoint();
    verify(ip).getAnnotated();
    verify(annotated).isAnnotationPresent(Body.class);
    verify(ip).getType();
    verify(ip).getMember();
    verify(member).getName();
    verify(ip).getQualifiers();
    verify(injectionTarget).getInjectionPoints();
    verify(this.beanManager).createInjectionTarget(Mockito.any());
    verifyNoMoreInteractions(pip, ip, annotated, injectionTarget, member);
}
项目:wildfly-swarm    文件:MPJWTExtension.java   
/**
 * Collect the types of all Provider injection points annotated with {@linkplain Claim}.
 *
 * @param pip - the injection point event information
 */
void processClaimProviderInjections(@Observes ProcessInjectionPoint<?, ? extends Provider> pip) {
    log.debugf("pip: %s", 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) {
            throw new DeploymentException("@Claim at: " + ip + " has no name or valid standard enum setting");
        }
        boolean usesEnum = claim.standard() != Claims.UNKNOWN;
        final String claimName = usesEnum ? claim.standard().name() : claim.value();
        log.debugf("Checking Provider Claim(%s), ip: %s", claimName, ip);
        ClaimIP claimIP = claims.get(claimName);
        Type matchType = ip.getType();
        Type actualType = ((ParameterizedType) matchType).getActualTypeArguments()[0];
        // Don't add Optional as this is handled specially
        if (!optionalOrJsonValue(actualType)) {
            rawTypes.add(actualType);
        } else if (!actualType.getTypeName().startsWith("javax.json.Json")) {
            // Validate that this is not an Optional<JsonValue>
            Type innerType = ((ParameterizedType) actualType).getActualTypeArguments()[0];
            if (!innerType.getTypeName().startsWith("javax.json.Json")) {
                providerOptionalTypes.add(actualType);
                providerQualifiers.add(claim);
            }
        }
        rawTypeQualifiers.add(claim);
        ClaimIPType key = new ClaimIPType(claimName, actualType);
        if (claimIP == null) {
            claimIP = new ClaimIP(actualType, actualType, false, claim);
            claimIP.setProviderSite(true);
            claims.put(key, claimIP);
        }
        claimIP.getInjectionPoints().add(ip);
        log.debugf("+++ Added Provider Claim(%s) ip: %s", claimName, ip);

    }
}
项目:camel-cdi    文件:CdiCamelExtension.java   
private void cdiEventEndpoints(@Observes ProcessInjectionPoint<?, CdiEventEndpoint> pip, BeanManager manager) {
    InjectionPoint ip = pip.getInjectionPoint();
    Type type = ip.getType() instanceof ParameterizedType
        ? ((ParameterizedType) ip.getType()).getActualTypeArguments()[0]
        : Object.class;
    String uri = eventEndpointUri(type, ip.getQualifiers());
    cdiEventEndpoints.put(uri, new CdiEventEndpoint<>(uri, type, ip.getQualifiers(), manager));
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:ObserverExtension.java   
<K, V> void processInjectionPoint(@Observes ProcessInjectionPoint<K, V> pip) {
    logger.info("finished the scanning process");
    processInjectionPoint++;
}
项目:wildfly-microprofile-config    文件:ConfigExtension.java   
public void collectConfigProducer(@Observes ProcessInjectionPoint<?, ?> pip) {
    ConfigProperty configProperty = pip.getInjectionPoint().getAnnotated().getAnnotation(ConfigProperty.class);
    if (configProperty != null) {
        injectionPoints.add(pip.getInjectionPoint());
    }
}
项目:reactive-cdi-events    文件:ReactorExtension.java   
public void locateInjections(@Observes ProcessInjectionPoint<?, ReactorEvent<?,?>> pip) {
    eventTypes.add(pip.getInjectionPoint());
}
项目:cito    文件:BodyProducerExtension.java   
/**
 * 
 * @param pip
 * @param beanManager
 */
public void captureProducerTypes(@Observes final ProcessInjectionPoint<?, ?> pip, BeanManager beanManager) {
    if (pip.getInjectionPoint().getAnnotated().isAnnotationPresent(Body.class)) {
        found.add(createBeanAdapter(pip.getInjectionPoint(), beanManager));
    }
}
项目:weld-vertx    文件:VertxExtension.java   
@SuppressWarnings("rawtypes")
void processAsyncReferenceInjectionPoints(@Observes ProcessInjectionPoint<?, ? extends AsyncReference> event) {
    asyncReferenceQualifiers.addAll(event.getInjectionPoint().getQualifiers());
}
项目:javaConfig    文件:ConfigExtension.java   
public void collectConfigProducer(@Observes ProcessInjectionPoint<?, ?> pip) {
    ConfigProperty configProperty = pip.getInjectionPoint().getAnnotated().getAnnotation(ConfigProperty.class);
    if (configProperty != null) {
        injectionPoints.add(pip.getInjectionPoint());
    }
}
项目:axon-cdi    文件:AxonCdiExtension.java   
<T, X extends EventScheduler> void processEventSchedulerInjectionPoint(
        @Observes final ProcessInjectionPoint<T, X> processInjectionPoint,
        final BeanManager beanManager) {
    InjectionPoint injectionPoint = processInjectionPoint.getInjectionPoint();
    eventSchedulerInfos.add(EventSchedulerInfo.of(injectionPoint));
}
项目:Java-EE    文件:LifeCycleLogger.java   
<T, X> void logLifecycleEvent(@Observes ProcessInjectionPoint<T, X> event) {
    LOGGER.info("ProcessInjectionPoint: injectionPoint=" + event.getInjectionPoint());
}
项目:joynr    文件:SubscriptionPublisherCdiExtension.java   
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);
    }
}
项目:osgi.ee    文件:ServiceExtension.java   
/**
 * Event generated by the container to process an injection point. Is called for every point defined in the
 * container. During this phase, we check for any @ServiceReference qualifiers and create a bean for it.
 * That bean is later added during another phase of the container construction.
 *
 * @param event The injection point event
 * @param <T> The injection point type
 * @param <X> The bean class declaring the point
 */
public <T, X> void processInjectionPoints(@Observes ProcessInjectionPoint<T, X> event) {
    TrackerBean bean = processInjectionPoint(event.getInjectionPoint(), (e) -> event.addDefinitionError(e));
    if (bean != null) {
        beans.add(bean);
    }
}