Package javax.enterprise.context.spi

Examples of javax.enterprise.context.spi.Context


    {
        Asserts.assertNotNull(scopeType, "scopeType paramter can not be null");

        List<Context> contexts = new ArrayList<Context>();
       
        Context standardContext = null;

        standardContext = ContextFactory.getStandardContext(scopeType);

        if(standardContext != null)
        {
            if(standardContext.isActive())
            {
                contexts.add(standardContext);  
            }
        }
       
View Full Code Here


    @Override
    public Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> creationalContext)
    {
        Asserts.assertNotNull(bean, "bean parameter can not be null");

        Context context = null;
        Object instance = null;

        if (bean instanceof SerializableBean)
        {
            bean = ((SerializableBean)bean).getBean();
        }
       
        //Check type if bean type is given
        if(beanType != null)
        {
            if(!ResolutionUtil.checkBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof NewBean))
            {
                throw new IllegalArgumentException("Given bean type : " + beanType + " is not applicable for the bean instance : " + bean);
            }
           
        }
       
        if(!(creationalContext instanceof CreationalContextImpl))
        {
            creationalContext = CreationalContextFactory.getInstance().wrappedCreationalContext(creationalContext, bean);
        }       
       
               
        //Scope is normal
        if (WebBeansUtil.isScopeTypeNormal(bean.getScope()))
        {
            instance = getEjbOrJmsProxyReference(bean, beanType,creationalContext);
           
            if(instance != null)
            {
                return instance;
            }           
           
            if(this.cacheProxies.containsKey(bean))
            {
                return this.cacheProxies.get(bean);
            }
           
            //Create Managed Bean Proxy
            instance = JavassistProxyFactory.createNormalScopedBeanProxy((AbstractOwbBean<?>)bean,creationalContext);
           
        }
        //Create Pseudo-Scope Bean Instance
        else
        {
            //Get bean context
            context = getContext(bean.getScope());
           
            //Get instance for ejb or jms
            instance = getEjbOrJmsProxyReference(bean, beanType, creationalContext);
           
            if(instance != null)
            {
                return instance;
            }
           
            //Get dependent from DependentContex that create contextual instance
            instance = context.get((Bean<Object>)bean, (CreationalContext<Object>)creationalContext);
        }
       
        return instance;
    }
View Full Code Here

     * @return true if also creates context.
     */
    private int activateContexts(Class<? extends Annotation> scopeType)
    {
        ContextsService service = ServiceLoader.getService(ContextsService.class);
        Context ctx = service.getCurrentContext(scopeType);
       
        if(scopeType == RequestScoped.class)
        {
            if(ctx != null && !ctx.isActive())
            {
                ContextFactory.activateContext(scopeType);
                return 0;
            }
            else if(ctx == null)
            {
                ContextFactory.initRequestContext(null);
                return 1;
            }
           
        }
       
        ctx = service.getCurrentContext(scopeType);
        if(ctx != null && !ctx.isActive())
        {
            ContextFactory.activateContext(scopeType);
            return 0;
        }
        else if(ctx == null)
View Full Code Here

           
            //Set Ejb bean on thread local
            OpenWebBeansEjbInterceptor.setThreadLocal(this.ejbBean, getContextualCreationalContext());

            //Context of the bean
            Context webbeansContext = BeanManagerImpl.getManager().getContext(this.ejbBean.getScope());
           
            //Already saved in context?
            webbeansInstance=webbeansContext.get(this.ejbBean);
            if (webbeansInstance != null)
            {
                boolean access = method.isAccessible();
                SecurityUtil.doPrivilegedSetAccessible(method, true);
                try
                {
                    return method.invoke(webbeansInstance, arguments);
                   
                }
                finally
                {
                    SecurityUtil.doPrivilegedSetAccessible(method, access);
                }           
               
            }
           
            // Getting actual EJB Bean proxy instance
            webbeansInstance = webbeansContext.get((Contextual<Object>)this.ejbBean, getContextualCreationalContext());
           
            //Call actual method on proxy
            //Actually it is called from OWB Proxy --> EJB Proxy --> Actual Bean Instance
            boolean access = method.isAccessible();
            SecurityUtil.doPrivilegedSetAccessible(method, true);
View Full Code Here

            return (CreationalContext<Object>)this.creationalContext;
        }
       
        OwbBean<Object> contextual = (OwbBean<Object>)this.ejbBean;
        //Context of the bean
        Context webbeansContext = BeanManagerImpl.getManager().getContext(this.ejbBean.getScope());
        if (webbeansContext instanceof AbstractContext)
        {
            AbstractContext owbContext = (AbstractContext)webbeansContext;
            creationalContext = owbContext.getCreationalContext(contextual);
View Full Code Here

        return creationalContext;
    }
   
    private void initiateBeanBag(OwbBean<Object> bean, CreationalContext<Object> creationalContext)
    {
        Context webbeansContext =  BeanManagerImpl.getManager().getContext(bean.getScope());
        if (webbeansContext instanceof AbstractContext)
        {
            AbstractContext owbContext = (AbstractContext)webbeansContext;
            owbContext.initContextualBag(bean, creationalContext);
        }
View Full Code Here

   
    @SuppressWarnings("unchecked")
    protected T createInstance(CreationalContext<T> creationalContext)
    {
        Context context = BeanManagerImpl.getManager().getContext(getScope());
        Object actualInstance = context.get((Bean<Object>)this.delegateBean, (CreationalContext<Object>)creationalContext);
        T proxy = (T)JavassistProxyFactory.createDependentScopedBeanProxy(this.delegateBean, actualInstance, creationalContext);
       
        return proxy;
    }
View Full Code Here

        }
       
        OpenWebBeansEjbInterceptor.setThreadLocal(this.ejbBean, this.creationalContext);
       
        //Context of the bean
        Context webbeansContext = BeanManagerImpl.getManager().getContext(ejbBean.getScope());
       
        //Get bean instance from context
        Object webbeansInstance = webbeansContext.get((Contextual<Object>)this.ejbBean, (CreationalContext<Object>)this.creationalContext);
       
        Object result = method.invoke(webbeansInstance, arguments);
       
        OpenWebBeansEjbInterceptor.unsetThreadLocal();
       
View Full Code Here

    @SuppressWarnings("unchecked")
    public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
    {
        BeanManager beanManager = BeanManagerImpl.getManager();
       
        Context context = beanManager.getContext(bean.getScope());
       
        return context.get((Bean<Object>)bean, (CreationalContext<Object>)beanManager.createCreationalContext(bean));
       
    }
View Full Code Here

    {
        if(OpenWebBeansConfiguration.getInstance().isUseJSF2Extensions())
        {
            try
            {
                Context context = (Context)ClassUtil.getClassFromName("org.apache.webbeans.jsf.scopes.ViewScopedContext").newInstance();
                afterBeanDiscovery.addContext(context);  
               
            }
            catch(Exception e)
            {
View Full Code Here

TOP

Related Classes of javax.enterprise.context.spi.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.