public int getAttributes() { return _sessionData.getKeys().size(); }
public Set<String> getNames() { return Collections.unmodifiableSet(_sessionData.getKeys()); }
/** * @deprecated As of Version 2.2, this method is replaced by * {@link #getAttributeNames} */ @Deprecated @Override public String[] getValueNames() throws IllegalStateException { try (Lock lock = _lock.lock()) { checkValidForRead(); Iterator<String> itor = _sessionData.getKeys().iterator(); if (!itor.hasNext()) return new String[0]; ArrayList<String> names = new ArrayList<>(); while (itor.hasNext()) names.add(itor.next()); return names.toArray(new String[names.size()]); } }
/** * 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); } } }
/** * @see javax.servlet.http.HttpSession#getAttributeNames() */ @Override public Enumeration<String> getAttributeNames() { try (Lock lock = _lock.lock()) { checkValidForRead(); final Iterator<String> itor = _sessionData.getKeys().iterator(); return new Enumeration<String> () { @Override public boolean hasMoreElements() { return itor.hasNext(); } @Override public String nextElement() { return itor.next(); } }; } }
/** * @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)); } }
do keys = _sessionData.getKeys(); for (String key:keys)