@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; } }
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 String getSessionId() { return getSession(true).getId(); }
@Override public Object getSessionMutex() { return PortletUtils.getSessionMutex(getSession(true)); }
public Object getSessionMutex() { return PortletUtils.getSessionMutex(getSession(true)); }
public String getSessionId() { return getSession(true).getId(); }
/** * Register the given callback as to be executed after session termination. * <p>Note: The callback object should be serializable in order to survive * web app restarts. * @param name the name of the attribute to register the callback for * @param callback the callback to be executed for destruction */ protected void registerSessionDestructionCallback(String name, Runnable callback) { PortletSession session = getSession(true); session.setAttribute(DESTRUCTION_CALLBACK_NAME_PREFIX + name, new DestructionCallbackBindingListener(callback)); }
/** * Register the given callback as to be executed after session termination. * <p>Note: The callback object should be serializable in order to survive * web app restarts. * @param name the name of the attribute to register the callback for * @param callback the callback to be executed for destruction */ protected void registerSessionDestructionCallback(String name, Runnable callback) { PortletSession session = getSession(true); session.setAttribute(DESTRUCTION_CALLBACK_NAME_PREFIX + name, new DestructionCallbackBindingListener(callback)); }
protected void updateAccessedSessionAttributes() { if (!this.sessionAttributesToUpdate.isEmpty() || !this.globalSessionAttributesToUpdate.isEmpty()) { PortletSession session = getSession(false); if (session != null) { try {
@Override public void setAttribute(String name, Object value, int scope) { if (scope == SCOPE_REQUEST) { if (!isRequestActive()) { throw new IllegalStateException( "Cannot set request attribute - request is not active anymore!"); } this.request.setAttribute(name, value); } else { PortletSession session = getSession(true); if (scope == SCOPE_GLOBAL_SESSION) { session.setAttribute(name, value, PortletSession.APPLICATION_SCOPE); this.globalSessionAttributesToUpdate.remove(name); } else { session.setAttribute(name, value); this.sessionAttributesToUpdate.remove(name); } } }
@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 { PortletSession session = getSession(false); if (session != null) { if (scope == SCOPE_GLOBAL_SESSION) { Object value = session.getAttribute(name, PortletSession.APPLICATION_SCOPE); if (value != null) { this.globalSessionAttributesToUpdate.put(name, value); } return value; } else { Object value = session.getAttribute(name); if (value != null) { this.sessionAttributesToUpdate.put(name, value); } return value; } } return null; } }
public void setAttribute(String name, Object value, int scope) { if (scope == SCOPE_REQUEST) { if (!isRequestActive()) { throw new IllegalStateException( "Cannot set request attribute - request is not active anymore!"); } this.request.setAttribute(name, value); } else { PortletSession session = getSession(true); if (scope == SCOPE_GLOBAL_SESSION) { session.setAttribute(name, value, PortletSession.APPLICATION_SCOPE); synchronized (this.globalSessionAttributesToUpdate) { this.globalSessionAttributesToUpdate.remove(name); } } else { session.setAttribute(name, value); synchronized (this.sessionAttributesToUpdate) { this.sessionAttributesToUpdate.remove(name); } } } }
PortletSession session = getSession(false); if (session != null) { if (scope == SCOPE_GLOBAL_SESSION) {
@Override public void removeAttribute(String name, int scope) { if (scope == SCOPE_REQUEST) { if (isRequestActive()) { this.request.removeAttribute(name); removeRequestDestructionCallback(name); } } else { PortletSession session = getSession(false); if (session != null) { if (scope == SCOPE_GLOBAL_SESSION) { session.removeAttribute(name, PortletSession.APPLICATION_SCOPE); this.globalSessionAttributesToUpdate.remove(name); } else { session.removeAttribute(name); this.sessionAttributesToUpdate.remove(name); } } } }
public void removeAttribute(String name, int scope) { if (scope == SCOPE_REQUEST) { if (isRequestActive()) { this.request.removeAttribute(name); removeRequestDestructionCallback(name); } } else { PortletSession session = getSession(false); if (session != null) { if (scope == SCOPE_GLOBAL_SESSION) { session.removeAttribute(name, PortletSession.APPLICATION_SCOPE); synchronized (this.globalSessionAttributesToUpdate) { this.globalSessionAttributesToUpdate.remove(name); } } else { session.removeAttribute(name); synchronized (this.sessionAttributesToUpdate) { this.sessionAttributesToUpdate.remove(name); } } } } }
@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 { PortletSession session = getSession(false); if (session != null) { if (scope == SCOPE_GLOBAL_SESSION) { return StringUtils.toStringArray(session.getAttributeNames(PortletSession.APPLICATION_SCOPE)); } else { return StringUtils.toStringArray(session.getAttributeNames()); } } return new String[0]; } }
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 { PortletSession session = getSession(false); if (session != null) { if (scope == SCOPE_GLOBAL_SESSION) { return StringUtils.toStringArray(session.getAttributeNames(PortletSession.APPLICATION_SCOPE)); } else { return StringUtils.toStringArray(session.getAttributeNames()); } } else { return new String[0]; } } }