本文整理了Java中javax.enterprise.inject.spi.CDI.getBeanManager()
方法的一些代码示例,展示了CDI.getBeanManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CDI.getBeanManager()
方法的具体详情如下:
包路径:javax.enterprise.inject.spi.CDI
类名称:CDI
方法名:getBeanManager
[英]Get the CDI BeanManager for the current context
[中]
代码示例来源:origin: javax.enterprise/cdi-api
/**
* Create an injector for the given class, using the current bean manager
* @param clazz class of the unmanaged instances
*/
public Unmanaged(Class<T> clazz) {
this(CDI.current().getBeanManager(), clazz);
}
代码示例来源:origin: oracle/helidon
@Override
public BeanManager getBeanManager() {
if (beanManager == null) {
CDI<Object> cdi = CDI.current();
if (cdi != null) {
beanManager = cdi.getBeanManager();
}
}
return beanManager;
}
代码示例来源:origin: jersey/jersey
@Override
public BeanManager getBeanManager() {
InitialContext initialContext = null;
try {
initialContext = new InitialContext();
return (BeanManager) initialContext.lookup("java:comp/BeanManager");
} catch (final Exception ex) {
try {
return CDI.current().getBeanManager();
} catch (final Exception e) {
LOGGER.config(LocalizationMessages.CDI_BEAN_MANAGER_JNDI_LOOKUP_FAILED());
return null;
}
} finally {
if (initialContext != null) {
try {
initialContext.close();
} catch (final NamingException ignored) {
// no-op
}
}
}
}
}
代码示例来源:origin: HotswapProjects/HotswapAgent
if (CDI.current().getBeanManager() instanceof BeanManagerImpl) {
beanManager = ((BeanManagerImpl) CDI.current().getBeanManager()).unwrap();
} else {
beanManager = ((BeanManagerProxy) CDI.current().getBeanManager()).unwrap();
代码示例来源:origin: HotswapProjects/HotswapAgent
BeanManager bm = CDI.current().getBeanManager();
代码示例来源:origin: HotswapProjects/HotswapAgent
BeanManager bm = CDI.current().getBeanManager();
代码示例来源:origin: resteasy/Resteasy
public static BeanManager lookupBeanManagerCDIUtil()
{
BeanManager bm = null;
try
{
bm = CDI.current().getBeanManager();
}
catch (NoClassDefFoundError e)
{
LogMessages.LOGGER.debug(Messages.MESSAGES.unableToFindCDIClass(), e);
}
catch (Exception e)
{
LogMessages.LOGGER.debug(Messages.MESSAGES.errorOccurredLookingUpViaCDIUtil(), e);
}
return bm;
}
代码示例来源:origin: javax/javaee-web-api
@SuppressWarnings("unchecked")
private Map<Class<?>, Class<? extends DataModel<?>>> getDataModelClassesMap(CDI<Object> cdi) {
BeanManager beanManager = cdi.getBeanManager();
// Get the Map with classes for which a custom DataModel implementation is available from CDI
Bean<?> bean = beanManager.resolve(beanManager.getBeans("comSunFacesDataModelClassesMap"));
Object beanReference = beanManager.getReference(bean, Map.class, beanManager.createCreationalContext(bean));
return (Map<Class<?>, Class<? extends DataModel<?>>>) beanReference;
}
代码示例来源:origin: javax.faces/javax.faces-api
@SuppressWarnings("unchecked")
private Map<Class<?>, Class<? extends DataModel<?>>> getDataModelClassesMap(CDI<Object> cdi) {
BeanManager beanManager = cdi.getBeanManager();
// Get the Map with classes for which a custom DataModel implementation is available from CDI
Bean<?> bean = beanManager.resolve(beanManager.getBeans("comSunFacesDataModelClassesMap"));
Object beanReference = beanManager.getReference(bean, Map.class, beanManager.createCreationalContext(bean));
return (Map<Class<?>, Class<? extends DataModel<?>>>) beanReference;
}
代码示例来源:origin: org.glassfish/javax.faces
@SuppressWarnings("unchecked")
public static Map<Class<?>, Class<? extends DataModel<?>>> getDataModelClassesMap(CDI<Object> cdi) {
BeanManager beanManager = cdi.getBeanManager();
// Get the Map with classes for which a custom DataModel implementation is available from CDI
Bean<?> bean = beanManager.resolve(beanManager.getBeans("comSunFacesDataModelClassesMap"));
Object beanReference = beanManager.getReference(bean, Map.class, beanManager.createCreationalContext(bean));
return (Map<Class<?>, Class<? extends DataModel<?>>>) beanReference;
}
代码示例来源:origin: org.glassfish/jakarta.faces
@SuppressWarnings("unchecked")
private Map<Class<?>, Class<? extends DataModel<?>>> getDataModelClassesMap(CDI<Object> cdi) {
BeanManager beanManager = cdi.getBeanManager();
// Get the Map with classes for which a custom DataModel implementation is available from CDI
Bean<?> bean = beanManager.resolve(beanManager.getBeans("comSunFacesDataModelClassesMap"));
Object beanReference = beanManager.getReference(bean, Map.class, beanManager.createCreationalContext(bean));
return (Map<Class<?>, Class<? extends DataModel<?>>>) beanReference;
}
代码示例来源:origin: eclipse-ee4j/mojarra
@SuppressWarnings("unchecked")
private Map<Class<?>, Class<? extends DataModel<?>>> getDataModelClassesMap(CDI<Object> cdi) {
BeanManager beanManager = cdi.getBeanManager();
// Get the Map with classes for which a custom DataModel implementation is available from CDI
Bean<?> bean = beanManager.resolve(beanManager.getBeans("comSunFacesDataModelClassesMap"));
Object beanReference = beanManager.getReference(bean, Map.class, beanManager.createCreationalContext(bean));
return (Map<Class<?>, Class<? extends DataModel<?>>>) beanReference;
}
代码示例来源:origin: eclipse-ee4j/mojarra
@SuppressWarnings("unchecked")
private Map<Class<?>, Class<? extends DataModel<?>>> getDataModelClassesMap(CDI<Object> cdi) {
BeanManager beanManager = cdi.getBeanManager();
// Get the Map with classes for which a custom DataModel implementation is available from CDI
Bean<?> bean = beanManager.resolve(beanManager.getBeans("comSunFacesDataModelClassesMap"));
Object beanReference = beanManager.getReference(bean, Map.class, beanManager.createCreationalContext(bean));
return (Map<Class<?>, Class<? extends DataModel<?>>>) beanReference;
}
代码示例来源:origin: javax/javaee-web-api
/**
* Create an injector for the given class, using the current bean manager
* @param clazz class of the unmanaged instances
*/
public Unmanaged(Class<T> clazz) {
this(CDI.current().getBeanManager(), clazz);
}
代码示例来源:origin: org.jboss.weld.se/weld-se
/**
* Create an injector for the given class, using the current bean manager
*/
public Unmanaged(Class<T> clazz) {
this(CDI.current().getBeanManager(), clazz);
}
代码示例来源:origin: org.jboss.weld.servlet/weld-servlet-shaded
/**
* Create an injector for the given class, using the current bean manager
* @param clazz class of the unmanaged instances
*/
public Unmanaged(Class<T> clazz) {
this(CDI.current().getBeanManager(), clazz);
}
代码示例来源:origin: io.thorntail/microprofile-restclient-api
private static BeanManager getBeanManager(Class<?> restClientInterface) {
try {
return CDI.current().getBeanManager();
} catch (IllegalStateException e) {
LOGGER.warnf("CDI container is not available - interceptor bindings declared on %s will be ignored", restClientInterface.getSimpleName());
return null;
}
}
代码示例来源:origin: org.apache.meecrowave/meecrowave-junit
private static CreationalContext<Object> doInject(final Object instance) {
final BeanManager bm = CDI.current().getBeanManager();
final AnnotatedType<?> annotatedType = bm.createAnnotatedType(instance.getClass());
final InjectionTarget injectionTarget = bm.createInjectionTarget(annotatedType);
final CreationalContext<Object> creationalContext = bm.createCreationalContext(null);
injectionTarget.inject(instance, creationalContext);
return creationalContext;
}
代码示例来源:origin: apache/meecrowave
private static CreationalContext<Object> doInject(final Object instance) {
final BeanManager bm = CDI.current().getBeanManager();
final AnnotatedType<?> annotatedType = bm.createAnnotatedType(instance.getClass());
final InjectionTarget injectionTarget = bm.createInjectionTarget(annotatedType);
final CreationalContext<Object> creationalContext = bm.createCreationalContext(null);
injectionTarget.inject(instance, creationalContext);
return creationalContext;
}
代码示例来源:origin: br.com.caelum.vraptor/vraptor-test
@PostConstruct
public void init() throws ServletException {
BeanManager manager = CDI.current().getBeanManager();
AnnotatedType<VRaptor> type = manager.createAnnotatedType(VRaptor.class);
InjectionTarget<VRaptor> target = manager.createInjectionTarget(type);
CreationalContext<VRaptor> ctx = manager.createCreationalContext(null);
target.inject(filter, ctx);
MockFilterConfig cfg = new MockFilterConfig(context);
filter.init(cfg);
}
内容来源于网络,如有侵权,请联系作者删除!