use of cn.taketoday.web.session.WebSession in project today-infrastructure by TAKETODAY.
the class SessionLocaleResolver method setSessionAttribute.
private void setSessionAttribute(RequestContext request, String attributeName, @Nullable Object attribute) {
SessionManager sessionManager = getSessionManager(request);
if (sessionManager != null) {
WebSession session = sessionManager.getSession(request);
session.setAttribute(attributeName, attribute);
}
}
use of cn.taketoday.web.session.WebSession in project today-framework 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 (synchronizeOnSession) {
WebSession session = getSession(request);
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;
}
use of cn.taketoday.web.session.WebSession in project today-framework by TAKETODAY.
the class AbstractController method handleRequest.
@Override
@Nullable
public ModelAndView handleRequest(RequestContext request) throws Exception {
if (HttpMethod.OPTIONS.matches(request.getMethodValue())) {
request.responseHeaders().set(HttpHeaders.ALLOW, getAllowHeader());
return null;
}
// Delegate to WebContentGenerator for checking and preparing.
checkRequest(request);
prepareResponse(request);
// Execute handleRequestInternal in synchronized block if required.
if (this.synchronizeOnSession) {
WebSession session = RequestContextUtils.getSession(request, false);
if (session != null) {
Object mutex = WebUtils.getSessionMutex(session);
synchronized (mutex) {
return handleRequestInternal(request);
}
}
}
return handleRequestInternal(request);
}
use of cn.taketoday.web.session.WebSession in project today-framework by TAKETODAY.
the class SessionScope method get.
@Override
public Object get(String name, Supplier<?> objectFactory) {
RequestContext context = RequestContextHolder.getRequired();
WebSession session = getSession(context);
Object sessionMutex = WebUtils.getSessionMutex(session);
synchronized (sessionMutex) {
return get(session, name, objectFactory);
}
}
use of cn.taketoday.web.session.WebSession in project today-framework 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;
}
Aggregations