Search in sources :

Example 1 with WeldInjectionTarget

use of org.jboss.weld.manager.api.WeldInjectionTarget in project wildfly by wildfly.

the class WeldComponentService method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
        beanManager = weldContainerSupplier.get().getBeanManager(beanDeploymentArchiveId);
        for (final Class<?> interceptor : interceptorClasses) {
            AnnotatedType<?> type = beanManager.createAnnotatedType(interceptor);
            @SuppressWarnings("rawtypes") InjectionTarget injectionTarget = beanManager.getInjectionTargetFactory(type).createInterceptorInjectionTarget();
            interceptorInjections.put(interceptor, beanManager.fireProcessInjectionTarget(type, injectionTarget));
        }
        if (ejbName != null) {
            EjbDescriptor<Object> descriptor = beanManager.getEjbDescriptor(ejbName);
            // may happen if the Jakarta Enterprise Beans were vetoed
            if (descriptor != null) {
                bean = beanManager.getBean(descriptor);
            }
        }
        if (bean instanceof SessionBean<?>) {
            SessionBean<?> sessionBean = (SessionBean<?>) bean;
            this.injectionTarget = sessionBean.getProducer();
            return;
        }
        WeldInjectionTarget<?> injectionTarget = InjectionTargets.createInjectionTarget(componentClass, bean, beanManager, !isComponentWithView);
        for (ComponentSupport support : ServiceLoader.load(ComponentSupport.class, WildFlySecurityManager.getClassLoaderPrivileged(WeldComponentService.class))) {
            if (support.isProcessing(componentDescription)) {
                this.injectionTarget = support.processInjectionTarget(injectionTarget, componentDescription, beanManager);
                break;
            }
        }
        if (this.injectionTarget == null) {
            this.injectionTarget = injectionTarget;
        }
        beanManager.getServices().get(InjectionTargetService.class).validateProducer(injectionTarget);
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
    }
}
Also used : ComponentSupport(org.jboss.as.weld.spi.ComponentSupport) SessionBean(org.jboss.weld.bean.SessionBean) InjectionTargetService(org.jboss.weld.injection.producer.InjectionTargetService) WeldInjectionTarget(org.jboss.weld.manager.api.WeldInjectionTarget) InjectionTarget(javax.enterprise.inject.spi.InjectionTarget)

Aggregations

InjectionTarget (javax.enterprise.inject.spi.InjectionTarget)1 ComponentSupport (org.jboss.as.weld.spi.ComponentSupport)1 SessionBean (org.jboss.weld.bean.SessionBean)1 InjectionTargetService (org.jboss.weld.injection.producer.InjectionTargetService)1 WeldInjectionTarget (org.jboss.weld.manager.api.WeldInjectionTarget)1