Java Code Examples for org.apache.webbeans.spi.ContextsService#endContext()

The following examples show how to use org.apache.webbeans.spi.ContextsService#endContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HAOpenWebBeansTestLifeCycle.java    From HotswapAgent with GNU General Public License v2.0 6 votes vote down vote up
public void beforeStopApplication(Object endObject)
{
    WebBeansContext webBeansContext = getWebBeansContext();
    ContextsService contextsService = webBeansContext.getContextsService();
    contextsService.endContext(Singleton.class, null);
    contextsService.endContext(ApplicationScoped.class, null);
    contextsService.endContext(RequestScoped.class, null);
    contextsService.endContext(SessionScoped.class, mockHttpSession);

    ELContextStore elStore = ELContextStore.getInstance(false);
    if (elStore == null)
    {
        return;
    }
    elStore.destroyELContextStore();
}
 
Example 2
Source File: ScopeHelper.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static void stopContexts(final ContextsService contextsService, final ServletContext servletContext, final HttpSession session) throws Exception {
    contextsService.endContext(SessionScoped.class, session);
    contextsService.endContext(RequestScoped.class, null);
    contextsService.endContext(ConversationScoped.class, null);
    if (CdiAppContextsService.class.isInstance(contextsService)) {
        CdiAppContextsService.class.cast(contextsService).removeThreadLocals();
    }
}
 
Example 3
Source File: OpenWebBeansContextControl.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private void stopSingletonScope()
{
    ContextsService contextsService = getContextsService();

    Object mockServletContext = null;
    if (isServletApiAvailable())
    {
        mockServletContext = OwbHelper.getMockServletContext();
    }
    contextsService.endContext(Singleton.class, mockServletContext);
}
 
Example 4
Source File: OpenWebBeansContextControl.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private void stopApplicationScope()
{
    ContextsService contextsService = getContextsService();

    Object mockServletContext = null;
    if (isServletApiAvailable())
    {
        mockServletContext = OwbHelper.getMockServletContext();
    }
    contextsService.endContext(ApplicationScoped.class, mockServletContext);
}
 
Example 5
Source File: OpenWebBeansContextControl.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private void stopSessionScope()
{
    ContextsService contextsService = getContextsService();

    Object mockSession = null;
    if (isServletApiAvailable())
    {
        mockSession = mockSessions.get();
        mockSessions.set(null);
        mockSessions.remove();
    }
    contextsService.endContext(SessionScoped.class, mockSession);
}
 
Example 6
Source File: HAAbstractUnitTest.java    From HotswapAgent with GNU General Public License v2.0 4 votes vote down vote up
protected void restartContext(Class<? extends Annotation> scopeType)
{
    ContextsService contextsService = webBeansContext.getContextsService();
    contextsService.endContext(scopeType, null);
    contextsService.startContext(scopeType, null);
}
 
Example 7
Source File: OpenWebBeansContextControl.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
private void stopRequestScope()
{
    ContextsService contextsService = getContextsService();

    contextsService.endContext(RequestScoped.class, null);
}
 
Example 8
Source File: OpenWebBeansContextControl.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
private void stopConversationScope()
{
    ContextsService contextsService = getContextsService();

    contextsService.endContext(ConversationScoped.class, null);
}