當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanManager.resolve方法代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:weld,項目名稱:weld-vertx,代碼行數:12,代碼來源:WeldVertxObserversTest.java

示例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);
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:14,代碼來源:ProgrammaticBeanLookup.java

示例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));
}
 
開發者ID:weld,項目名稱:weld-vertx,代碼行數:7,代碼來源:WeldVertxObserversTest.java

示例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));
}
 
開發者ID:eclipse,項目名稱:yasson,代碼行數:6,代碼來源:CdiInjectionTest.java

示例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));
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:5,代碼來源:BeanManagerHelper.java

示例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));
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:5,代碼來源:BeanManagerHelper.java

示例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);
}
 
開發者ID:mvc-spec,項目名稱:ozark,代碼行數:16,代碼來源:CdiUtils.java

示例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 );
}
 
開發者ID:peter-mount,項目名稱:opendata-common,代碼行數:15,代碼來源:CDIUtils.java

示例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 );
}
 
開發者ID:peter-mount,項目名稱:opendata-common,代碼行數:18,代碼來源:CDIUtils.java


注:本文中的javax.enterprise.inject.spi.BeanManager.resolve方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。