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

项目:CDIProperties    文件:CDIPropertiesExtension.java   
/**
 * Prepares the injection process of properties from a property file.
 *
 * @param pit
 *      The actual target of process injection
 * @param <T>
 *      the generic type of the injection target
 */
public <T> void initializePropertyLoading(@Observes final ProcessInjectionTarget<T> pit) throws IOException {
    AnnotatedType<T> at = pit.getAnnotatedType();
    if (!at.isAnnotationPresent(PropertyFile.class)) {
        return;
    }
    try {
        PropertyFile propertyFile = at.getAnnotation(PropertyFile.class);
        Properties properties = loadProperties(propertyFile, pit.getAnnotatedType().getJavaClass());
        Map<Field, Object> fieldValues = assignPropertiesToFields(at.getFields(), properties);
        InjectionTarget<T> wrapped = new PropertyInjectionTarget<T>(fieldValues, pit, pit.getInjectionTarget());
        pit.setInjectionTarget(wrapped);
    } catch (Exception e) {
        pit.addDefinitionError(e);
    }
}
项目:dynamic-repositories    文件:RepositoryExtension.java   
@SuppressWarnings("element-type-mismatch")
   <T> void processInjectionPoint(@Observes ProcessInjectionTarget<T> pit, BeanManager beanManager) {
    for (InjectionPoint point : pit.getInjectionTarget().getInjectionPoints()) {
           if (repositoryInterfaces.contains(point.getType())) {
               log.fine(String.format("... found InjectionPoint in Class: %s with name: %s for the repository with type: %s%n", point.getBean().getBeanClass().getName(), point.getMember().getName(), point.getType()));
               String technology = "default";
               if (point.getAnnotated().isAnnotationPresent(Technology.class)) {
                   technology = point.getAnnotated().getAnnotation(Technology.class).value();
               }
               RepositoryKey key = new RepositoryKey((Class<?>) point.getType(), technology);
               if (!repositoryBeans.containsKey(key)) {
                   log.fine(String.format("... create Bean for Repository: %s with technology: %s%n", point.getType(), technology));
                   repositoryBeans.put(key, new RepositoryBean(beanManager, key));
               }
           }
    }
}
项目:cdi    文件:MybatisExtensionTest.java   
private <T> void projectInjectionTarget(MybatisExtension extension, Type type) {
  ProcessInjectionTarget<T> event = mock(ProcessInjectionTarget.class);
  InjectionTarget<T> injectTarget = mock(InjectionTarget.class);
  Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();

  InjectionPoint injectionPoint = mock(InjectionPoint.class);
  Annotated annotated = mock(Annotated.class);

  when(injectionPoint.getAnnotated()).thenReturn(annotated);

  when(annotated.getBaseType()).thenReturn(type);
  when(annotated.getAnnotations()).thenReturn(new HashSet<Annotation>());

  injectionPoints.add(injectionPoint);

  when(event.getInjectionTarget()).thenReturn(injectTarget);
  when(injectTarget.getInjectionPoints()).thenReturn(injectionPoints);

  extension.processInjectionTarget(event);
}
项目:wildfly-swarm    文件:ConfigurableExtension.java   
@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));
        }
    }
}
项目:eap-6.1-quickstarts    文件:CreatureExtension.java   
/**
 * Observer to a CDI lifecycle event to correctly setup the XML backed "injection".
 * @param pit CDI lifecycle callback payload
 * @param <X> Type of the Injection to observe
 */
<X extends Creature> void processInjectionTarget(@Observes ProcessInjectionTarget<X> pit) {
    Class<? extends Creature> klass = pit.getAnnotatedType().getJavaClass();
    log.info("Setting up injection target for " + klass);
    final Element entry = (Element) document.getElementsByTagName(klass.getSimpleName().toLowerCase()).item(0);
    pit.setInjectionTarget(new XmlBackedWrappedInjectionTarget<X>(pit.getInjectionTarget(), entry));
}
项目:jboss-as-quickstart    文件:CreatureExtension.java   
/**
 * Observer to a CDI lifecycle event to correctly setup the XML backed "injection".
 * @param pit CDI lifecycle callback payload
 * @param <X> Type of the Injection to observe
 */
