Search in sources :

Example 1 with NGSessionScopeInstance

use of angularBeans.context.NGSessionContextHolder.NGSessionScopeInstance in project AngularBeans by bessemHmidi.

the class NGSessionScopeContext method get.

@Override
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) {
    if (holder.get() == null)
        return null;
    Bean bean = (Bean) contextual;
    if (holder.get().getBeans().containsKey(bean.getBeanClass())) {
        return (T) holder.get().getBean(bean.getBeanClass()).instance;
    } else {
        T instance = (T) bean.create(creationalContext);
        NGSessionScopeInstance customInstance = new NGSessionScopeInstance();
        customInstance.bean = bean;
        customInstance.ctx = creationalContext;
        customInstance.instance = instance;
        holder.get().putBean(customInstance);
        return instance;
    }
}
Also used : NGSessionScopeInstance(angularBeans.context.NGSessionContextHolder.NGSessionScopeInstance) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

NGSessionScopeInstance (angularBeans.context.NGSessionContextHolder.NGSessionScopeInstance)1 Bean (javax.enterprise.inject.spi.Bean)1