Search in sources :

Example 1 with AnnotationLiteral

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;
}
Also used : Context(javax.enterprise.context.spi.Context) CreationalContext(javax.enterprise.context.spi.CreationalContext) CreationalContext(javax.enterprise.context.spi.CreationalContext) AnnotationLiteral(javax.enterprise.util.AnnotationLiteral) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

Context (javax.enterprise.context.spi.Context)1 CreationalContext (javax.enterprise.context.spi.CreationalContext)1 Bean (javax.enterprise.inject.spi.Bean)1 AnnotationLiteral (javax.enterprise.util.AnnotationLiteral)1