本文整理汇总了Java中javax.enterprise.inject.spi.BeanManager.resolve方法的典型用法代码示例。如果您正苦于以下问题:Java BeanManager.resolve方法的具体用法?Java BeanManager.resolve怎么用?Java BeanManager.resolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.enterprise.inject.spi.BeanManager
的用法示例。
在下文中一共展示了BeanManager.resolve方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testVertxBean
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
@Test
public void testVertxBean() {
BeanManager beanManager = CDI.current().getBeanManager();
Bean<?> bean = beanManager.resolve(beanManager.getBeans(Vertx.class));
assertTrue(bean.getTypes().contains(Vertx.class));
assertTrue(bean.getTypes().contains(Measured.class));
Class<?> vertxClass = vertx.getClass();
for (Class<?> intf : vertxClass.getInterfaces()) {
assertTrue(bean.getTypes().contains(intf));
}
}
示例2: lookup
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Object lookup(String name, BeanManager bm) {
Set<Bean<?>> beans = bm.getBeans(name);
if (beans.isEmpty()) {
throw new IllegalStateException("CDI BeanManager cannot find an instance of requested type '" + name + "'");
}
Bean bean = bm.resolve(beans);
CreationalContext ctx = bm.createCreationalContext(bean);
// select one beantype randomly. A bean has a non-empty set of
// beantypes.
Type type = (Type) bean.getTypes().iterator().next();
return bm.getReference(bean, type, ctx);
}
示例3: testContextBean
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
@Test
public void testContextBean() {
BeanManager beanManager = CDI.current().getBeanManager();
Bean<?> bean = beanManager.resolve(beanManager.getBeans(Context.class));
assertTrue(bean.getTypes().contains(Context.class));
}
示例4: getCalledMethods
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
private CalledMethods getCalledMethods() {
final BeanManager beanManager = CDI.current().getBeanManager();
final Bean<?> resolve = beanManager.resolve(beanManager.getBeans(CalledMethods.class));
return (CalledMethods) beanManager.getReference(resolve, CalledMethods.class, beanManager.createCreationalContext(resolve));
}
示例5: getCamelContextById
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
static CamelContext getCamelContextById(BeanManager manager, String camelContextId) {
Bean<?> bean = manager.resolve(manager.getBeans(camelContextId));
return (CamelContext) manager.getReference(bean, CamelContext.class, manager.createCreationalContext(bean));
}
示例6: getDefaultCamelContext
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
static CamelContext getDefaultCamelContext(BeanManager manager) {
Bean<?> bean = manager.resolve(manager.getBeans(CamelContext.class));
return (CamelContext) manager.getReference(bean, CamelContext.class, manager.createCreationalContext(bean));
}
示例7: newBean
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
/**
* Create a new CDI bean given its class and a bean manager. The bean is created
* in the context defined by the scope annotation on the class.
*
* @param bm The BeanManager.
* @param clazz CDI class.
* @param <T> class parameter.
* @return newly allocated CDI bean.
*/
public static <T> T newBean(BeanManager bm, Class<T> clazz) {
Set<Bean<?>> beans = bm.getBeans(clazz);
final Bean<T> bean = (Bean<T>) bm.resolve(beans);
final CreationalContext<T> ctx = bm.createCreationalContext(bean);
return (T) bm.getReference(bean, clazz, ctx);
}
示例8: getBean
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
/**
* Get the named bean
*
* @param <T> type of bean
* @param name name of bean
*
* @return
*/
public static <T> Bean<T> getBean( String name )
{
BeanManager beanManager = getBeanManager();
Set beans = beanManager.getBeans( name );
return beanManager.resolve( beans );
}
示例9: getInstance
import javax.enterprise.inject.spi.BeanManager; //导入方法依赖的package包/类
/**
* Return the instance of a bean
*
* @param <T> type of bean
* @param clazz class of bean
* @param qualifiers qualifiers
*
* @return
*/
public static <T> T getInstance( Class<T> clazz, Annotation... qualifiers )
{
BeanManager beanManager = getBeanManager();
Set beans = beanManager.getBeans( clazz, qualifiers );
Bean<T> bean = beanManager.resolve( beans );
CreationalContext<T> ctx = beanManager.createCreationalContext( bean );
return (T) beanManager.getReference( bean, clazz, ctx );
}