Search in sources :

Example 1 with Reference

use of org.osgi.service.cdi.annotations.Reference 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)

Aggregations

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