private HttpSession obtainSession() { HttpSession session = getSession(true); Assert.state(session != null, "No HttpSession"); return session; }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return this.request; } else if (REFERENCE_SESSION.equals(key)) { return getSession(true); } else { return null; } }
private HttpSession obtainSession() { HttpSession session = getSession(true); Assert.state(session != null, "No HttpSession"); return session; }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return this.request; } else if (REFERENCE_SESSION.equals(key)) { return getSession(true); } else { return null; } }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return this.requestContext; } else if (REFERENCE_SESSION.equals(key)) { return super.getSession(true); } else { return null; } } }
/** * Update all accessed session attributes through {@code session.setAttribute} * calls, explicitly indicating to the container that they might have been modified. */ @Override protected void updateAccessedSessionAttributes() { if (!this.sessionAttributesToUpdate.isEmpty()) { // Update all affected session attributes. HttpSession session = getSession(false); if (session != null) { try { for (Map.Entry<String, Object> entry : this.sessionAttributesToUpdate.entrySet()) { String name = entry.getKey(); Object newValue = entry.getValue(); Object oldValue = session.getAttribute(name); if (oldValue == newValue && !isImmutableSessionAttribute(name, newValue)) { session.setAttribute(name, newValue); } } } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } this.sessionAttributesToUpdate.clear(); } }
@Override public Object getAttribute(String name, int scope) { if (scope == SCOPE_REQUEST) { if (!isRequestActive()) { throw new IllegalStateException( "Cannot ask for request attribute - request is not active anymore!"); } return this.request.getAttribute(name); } else { HttpSession session = getSession(false); if (session != null) { try { Object value = session.getAttribute(name); if (value != null) { this.sessionAttributesToUpdate.put(name, value); } return value; } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } return null; } }
@Override public void removeAttribute(String name, int scope) { if (scope == SCOPE_REQUEST) { if (isRequestActive()) { this.request.removeAttribute(name); removeRequestDestructionCallback(name); } } else { HttpSession session = getSession(false); if (session != null) { this.sessionAttributesToUpdate.remove(name); try { session.removeAttribute(name); // Remove any registered destruction callback as well. session.removeAttribute(DESTRUCTION_CALLBACK_NAME_PREFIX + name); } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } } }
@Override public String[] getAttributeNames(int scope) { if (scope == SCOPE_REQUEST) { if (!isRequestActive()) { throw new IllegalStateException( "Cannot ask for request attributes - request is not active anymore!"); } return StringUtils.toStringArray(this.request.getAttributeNames()); } else { HttpSession session = getSession(false); if (session != null) { try { return StringUtils.toStringArray(session.getAttributeNames()); } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } return new String[0]; } }
@Override public Object getAttribute(String name, int scope) { if (scope == SCOPE_REQUEST) { if (!isRequestActive()) { throw new IllegalStateException( "Cannot ask for request attribute - request is not active anymore!"); } return this.request.getAttribute(name); } else { HttpSession session = getSession(false); if (session != null) { try { Object value = session.getAttribute(name); if (value != null) { this.sessionAttributesToUpdate.put(name, value); } return value; } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } return null; } }
/** * Update all accessed session attributes through {@code session.setAttribute} * calls, explicitly indicating to the container that they might have been modified. */ @Override protected void updateAccessedSessionAttributes() { if (!this.sessionAttributesToUpdate.isEmpty()) { // Update all affected session attributes. HttpSession session = getSession(false); if (session != null) { try { for (Map.Entry<String, Object> entry : this.sessionAttributesToUpdate.entrySet()) { String name = entry.getKey(); Object newValue = entry.getValue(); Object oldValue = session.getAttribute(name); if (oldValue == newValue && !isImmutableSessionAttribute(name, newValue)) { session.setAttribute(name, newValue); } } } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } this.sessionAttributesToUpdate.clear(); } }
@Override public void removeAttribute(String name, int scope) { if (scope == SCOPE_REQUEST) { if (isRequestActive()) { this.request.removeAttribute(name); removeRequestDestructionCallback(name); } } else { HttpSession session = getSession(false); if (session != null) { this.sessionAttributesToUpdate.remove(name); try { session.removeAttribute(name); // Remove any registered destruction callback as well. session.removeAttribute(DESTRUCTION_CALLBACK_NAME_PREFIX + name); } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } } }
@Override public String[] getAttributeNames(int scope) { if (scope == SCOPE_REQUEST) { if (!isRequestActive()) { throw new IllegalStateException( "Cannot ask for request attributes - request is not active anymore!"); } return StringUtils.toStringArray(this.request.getAttributeNames()); } else { HttpSession session = getSession(false); if (session != null) { try { return StringUtils.toStringArray(session.getAttributeNames()); } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } return new String[0]; } }
private HttpSession obtainSession() { HttpSession session = getSession(true); Assert.state(session != null, "No HttpSession"); return session; }
private HttpSession obtainSession() { HttpSession session = getSession(true); Assert.state(session != null, "No HttpSession"); return session; }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return this.request; } else if (REFERENCE_SESSION.equals(key)) { return getSession(true); } else { return null; } }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return this.request; } else if (REFERENCE_SESSION.equals(key)) { return getSession(true); } else { return null; } }
@Override public Object resolveReference(String key) { if (REFERENCE_REQUEST.equals(key)) { return this.requestContext; } else if (REFERENCE_SESSION.equals(key)) { return super.getSession(true); } else { return null; } } }
@Override public void removeAttribute(String name, int scope) { if (scope == SCOPE_REQUEST) { if (isRequestActive()) { this.request.removeAttribute(name); removeRequestDestructionCallback(name); } } else { HttpSession session = getSession(false); if (session != null) { this.sessionAttributesToUpdate.remove(name); try { session.removeAttribute(name); // Remove any registered destruction callback as well. session.removeAttribute(DESTRUCTION_CALLBACK_NAME_PREFIX + name); } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } } }
@Override public String[] getAttributeNames(int scope) { if (scope == SCOPE_REQUEST) { if (!isRequestActive()) { throw new IllegalStateException( "Cannot ask for request attributes - request is not active anymore!"); } return StringUtils.toStringArray(this.request.getAttributeNames()); } else { HttpSession session = getSession(false); if (session != null) { try { return StringUtils.toStringArray(session.getAttributeNames()); } catch (IllegalStateException ex) { // Session invalidated - shouldn't usually happen. } } return new String[0]; } }