Search in sources :

Example 56 with Bean

use of javax.enterprise.inject.spi.Bean 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

Bean (javax.enterprise.inject.spi.Bean)56 BeanManager (javax.enterprise.inject.spi.BeanManager)26 ArrayList (java.util.ArrayList)8 BeanManagerImpl (org.apache.webbeans.container.BeanManagerImpl)7 HashSet (java.util.HashSet)5 ScopedInstance (org.eclipse.jetty.cdi.core.ScopedInstance)5 IOException (java.io.IOException)4 Annotation (java.lang.annotation.Annotation)4 CreationalContext (javax.enterprise.context.spi.CreationalContext)4 ContextControl (org.apache.deltaspike.cdise.api.ContextControl)4 Map (java.util.Map)3 NamingException (javax.naming.NamingException)3 CdiContainer (org.apache.deltaspike.cdise.api.CdiContainer)3 CarRepair (org.apache.deltaspike.cdise.tck.beans.CarRepair)3 Test (org.junit.Test)3 Method (java.lang.reflect.Method)2 Type (java.lang.reflect.Type)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2