Search in sources :

Example 1 with HttpRequestContextImpl

use of org.jboss.weld.module.web.context.http.HttpRequestContextImpl in project core by weld.

the class WeldWebModule method postContextRegistration.

@Override
public void postContextRegistration(PostContextRegistrationContext ctx) {
    final BeanIdentifierIndex index = ctx.getServices().get(BeanIdentifierIndex.class);
    final String contextId = ctx.getContextId();
    if (Reflections.isClassLoadable(ServletApiAbstraction.SERVLET_CONTEXT_CLASS_NAME, WeldClassLoaderResourceLoader.INSTANCE)) {
        // Register the Http contexts if not in
        Set<Annotation> httpQualifiers = ImmutableSet.<Annotation>builder().addAll(Bindings.DEFAULT_QUALIFIERS).add(HttpLiteral.INSTANCE).build();
        ctx.addContext(new ContextHolder<HttpSessionContext>(new HttpSessionContextImpl(contextId, index), HttpSessionContext.class, httpQualifiers));
        ctx.addContext(new ContextHolder<HttpSessionDestructionContext>(new HttpSessionDestructionContext(contextId, index), HttpSessionDestructionContext.class, httpQualifiers));
        ctx.addContext(new ContextHolder<HttpConversationContext>(new LazyHttpConversationContextImpl(contextId, ctx.getServices()), HttpConversationContext.class, httpQualifiers));
        ctx.addContext(new ContextHolder<HttpRequestContext>(new HttpRequestContextImpl(contextId), HttpRequestContext.class, httpQualifiers));
    }
}
Also used : HttpSessionDestructionContext(org.jboss.weld.module.web.context.http.HttpSessionDestructionContext) LazyHttpConversationContextImpl(org.jboss.weld.module.web.context.http.LazyHttpConversationContextImpl) Annotation(java.lang.annotation.Annotation) BeanIdentifierIndex(org.jboss.weld.serialization.BeanIdentifierIndex) HttpSessionContextImpl(org.jboss.weld.module.web.context.http.HttpSessionContextImpl) HttpSessionContext(org.jboss.weld.context.http.HttpSessionContext) HttpRequestContext(org.jboss.weld.context.http.HttpRequestContext) HttpRequestContextImpl(org.jboss.weld.module.web.context.http.HttpRequestContextImpl) HttpConversationContext(org.jboss.weld.context.http.HttpConversationContext)

Example 2 with HttpRequestContextImpl

use of org.jboss.weld.module.web.context.http.HttpRequestContextImpl in project core by weld.

the class HttpContextLifecycle method sessionDestroyed.

public void sessionDestroyed(HttpSession session) {
    // Mark the session context and conversation contexts to destroy
    // instances when appropriate
    deactivateSessionDestructionContext(session);
    boolean destroyed = getSessionContext().destroy(session);
    SessionHolder.clear();
    RequestScopedCache.endRequest();
    if (destroyed) {
        // we are outside of a request (the session timed out) and therefore the session was destroyed immediately
        // we can fire the @Destroyed(SessionScoped.class) event immediately
        sessionDestroyedEvent.fire(session);
    } else {
        // let's store its reference until then
        if (getRequestContext() instanceof HttpRequestContextImpl) {
            HttpServletRequest request = Reflections.<HttpRequestContextImpl>cast(getRequestContext()).getHttpServletRequest();
            request.setAttribute(HTTP_SESSION, session);
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpRequestContextImpl(org.jboss.weld.module.web.context.http.HttpRequestContextImpl)

Aggregations

HttpRequestContextImpl (org.jboss.weld.module.web.context.http.HttpRequestContextImpl)2 Annotation (java.lang.annotation.Annotation)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpConversationContext (org.jboss.weld.context.http.HttpConversationContext)1 HttpRequestContext (org.jboss.weld.context.http.HttpRequestContext)1 HttpSessionContext (org.jboss.weld.context.http.HttpSessionContext)1 HttpSessionContextImpl (org.jboss.weld.module.web.context.http.HttpSessionContextImpl)1 HttpSessionDestructionContext (org.jboss.weld.module.web.context.http.HttpSessionDestructionContext)1 LazyHttpConversationContextImpl (org.jboss.weld.module.web.context.http.LazyHttpConversationContextImpl)1 BeanIdentifierIndex (org.jboss.weld.serialization.BeanIdentifierIndex)1