1 16 17 package org.springframework.web.context.request; 18 19 import org.springframework.beans.factory.ObjectFactory; 20 21 47 public class SessionScope extends AbstractRequestAttributesScope { 48 49 private final int scope; 50 51 52 57 public SessionScope() { 58 this.scope = RequestAttributes.SCOPE_SESSION; 59 } 60 61 74 public SessionScope(boolean globalSession) { 75 this.scope = (globalSession ? RequestAttributes.SCOPE_GLOBAL_SESSION : RequestAttributes.SCOPE_SESSION); 76 } 77 78 79 protected int getScope() { 80 return this.scope; 81 } 82 83 public String getConversationId() { 84 return RequestContextHolder.currentRequestAttributes().getSessionId(); 85 } 86 87 public Object get(String name, ObjectFactory objectFactory) { 88 Object mutex = RequestContextHolder.currentRequestAttributes().getSessionMutex(); 89 synchronized (mutex) { 90 return super.get(name, objectFactory); 91 } 92 } 93 94 public Object remove(String name) { 95 Object mutex = RequestContextHolder.currentRequestAttributes().getSessionMutex(); 96 synchronized (mutex) { 97 return super.remove(name); 98 } 99 } 100 101 } 102 | Popular Tags |