Search in sources :

Example 1 with ProcessInjectionPoint

use of javax.enterprise.inject.spi.ProcessInjectionPoint in project aries by apache.

the class ReferenceExtension method processInjectionTarget.

void processInjectionTarget(@Observes @SuppressWarnings("rawtypes") ProcessInjectionPoint pip, BeanManager manager) {
    InjectionPoint injectionPoint = pip.getInjectionPoint();
    Annotated annotated = injectionPoint.getAnnotated();
    Reference reference = annotated.getAnnotation(Reference.class);
    if (reference == null) {
        return;
    }
    try {
        BeanManagerImpl beanManagerImpl = ((BeanManagerProxy) manager).delegate();
        ReferenceDependency referenceDependency = new ReferenceDependency(beanManagerImpl, reference, injectionPoint);
        _referenceDependencies.add(referenceDependency);
        if (_log.isDebugEnabled()) {
            _log.debug("CDIe - Found OSGi service reference {}", referenceDependency);
        }
    } catch (Exception e) {
        if (_log.isErrorEnabled()) {
            _log.error("CDIe - Error on reference {}", reference, e);
        }
    }
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) ProcessInjectionPoint(javax.enterprise.inject.spi.ProcessInjectionPoint) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) BeanManagerImpl(org.jboss.weld.manager.BeanManagerImpl) Reference(org.osgi.service.cdi.annotations.Reference) BeanManagerProxy(org.jboss.weld.bean.builtin.BeanManagerProxy)

Example 2 with ProcessInjectionPoint

use of javax.enterprise.inject.spi.ProcessInjectionPoint in project aries by apache.

the class ConfigurationExtension method processInjectionTarget.

void processInjectionTarget(@Observes @SuppressWarnings("rawtypes") ProcessInjectionPoint pip) {
    InjectionPoint injectionPoint = pip.getInjectionPoint();
    Annotated annotated = injectionPoint.getAnnotated();
    Configuration configuration = annotated.getAnnotation(Configuration.class);
    if (configuration == null) {
        return;
    }
    Class<?> beanClass = injectionPoint.getBean().getBeanClass();
    String name = beanClass.getName();
    Named named = annotated.getAnnotation(Named.class);
    if (named != null) {
        name = named.value();
    }
    ConfigurationDependency configurationDependency = new ConfigurationDependency(_bundleContext, configuration.value(), configuration.required(), name, injectionPoint);
    _configurations.add(configurationDependency);
    if (_log.isDebugEnabled()) {
        _log.debug("CDIe - Found OSGi configuration dependency {}", configurationDependency);
    }
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) Named(javax.inject.Named) Configuration(org.osgi.service.cdi.annotations.Configuration) ProcessInjectionPoint(javax.enterprise.inject.spi.ProcessInjectionPoint) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint)

Aggregations

Annotated (javax.enterprise.inject.spi.Annotated)2 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)2 ProcessInjectionPoint (javax.enterprise.inject.spi.ProcessInjectionPoint)2 Named (javax.inject.Named)1 BeanManagerProxy (org.jboss.weld.bean.builtin.BeanManagerProxy)1 BeanManagerImpl (org.jboss.weld.manager.BeanManagerImpl)1 Configuration (org.osgi.service.cdi.annotations.Configuration)1 Reference (org.osgi.service.cdi.annotations.Reference)1