com.arch.cdi.CdiUtils Maven / Gradle / Ivy
package com.arch.cdi;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.CDI;
/**
* Created by wagner.araujo on 09/03/16.
*/
public final class CdiUtils {
// private static BeanManager beanManager;
private CdiUtils() {
//
}
// static {
// try {
// InitialContext initialContext = new InitialContext();
// beanManager = (BeanManager) initialContext.lookup("java:comp/BeanManager");
// } catch (NamingException e) {
// LogUtils.generate(e);
// }
// }
@Deprecated
public static BeanManager getBeanManager() {
return CDI.current().getBeanManager();
}
@Deprecated
public static T getInstanceReference(Class clazz) {
// Bean bean = (Bean) beanManager.resolve(beanManager.getBeans(clazz));
// return beanManager.getContext(bean.getScope()).get(bean, beanManager.createCreationalContext(bean));
return CDI.current().select(clazz).get();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy