@Override public boolean supportsContext(final Class<? extends Annotation> scopeType) { return scopeType.equals(RequestScoped.class) || scopeType.equals(SessionScoped.class) || scopeType.equals(ApplicationScoped.class) || scopeType.equals(Dependent.class) || scopeType.equals(Singleton.class) || scopeType.equals(ConversationScoped.class) && supportsConversation(); }
@Override public Context getCurrentContext(final Class<? extends Annotation> scopeType) { if (scopeType.equals(RequestScoped.class)) { return getRequestContext(); } else if (scopeType.equals(SessionScoped.class)) { return getSessionContext(); } else if (scopeType.equals(ApplicationScoped.class)) { return getApplicationContext(); } else if (supportsConversation() && scopeType.equals(ConversationScoped.class)) { return getConversationContext(); } else if (scopeType.equals(Dependent.class)) { return dependentContext; } else if (scopeType.equals(Singleton.class)) { return getSingletonContext(); } return null; }
@Override public void endContext(final Class<? extends Annotation> scopeType, final Object endParameters) { if (supportsContext(scopeType)) { if (scopeType.equals(RequestScoped.class)) { destroyRequestContext(); } else if (scopeType.equals(SessionScoped.class)) { destroySessionContext((HttpSession) endParameters); } else if (scopeType.equals(ApplicationScoped.class)) { destroyApplicationContext(); } else if (scopeType.equals(Dependent.class)) { //NOPMD // Do nothing } else if (scopeType.equals(Singleton.class)) { destroySingletonContext(); } else if (supportsConversation() && scopeType.equals(ConversationScoped.class)) { destroyConversationContext(); } else { if (logger.isWarningEnabled()) { logger.warning("CDI-OpenWebBeans container in OpenEJB does not support context scope " + scopeType.getSimpleName() + ". Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types"); } } } }
@Override public void startContext(final Class<? extends Annotation> scopeType, final Object startParameter) throws ContextException { if (supportsContext(scopeType)) { if (scopeType.equals(RequestScoped.class)) { initRequestContext((ServletRequestEvent) startParameter); } else if (scopeType.equals(SessionScoped.class)) { initSessionContext((HttpSession) startParameter); } else if (scopeType.equals(ApplicationScoped.class)) { initApplicationContext(); } else if (scopeType.equals(Dependent.class)) { initSingletonContext(); } else if (scopeType.equals(Singleton.class)) { //NOPMD // Do nothing } else if (supportsConversation() && scopeType.equals(ConversationScoped.class)) { initConversationContext((ConversationContext) startParameter); } else { if (logger.isWarningEnabled()) { logger.warning("CDI-OpenWebBeans container in OpenEJB does not support context scope " + scopeType.getSimpleName() + ". Scopes @Dependent, @RequestScoped, @ApplicationScoped and @Singleton are supported scope types"); } } } }
private void destroyRequestContext() { // execute request tasks endRequest(); if (supportsConversation()) { // OWB-595 cleanupConversation(); } //Get context final RequestContext context = getRequestContext(); //Destroy context if (context != null) { context.destroy(); } // clean up the EL caches after each request final ELContextStore elStore = ELContextStore.getInstance(false); if (elStore != null) { elStore.destroyELContextStore(); } //Clear thread locals - only for request to let user do with deltaspike start(session, request)restart(request)...stop() requestContext.remove(); RequestScopedBeanInterceptorHandler.removeThreadLocals(); }