Package org.apache.webbeans.context

Examples of org.apache.webbeans.context.ContextFactory


* @version $Rev$ $Date$
*/
public class ContextsImpl implements org.jboss.jsr299.tck.spi.Contexts<AbstractContext> {

    public AbstractContext getRequestContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        RequestContext ctx = (RequestContext) contextFactory.getStandardContext(RequestScoped.class);

        if (ctx == null) {
            contextFactory.initRequestContext(null);
        }

        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.REQUEST);
    }
View Full Code Here


    public void setInactive(AbstractContext context) {
        context.setActive(false);
    }

    public AbstractContext getDependentContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.DEPENDENT);
    }
View Full Code Here

* @version $Rev$ $Date$
*/
public class ContextsImpl implements org.jboss.jsr299.tck.spi.Contexts<AbstractContext> {

    public AbstractContext getRequestContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        RequestContext ctx = (RequestContext) contextFactory.getStandardContext(RequestScoped.class);

        if (ctx == null) {
            contextFactory.initRequestContext(null);
        }

        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.REQUEST);
    }
View Full Code Here

    public void setInactive(AbstractContext context) {
        context.setActive(false);
    }

    public AbstractContext getDependentContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.DEPENDENT);
    }
View Full Code Here

* @version $Rev$ $Date$
*/
public class ContextsImpl implements org.jboss.jsr299.tck.spi.Contexts<AbstractContext> {

    public AbstractContext getRequestContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        RequestContext ctx = (RequestContext) contextFactory.getStandardContext(RequestScoped.class);

        if (ctx == null) {
            contextFactory.initRequestContext(null);
        }

        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.REQUEST);
    }
View Full Code Here

    public void setInactive(AbstractContext context) {
        context.setActive(false);
    }

    public AbstractContext getDependentContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.DEPENDENT);
    }
View Full Code Here

        defineManagedBean(Producer1.class);
        defineManagedBean(Producer1ConsumerComponent.class);

        List<AbstractOwbBean<?>> comps = getComponents();

        ContextFactory contextFactory = WebBeansContext.getInstance().getContextFactory();
        contextFactory.initRequestContext(null);
        contextFactory.initApplicationContext(null);

        Assert.assertEquals(4, getDeployedComponents());

        Object obj = getManager().getInstance(comps.get(0));
       
        Assert.assertNotNull(obj);

        getInstanceByName("service");

        getManager().getInstance(comps.get(1));

        Object object = getManager().getInstance(comps.get(2));

        Assert.assertTrue(object instanceof Producer1ConsumerComponent);

        Producer1ConsumerComponent single = (Producer1ConsumerComponent) object;

        IService service = single.getService();

        Assert.assertNotNull(service);

        contextFactory.destroyApplicationContext(null);
        contextFactory.destroyRequestContext(null);
    }
View Full Code Here

    @Test
    public void testDisposal1()
    {
        clear();

        ContextFactory contextFactory = WebBeansContext.getInstance().getContextFactory();
        contextFactory.initRequestContext(null);
        contextFactory.initSessionContext(null);

        defineManagedBean(Disposal1.class);

        @SuppressWarnings("unchecked")
        List<Integer> list = (List<Integer>) getInstanceByName("createBinding1");
        Assert.assertNotNull(list);
        Assert.assertTrue(list.size() == 1);
        contextFactory.destroyRequestContext(null);

        Assert.assertTrue(Disposal1.getDISPOSCALL());

    }
View Full Code Here

     */
    private int activateContexts(Class<? extends Annotation> scopeType)
    {
        ContextsService service = webBeansContext.getService(ContextsService.class);
        Context ctx = service.getCurrentContext(scopeType);
        ContextFactory contextFactory = webBeansContext.getContextFactory();

        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)
        {
            contextFactory.initApplicationContext(null);
            return 1;

        }    
       
        return -1;
View Full Code Here

     * @param destroy if destroy context
     * @param scopeType scope type
     */
    private void deActivateContexts(boolean destroy, Class<? extends Annotation> scopeType)
    {
        ContextFactory contextFactory = webBeansContext.getContextFactory();
        if(scopeType == ApplicationScoped.class)
        {
            if(destroy)
            {
                contextFactory.destroyApplicationContext(null);
            }
            else
            {
                contextFactory.deActivateContext(ApplicationScoped.class);
            }           
        }
        else
        {
            if(destroy)
            {
                contextFactory.destroyRequestContext(null);
            }
            else
            {
                contextFactory.deActivateContext(RequestScoped.class);
            }           
        }               
    }
View Full Code Here

TOP

Related Classes of org.apache.webbeans.context.ContextFactory

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.