Search in sources :

Example 16 with WebSession

use of cn.taketoday.web.session.WebSession in project today-infrastructure by TAKETODAY.

the class SessionScope method getConversationId.

@Override
public String getConversationId() {
    RequestContext context = RequestContextHolder.getRequired();
    WebSession session = getSession(context, false);
    if (session != null) {
        return session.getId();
    }
    return null;
}
Also used : WebSession(cn.taketoday.web.session.WebSession) RequestContext(cn.taketoday.web.RequestContext)

Example 17 with WebSession

use of cn.taketoday.web.session.WebSession in project today-infrastructure by TAKETODAY.

the class RequestMappingHandlerAdapter method handleInternal.

@Override
protected Object handleInternal(RequestContext request, HandlerMethod handlerMethod) throws Throwable {
    Object returnValue;
    checkRequest(request);
    // Execute invokeHandlerMethod in synchronized block if required.
    if (this.synchronizeOnSession) {
        if (sessionManager != null) {
        }
        WebSession session = RequestContextUtils.getSession(request, false);
        if (session != null) {
            Object mutex = WebUtils.getSessionMutex(session);
            synchronized (mutex) {
                returnValue = invokeHandlerMethod(request, handlerMethod);
            }
        } else {
            // No Session available -> no mutex necessary
            returnValue = invokeHandlerMethod(request, handlerMethod);
        }
    } else {
        // No synchronization on session demanded at all...
        returnValue = invokeHandlerMethod(request, handlerMethod);
    }
    HttpHeaders headers = request.getHeaders();
    if (!headers.containsKey(HEADER_CACHE_CONTROL)) {
        if (getSessionAttributesHandler(handlerMethod).hasSessionAttributes()) {
            applyCacheSeconds(request, cacheSecondsForSessionAttributeHandlers);
        } else {
            prepareResponse(request);
        }
    }
    return returnValue;
}
Also used : HttpHeaders(cn.taketoday.http.HttpHeaders) WebSession(cn.taketoday.web.session.WebSession)

Aggregations

WebSession (cn.taketoday.web.session.WebSession)17 RequestContext (cn.taketoday.web.RequestContext)6 Nullable (cn.taketoday.lang.Nullable)4 SessionManager (cn.taketoday.web.session.SessionManager)4 HttpHeaders (cn.taketoday.http.HttpHeaders)2 LinkedHashMap (java.util.LinkedHashMap)2