use of org.jboss.weld.environment.se.WeldContainer in project drools by kiegroup.
the class CDIInstanceExample method main.
public static void main(String[] args) {
Weld w = new Weld();
WeldContainer wc = w.initialize();
CDIInstanceExample bean = wc.instance().select(CDIInstanceExample.class).get();
bean.go(System.out);
w.shutdown();
}
use of org.jboss.weld.environment.se.WeldContainer in project Payara by payara.
the class ACCJCDIServiceImpl method createInterceptorInstance.
@Override
public <T> T createInterceptorInstance(Class<T> interceptorClass, EjbDescriptor ejbDesc, JCDIService.JCDIInjectionContext<T> ejbContext, Set<EjbInterceptor> ejbInterceptors) {
T interceptorInstance = null;
WeldContainer wc = getWeldContainer();
if (wc != null) {
BeanManager beanManager = wc.getBeanManager();
AnnotatedType<T> annotatedType = beanManager.createAnnotatedType(interceptorClass);
InjectionTarget<T> target = ((WeldManager) beanManager).getInjectionTargetFactory(annotatedType).createInterceptorInjectionTarget();
CreationalContext<T> cc = beanManager.createCreationalContext(null);
interceptorInstance = target.produce(cc);
target.inject(interceptorInstance, cc);
}
return interceptorInstance;
}
use of org.jboss.weld.environment.se.WeldContainer in project Payara by payara.
the class ACCJCDIServiceImpl method createManagedObject.
@Override
public <T> JCDIInjectionContext<T> createManagedObject(Class<T> managedClass, BundleDescriptor bundle, boolean invokePostConstruct) {
JCDIInjectionContext<T> context = null;
T managedObject = null;
try {
managedObject = createEEManagedObject(bundle.getManagedBeanByBeanClass(managedClass.getName()));
} catch (Exception e) {
e.printStackTrace();
}
WeldContainer wc = getWeldContainer();
if (wc != null) {
BeanManager beanManager = wc.getBeanManager();
AnnotatedType<T> annotatedType = beanManager.createAnnotatedType(managedClass);
InjectionTarget<T> target = beanManager.createInjectionTarget(annotatedType);
CreationalContext<T> cc = beanManager.createCreationalContext(null);
target.inject(managedObject, cc);
if (invokePostConstruct) {
target.postConstruct(managedObject);
}
context = new JCDIInjectionContextImpl<>(target, cc, managedObject);
}
return context;
}
use of org.jboss.weld.environment.se.WeldContainer in project camel by apache.
the class CamelCdiDeployment method apply.
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
WeldContainer container = weld.initialize();
context.setBeanManager(container.getBeanManager());
try {
base.evaluate();
} finally {
container.shutdown();
context.unsetBeanManager();
}
}
};
}
use of org.jboss.weld.environment.se.WeldContainer in project indy by Commonjava.
the class DefaultIndyConfigFactoryTest method weldInjection_IterateIndyConfigurators.
@Test
public void weldInjection_IterateIndyConfigurators() {
Weld weld = new Weld();
WeldContainer container = weld.initialize();
List<String> sections = new ArrayList<>();
container.instance().select(IndyConfigInfo.class).iterator().forEachRemaining((instance) -> {
String section = ConfigUtils.getSectionName(instance);
System.out.printf("Got instance: %s with section: %s\n", instance, section);
sections.add(section);
});
System.out.println(sections);
assertThat(sections.contains(ConfigurationSectionListener.DEFAULT_SECTION), equalTo(true));
assertThat(sections.contains("flatfiles"), equalTo(true));
assertThat(sections.contains("ui"), equalTo(true));
assertThat(sections.contains("storage-default"), equalTo(true));
}
Aggregations