/** * @see javax.servlet.http.HttpSession#getValue(java.lang.String) */ @Override @Deprecated public Object getValue(String name) { try (Lock lock = _lock.lock()) { return _sessionData.getAttribute(name); } }
/** * @see javax.servlet.http.HttpSession#getAttribute(java.lang.String) */ @Override public Object getAttribute(String name) { try (Lock lock = _lock.lock()) { checkValidForRead(); return _sessionData.getAttribute(name); } }
/** * Call the activation listeners. This must be called holding the * lock. */ public void didActivate() { HttpSessionEvent event = new HttpSessionEvent(this); for (Iterator<String> iter = _sessionData.getKeys().iterator(); iter.hasNext();) { Object value = _sessionData.getAttribute(iter.next()); if (value instanceof HttpSessionActivationListener) { HttpSessionActivationListener listener = (HttpSessionActivationListener) value; listener.sessionDidActivate(event); } } }
/** * Call the passivation listeners. This must be called holding the * lock */ public void willPassivate() { HttpSessionEvent event = new HttpSessionEvent(this); for (Iterator<String> iter = _sessionData.getKeys().iterator(); iter.hasNext();) { Object value = _sessionData.getAttribute(iter.next()); if (value instanceof HttpSessionActivationListener) { HttpSessionActivationListener listener = (HttpSessionActivationListener) value; listener.sessionWillPassivate(event); } } }
/** * @param os the output stream to save to * @param id identity of the session * @param data the info of the session * @throws IOException */ protected void save(OutputStream os, String id, SessionData data) throws IOException { DataOutputStream out = new DataOutputStream(os); out.writeUTF(id); out.writeUTF(_context.getCanonicalContextPath()); out.writeUTF(_context.getVhost()); out.writeUTF(data.getLastNode()); out.writeLong(data.getCreated()); out.writeLong(data.getAccessed()); out.writeLong(data.getLastAccessed()); out.writeLong(data.getCookieSet()); out.writeLong(data.getExpiry()); out.writeLong(data.getMaxInactiveMs()); List<String> keys = new ArrayList<String>(data.getKeys()); out.writeInt(keys.size()); ObjectOutputStream oos = new ObjectOutputStream(out); for (String name:keys) { oos.writeUTF(name); oos.writeObject(data.getAttribute(name)); } }