javax.enterprise.inject.spi.ProcessInjectionTarget Java Examples

The following examples show how to use javax.enterprise.inject.spi.ProcessInjectionTarget. 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: SpringCDIExtension.java    From datawave with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
<T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> pit, BeanManager bm) {
    log.trace("processInjectionTarget({},{})", pit, bm);
    
    synchronized (springBeans) {
        Set<InjectionPoint> injectionPoints = pit.getInjectionTarget().getInjectionPoints();
        for (InjectionPoint ip : injectionPoints) {
            Type type = ip.getType();
            // Skip primitives
            if (!(type instanceof Class<?> || type instanceof ParameterizedType))
                continue;
            
            SpringBean sb = ip.getAnnotated().getAnnotation(SpringBean.class);
            if (sb != null) {
                String key = sb.name() + ":" + type;
                if (!springBeans.containsKey(key)) {
                    SpringCDIBean scb = sb.refreshable() ? new RefreshableSpringCDIBean(sb, type, bm) : new SpringCDIBean(sb, type, bm);
                    springBeans.put(key, scb);
                }
            }
        }
    }
}
 
Example #2
Source File: ConfigurableExtension.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
<T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> pit, BeanManager beanManager) throws Exception {
    try (AutoCloseable handle = Performance.accumulate("ConfigurationExtension.processInjectionTarget")) {
        if (isApplicable(pit.getAnnotatedType())) {
            pit.setInjectionTarget(new ConfigurableInjectionTarget<T>(pit.getInjectionTarget(), this.configurableManager));
        }
    }
}
 
Example #3
Source File: MPConfigExtension.java    From microprofile-jwt-auth with Apache License 2.0 4 votes vote down vote up
void findNeededConfigPropertyProducers(@Observes ProcessInjectionTarget<ConfigProperty> pit) {
    System.out.printf("ConfigPropertyTarget: %s", pit.getInjectionTarget());
}
 
Example #4
Source File: MockExtension.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public <X> void onProcessInjectionTarget(@Observes ProcessInjectionTarget<X> processInjectionTarget,
                                         BeanManager beanManager)
{
    if (!isActivated)
    {
        return;
    }

    for (MockFilter mockFilter : mockFilters)
    {
        if (!mockFilter.isMockedImplementationSupported(beanManager, processInjectionTarget.getAnnotatedType()))
        {
            return;
        }
    }

    List<Annotation> qualifiers = new ArrayList<Annotation>();
    for (Annotation annotation : processInjectionTarget.getAnnotatedType().getAnnotations())
    {
        if (beanManager.isQualifier(annotation.annotationType()))
        {
            qualifiers.add(annotation);
        }
    }

    Typed typed = processInjectionTarget.getAnnotatedType().getAnnotation(Typed.class);

    List<Type> foundTypes = new ArrayList<Type>();
    if (typed != null)
    {
        Collections.addAll(foundTypes, typed.value());
    }
    else
    {
        foundTypes.addAll(extractTypes(processInjectionTarget.getAnnotatedType().getJavaClass()));
    }

    if (foundTypes.isEmpty())
    {
        return;
    }

    final InjectionTarget<X> originalInjectionTarget = processInjectionTarget.getInjectionTarget();
    processInjectionTarget.setInjectionTarget(new MockAwareInjectionTargetWrapper<X>(
        beanManager, originalInjectionTarget, foundTypes, qualifiers));
}