Search in sources :

Example 16 with WeldContainer

use of org.jboss.weld.environment.se.WeldContainer in project Payara by payara.

the class ACCJCDIServiceImpl method injectManagedObject.

@Override
public <T> void injectManagedObject(T managedObject, BundleDescriptor bundle) {
    WeldContainer wc = getWeldContainer();
    if (wc != null) {
        BeanManager beanManager = wc.getBeanManager();
        @SuppressWarnings("unchecked") AnnotatedType<T> annotatedType = beanManager.createAnnotatedType((Class<T>) managedObject.getClass());
        InjectionTarget<T> target = beanManager.createInjectionTarget(annotatedType);
        CreationalContext<T> cc = beanManager.createCreationalContext(null);
        target.inject(managedObject, cc);
    }
}
Also used : WeldContainer(org.jboss.weld.environment.se.WeldContainer) BeanManager(javax.enterprise.inject.spi.BeanManager)

Aggregations

WeldContainer (org.jboss.weld.environment.se.WeldContainer)16 Weld (org.jboss.weld.environment.se.Weld)12 Test (org.junit.Test)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 BeanManager (javax.enterprise.inject.spi.BeanManager)3 File (java.io.File)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Bean (javax.enterprise.inject.spi.Bean)1 NamingException (javax.naming.NamingException)1 KieServicesImpl (org.drools.compiler.kie.builder.impl.KieServicesImpl)1 Statement (org.junit.runners.model.Statement)1