Package javax.enterprise.context.spi

Examples of javax.enterprise.context.spi.Context


    }

    @Override
    public Object getSessionBeanProxy(Bean<?> bean, Class<?> interfce, CreationalContext<?> creationalContext) {

        final Context context = webBeansContext.getBeanManagerImpl().getContext(bean.getScope());

        final CreationalContext<Object> cc = (CreationalContext<Object>) creationalContext;
        final Contextual<Object> component = (Contextual<Object>) bean;

        return context.get(component, cc);

    }
View Full Code Here


        if (logger.isDebugEnabled()) {
            logger.debug(">lazyStartSessionContext");
        }

        Context webContext = null;
        Context context = getCurrentContext(RequestScoped.class);
        if (context instanceof ServletRequestContext) {
            ServletRequestContext requestContext = (ServletRequestContext) context;
            HttpServletRequest servletRequest = requestContext.getServletRequest();
            if (null != servletRequest) { // this could be null if there is no active request context
                try {
View Full Code Here

        }
    }

    private boolean ensureRequestScope()
    {
        Context context = this.lifeCycle.getContextService().getCurrentContext(RequestScoped.class);
       
        if (context == null || !context.isActive())
        {
            requestInitialized(null);
            return true;
        }
        return false;
View Full Code Here

    @Test(groups = INTEGRATION, expectedExceptions = { ContextNotActiveException.class, IllegalStateException.class })
    @SpecAssertions({ @SpecAssertion(section = "5.4.2", id = "ab"), @SpecAssertion(section = "6.5.4", id = "a") })
    public void testInactiveScope() throws Exception {
        assert getCurrentConfiguration().getContexts().getRequestContext().isActive();
        Context ctx = getCurrentConfiguration().getContexts().getRequestContext();
        setContextInactive(ctx);
        assert !getCurrentConfiguration().getContexts().getRequestContext().isActive();
        try {
            getInstanceByType(TunedTuna.class).getState();
        } finally {
View Full Code Here

    @SpecAssertion(section = "6.4", id = "f")
    public void testContextGetWithCreateFalseReturnsNull() {
        Set<Bean<Fox>> foxBeans = getBeans(Fox.class);
        assert foxBeans.size() == 1;
        Bean<Fox> foxBean = foxBeans.iterator().next();
        Context context = getCurrentManager().getContext(Dependent.class);
        assert context.get(foxBean, null) == null;
    }
View Full Code Here

    @SpecAssertions({ @SpecAssertion(section = "7.3.2", id = "bc"), @SpecAssertion(section = "7.3.3", id = "c") })
    public void testDestroyRemovesSFSB() throws Exception {
        GrossStadt frankfurt = getInstanceByType(GrossStadt.class);
        Bean<KleinStadt> stadtBean = getBeans(KleinStadt.class).iterator().next();
        assert stadtBean != null : "Expected a bean for stateful session bean Kassel";
        Context requestContext = getCurrentManager().getContext(RequestScoped.class);
        CreationalContext<KleinStadt> creationalContext = getCurrentManager().createCreationalContext(stadtBean);
        KleinStadt kassel = stadtBean.create(creationalContext);
        kassel.ping();
        stadtBean.destroy(kassel, creationalContext);

        assert frankfurt.isKleinStadtDestroyed() : "Expected SFSB bean to be destroyed";
        kassel = requestContext.get(stadtBean);
        assert kassel == null : "SFSB bean should not exist after being destroyed";
        // frankfurt.dispose();
    }
View Full Code Here

    }

    @Test(groups = LIFECYCLE)
    @SpecAssertions({ @SpecAssertion(section = "6.2", id = "l") })
    public void testContextCreatesNewInstanceForInjection() {
        Context requestContext = getCurrentManager().getContext(RequestScoped.class);
        Bean<Tuna> tunaBean = getBeans(Tuna.class).iterator().next();
        assert requestContext.get(tunaBean) == null;
        TunaFarm tunaFarm = getInstanceByType(TunaFarm.class);
        assert tunaFarm.tuna != null;
    }
View Full Code Here

    }

    @Test
    @SpecAssertion(section = "11.5.2", id = "f")
    public void testAddContext() {
        Context context = getCurrentManager().getContext(SuperScoped.class);
        assertNotNull(context);
        assertTrue(context.isActive());
        assertTrue(context instanceof SuperContext);
    }
View Full Code Here

    @Test(groups = { CONTEXTS })
    @SpecAssertions({ @SpecAssertion(section = "2.4.1", id = "aa"), @SpecAssertion(section = "2.4.1", id = "ab"),
            @SpecAssertion(section = "2.4.1", id = "ac"), @SpecAssertion(section = "2.4.1", id = "ca"),
            @SpecAssertion(section = "11.3.16", id = "a") })
    public void testBuiltInContexts() {
        Context context = getCurrentManager().getContext(Dependent.class);
        assert context != null;
        context = getCurrentManager().getContext(RequestScoped.class);
        assert context != null;
        context = getCurrentManager().getContext(SessionScoped.class);
        assert context != null;
View Full Code Here

    @SpecAssertions({ @SpecAssertion(section = "6.2", id = "p"), @SpecAssertion(section = "6.3", id = "d") })
    public void testContextDestroysBeansWhenDestroyed() {
        MyContextual bean = AfterBeanDiscoveryObserver.getBean();
        bean.setShouldReturnNullInstances(false);

        Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
        CreationalContext<MySessionBean> creationalContext = getCurrentManager().createCreationalContext(bean);
        MySessionBean instance = sessionContext.get(bean, creationalContext);
        instance.ping();
        assert instance != null;
        assert bean.isCreateCalled();

        destroyContext(sessionContext);
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.