<X extends Creature> void processInjectionTarget(@Observes ProcessInjectionTarget<X> pit) {
    Class<? extends Creature> klass = pit.getAnnotatedType().getJavaClass();
    log.info("Setting up injection target for " + klass);
    final Element entry = (Element) document.getElementsByTagName(klass.getSimpleName().toLowerCase()).item(0);
    pit.setInjectionTarget(new XmlBackedWrappedInjectionTarget<X>(pit.getInjectionTarget(), entry));
}
项目:dynamic-messages    文件:MessagesExtension.java   
<T> void processInjectionPoint(@Observes ProcessInjectionTarget<T> pit) {
    for (InjectionPoint point : pit.getInjectionTarget().getInjectionPoints()) {
           if (messageBundleInterfaces.containsKey(point.getType())) {
               System.out.printf("... found InjectionPoint for MessageBundle: %s of type %s%n", point.getMember().getName(), point.getType());
        }
    }
}
项目:cdi    文件:MybatisExtension.java   
/**
 * Collect all targets to match Mappers and Session providers dependency.
 *
 * @param <X> the generic type
 * @param event the event
 */
protected <X> void processInjectionTarget(@Observes ProcessInjectionTarget<X> event) {
  final InjectionTarget<X> it = event.getInjectionTarget();
  for (final InjectionPoint ip : it.getInjectionPoints()) {
    injectionPoints.add(ip);
  }
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:ObserverExtension.java   
<T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> pit) {
    logger.info("finished the scanning process");
    processInjectionTarget++;
}
项目:Camel    文件:CdiCamelExtension.java   
private <T extends CamelContext> void camelContextBeans(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
    pit.setInjectionTarget(environment.camelContextInjectionTarget(pit.getInjectionTarget(), pit.getAnnotatedType(), manager, this));
}
项目:Camel    文件:CdiCamelExtension.java   
private <T> void camelBeansPostProcessor(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
    if (camelBeans.contains(pit.getAnnotatedType())) {
        pit.setInjectionTarget(new CamelBeanInjectionTarget<>(pit.getInjectionTarget(), manager));
    }
}
项目:Camel    文件:CdiCamelExtension.java   
private <T extends CamelContextAware> void camelContextAware(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
    pit.setInjectionTarget(new CamelBeanInjectionTarget<>(pit.getInjectionTarget(), manager));
}
项目:Java-EE    文件:LifeCycleLogger.java   
<X> void logLifecycleEvent(@Observes ProcessInjectionTarget<X> event) {
    LOGGER.info("ProcessInjectionTarget: annotatedType=" + event.getAnnotatedType());
}
项目:camel-cdi    文件:CdiCamelExtension.java   
private <T extends CamelContext> void camelContextBeans(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
    pit.setInjectionTarget(environment.camelContextInjectionTarget(pit.getInjectionTarget(), pit.getAnnotatedType(), manager));
}
项目:camel-cdi    文件:CdiCamelExtension.java   
private <T extends CamelContextAware> void camelContextAware(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
    pit.setInjectionTarget(new CamelBeanInjectionTarget<>(pit.getInjectionTarget(), manager));
}
项目:camel-cdi    文件:CdiCamelExtension.java   
private <T> void camelBeansPostProcessor(@Observes ProcessInjectionTarget<T> pit, BeanManager manager) {
    if (camelBeans.contains(pit.getAnnotatedType()))
        pit.setInjectionTarget(new CamelBeanInjectionTarget<>(pit.getInjectionTarget(), manager));
}
项目:Ka-Websocket    文件:WebSocketEventExtension.java   
/**
 * Handle all injections
 * 
 * @param pit ProcessInjectionTarget to inspect.
 **/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void processInjectorTarger(@Observes ProcessInjectionTarget<Object> pit) {
     pit.setInjectionTarget(new RegisterWebSocketEventListenerInjectionTarget(pit.getInjectionTarget(), listenerCandidates, servletConfigs));         

}
项目:deltaspike    文件:MockExtension.java   
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));
}
项目:CDIProperties    文件:PropertyInjectionTarget.java   
/**
 * Constructor accepting all required values for injection
 *
 * @param injectableValues
 *      - injectable values for this instances of this type
 * @param pit
 *      - the process injection target
 * @param it
 *      - The current instance to be injected
 */
public PropertyInjectionTarget(final Map<Field, Object> injectableValues, final ProcessInjectionTarget<T> pit, InjectionTarget<T> it) {
    this.injectableValues = injectableValues;
    this.pit = pit;
    this.it = it;

}
项目:cdi-properties    文件:PropertyExtension.java   
/**
 * Processes every available CDI injection target and wires it up with the necessary
 * property resolution processing
 * 
 * @param pit
 *            The injection target being configured
 * @param beanManager
 *            The CDI bean manager
 */
<T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> pit, BeanManager beanManager) {
    InjectionTarget<T> it = pit.getInjectionTarget();
    AnnotatedType<T> at = pit.getAnnotatedType();
    PropertyFormat propertyFormat = PropertyFormatFactory.getInstance();
    pit.setInjectionTarget(new PropertyResolverInjectionTarget<T>(it, at, resolverGateway
            .getResolver(PropertyResolverBean.class), propertyFormat));
}