use of javax.enterprise.util.AnnotationLiteral in project AngularBeans by bessemHmidi.
the class BeanLocator method lookup.
public Object lookup(String beanName, String sessionID) {
NGSessionScopeContext.setCurrentContext(sessionID);
Set<Bean<?>> beans = beanManager.getBeans(beanName);
Class beanClass = CommonUtils.beanNamesHolder.get(beanName);
if (beans.isEmpty()) {
beans = beanManager.getBeans(beanClass, new //
AnnotationLiteral<Any>() {
});
}
Bean bean = beanManager.resolve(beans);
Class scopeAnnotationClass = bean.getScope();
Context context;
if (scopeAnnotationClass.equals(RequestScoped.class)) {
context = beanManager.getContext(scopeAnnotationClass);
if (context == null)
return bean.create(beanManager.createCreationalContext(bean));
} else {
if (scopeAnnotationClass.equals(NGSessionScopeContext.class)) {
context = NGSessionScopeContext.getINSTANCE();
} else {
context = beanManager.getContext(scopeAnnotationClass);
}
}
CreationalContext creationalContext = beanManager.createCreationalContext(bean);
Object reference = context.get(bean, creationalContext);
return reference;
}
Aggregations