Search in sources :

Example 11 with ContextsService

use of org.apache.webbeans.spi.ContextsService in project deltaspike by apache.

the class OpenWebBeansContextControl method stopConversationScope.

private void stopConversationScope() {
    ContextsService contextsService = getContextsService();
    contextsService.endContext(ConversationScoped.class, null);
}
Also used : ContextsService(org.apache.webbeans.spi.ContextsService)

Example 12 with ContextsService

use of org.apache.webbeans.spi.ContextsService in project deltaspike by apache.

the class OpenWebBeansContextControl method stopSessionScope.

private void stopSessionScope() {
    ContextsService contextsService = getContextsService();
    Object mockSession = null;
    if (isServletApiAvailable()) {
        mockSession = mockSessions.get();
        mockSessions.set(null);
        mockSessions.remove();
    }
    contextsService.endContext(SessionScoped.class, mockSession);
}
Also used : ContextsService(org.apache.webbeans.spi.ContextsService)

Example 13 with ContextsService

use of org.apache.webbeans.spi.ContextsService in project deltaspike by apache.

the class OpenWebBeansContextControl method startSingletonScope.

/*
    * start scopes
    */
private void startSingletonScope() {
    ContextsService contextsService = getContextsService();
    Object mockServletContext = null;
    if (isServletApiAvailable()) {
        mockServletContext = OwbHelper.getMockServletContext();
    }
    contextsService.startContext(Singleton.class, mockServletContext);
}
Also used : ContextsService(org.apache.webbeans.spi.ContextsService)

Example 14 with ContextsService

use of org.apache.webbeans.spi.ContextsService in project deltaspike by apache.

the class OpenWebBeansContextControl method stopApplicationScope.

private void stopApplicationScope() {
    ContextsService contextsService = getContextsService();
    Object mockServletContext = null;
    if (isServletApiAvailable()) {
        mockServletContext = OwbHelper.getMockServletContext();
    }
    contextsService.endContext(ApplicationScoped.class, mockServletContext);
}
Also used : ContextsService(org.apache.webbeans.spi.ContextsService)

Example 15 with ContextsService

use of org.apache.webbeans.spi.ContextsService in project tomee by apache.

the class EnsureRequestScopeThreadLocalIsCleanUpTest method runAndCheckThreadLocal.

@Test
public void runAndCheckThreadLocal() throws Exception {
    final ApplicationComposers composers = new ApplicationComposers(EnsureRequestScopeThreadLocalIsCleanUpTest.class);
    composers.before(this);
    final CdiAppContextsService contextsService = CdiAppContextsService.class.cast(WebBeansContext.currentInstance().getService(ContextsService.class));
    assertNotNull(contextsService.getCurrentContext(RequestScoped.class));
    assertNotNull(contextsService.getCurrentContext(SessionScoped.class));
    composers.after();
    assertNull(contextsService.getCurrentContext(RequestScoped.class));
    assertNull(contextsService.getCurrentContext(SessionScoped.class));
}
Also used : SessionScoped(javax.enterprise.context.SessionScoped) ContextsService(org.apache.webbeans.spi.ContextsService) RequestScoped(javax.enterprise.context.RequestScoped) ApplicationComposers(org.apache.openejb.testing.ApplicationComposers) Test(org.junit.Test)

Aggregations

ContextsService (org.apache.webbeans.spi.ContextsService)19 RequestScoped (javax.enterprise.context.RequestScoped)4 WebBeansContext (org.apache.webbeans.config.WebBeansContext)4 Test (org.junit.Test)4 AppContext (org.apache.openejb.AppContext)3 BeanContext (org.apache.openejb.BeanContext)3 IOException (java.io.IOException)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 SessionScoped (javax.enterprise.context.SessionScoped)2 Context (javax.enterprise.context.spi.Context)2 JMSContext (javax.jms.JMSContext)2 JMSRuntimeException (javax.jms.JMSRuntimeException)2 Context (javax.naming.Context)2 InitialContext (javax.naming.InitialContext)2 NamingException (javax.naming.NamingException)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)2 WebContext (org.apache.openejb.core.WebContext)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1