use of javax.enterprise.inject.spi.BeanManager in project camel by apache.
the class CamelCdiRunner method createTest.
@Override
protected Object createTest() {
BeanManager manager = context.getBeanManager();
Set<Bean<?>> beans = manager.getBeans(getTestClass().getJavaClass(), AnyLiteral.INSTANCE);
Bean<?> bean = beans.iterator().next();
// TODO: manage lifecycle of @Dependent beans
return manager.getReference(bean, bean.getBeanClass(), manager.createCreationalContext(bean));
}
use of javax.enterprise.inject.spi.BeanManager in project camel by apache.
the class FrameworkMethodCdiInjection method evaluate.
@Override
public void evaluate() throws Throwable {
BeanManager manager = context.getBeanManager();
Type[] types = method.getMethod().getGenericParameterTypes();
Object[] parameters = new Object[types.length];
for (int i = 0; i < types.length; i++) {
// TODO: use a proper CreationalContext...
parameters[i] = manager.getInjectableReference(new FrameworkMethodInjectionPoint(method.getMethod(), i, manager), manager.createCreationalContext(null));
}
method.invokeExplosively(test, parameters);
}
use of javax.enterprise.inject.spi.BeanManager in project wildfly by wildfly.
the class WeldJspExpressionFactoryWrapper method wrap.
@Override
public ExpressionFactory wrap(ExpressionFactory expressionFactory, ServletContext servletContext) {
BeanManager beanManager = getBeanManager();
if (beanManager == null) {
//this should never happen
return expressionFactory;
}
// get JspApplicationContext.
JspApplicationContext jspAppContext = JspFactory.getDefaultFactory().getJspApplicationContext(servletContext);
// register compositeELResolver with JSP
jspAppContext.addELResolver(beanManager.getELResolver());
jspAppContext.addELContextListener(Reflections.<ELContextListener>newInstance("org.jboss.weld.el.WeldELContextListener", getClass().getClassLoader()));
return beanManager.wrapExpressionFactory(expressionFactory);
}
use of javax.enterprise.inject.spi.BeanManager in project wildfly by wildfly.
the class PortableExtensionInExternalModuleTestCase method assertPortableExtensionInjection.
private void assertPortableExtensionInjection(PortableExtensionLookup injectionTarget) {
Assert.assertNotNull(injectionTarget);
PortableExtension extension = injectionTarget.getPortableExtension();
Assert.assertNotNull(extension);
BeanManager beanManager = extension.getBeanManager();
Assert.assertNotNull(beanManager);
}
use of javax.enterprise.inject.spi.BeanManager in project wildfly by wildfly.
the class WeldBeanManagerServiceProcessor method bindBeanManager.
private void bindBeanManager(ServiceTarget serviceTarget, ServiceName beanManagerServiceName, ServiceName contextServiceName, final Collection<ServiceName> dependencies, final ServiceRegistry serviceRegistry) {
final ServiceName beanManagerBindingServiceName = contextServiceName.append("BeanManager");
dependencies.add(beanManagerBindingServiceName);
BinderService beanManagerBindingService = new BinderService("BeanManager");
final BeanManagerManagedReferenceFactory referenceFactory = new BeanManagerManagedReferenceFactory();
serviceTarget.addService(beanManagerBindingServiceName, beanManagerBindingService).addInjection(beanManagerBindingService.getManagedObjectInjector(), referenceFactory).addDependency(contextServiceName, ServiceBasedNamingStore.class, beanManagerBindingService.getNamingStoreInjector()).addDependency(beanManagerServiceName, BeanManager.class, referenceFactory.beanManager).install();
}
Aggregations