@Override protected void didReadChange(Session session, String attributeName) { // For flash persistence, after reading a value, get rid of it. session.setAttribute(attributeName, null); }
public String store(final String script) { Session session = request.getSession(true); String key = createKey(script); Integer max = 0; if ( session.getAttribute(key) != null ) { List<String> names = session.getAttributeNames(prefix); for ( String name : names ) { String[] parts = name.split("-"); Integer seq = new Integer(parts[1]); if ( seq > max ) { max = seq; } } } final String fkey = key + "-" + (max+1); session.setAttribute(fkey, script); return keyToUrl(fkey); }
public <T> boolean exists(Class<T> ssoClass) { Session session = request.getSession(false); return session != null && !session.isInvalidated() && session.getAttribute(buildKey(ssoClass)) != null; } }
public void discardChanges(String pageName) { Session session = request.getSession(false); if (session == null) return; String fullPrefix = prefix + pageName + ":"; for (String name : session.getAttributeNames(fullPrefix)) { session.setAttribute(name, null); } }
public String find(String path) { Session session = request.getSession(false); if(session != null){ String script = (String) session.getAttribute(path); session.setAttribute(path, null); return script; } return null; }
public Object get(Object instance, InstanceContext context) { Session session = getSession(); if (session == null) { return null; } return session.getAttribute(key); }
public final Collection<PersistentFieldChange> gatherFieldChanges(String pageName) { Session session = request.getSession(false); if (session == null) return Collections.emptyList(); List<PersistentFieldChange> result = newList(); String fullPrefix = prefix + pageName + ":"; for (String name : session.getAttributeNames(fullPrefix)) { Object persistedValue = session.getAttribute(name); Object applicationValue = persistedValue == null ? null : convertPersistedToApplicationValue( persistedValue); PersistentFieldChange change = buildChange(name, applicationValue); result.add(change); didReadChange(session, name); } return result; }
assertSame(session.getAttribute("dirty"), dirty); session.restoreDirtyObjects();
protected final void train_getAttributeNames(Session session, String prefix, String... names) { expect(session.getAttributeNames(prefix)).andReturn(Arrays.asList(names)); }
public boolean isSessionInvalidated() { // Double check to ensure that the session exists, but don't create it. if (session == null) { session = sessionFactory.getSession(false); } return session != null && session.isInvalidated(); }
void onActionFromNixSession() { if (getSessionExists() && !session().isInvalidated()) { session().invalidate(); } }
Object onActionFromKill() { if (!productionMode) { Session session = request.getSession(false); if (session == null) { alertManager.info("No server-side session currently exist."); } else { session.invalidate(); alertManager.info("Server-side session invalidated."); } } return devmodezone.getBody(); }
public void requestDidComplete() { Session session = request.getSession(false); if (session != null) session.restoreDirtyObjects(); } }
private void clearSession() { Session session = request.getSession(false); if (session != null) { for (String name : session.getAttributeNames()) { session.setAttribute(name, null); } } }
public Object getAttributeValue() { return getSession().getAttribute(attributeName); }
pw = newPropertyWriter(writer, session.getAttributeNames()); for (String name : session.getAttributeNames()) pw.write(name, session.getAttribute(name));
@Test public void get_attribute_names_by_prefix() { Enumeration e = Collections.enumeration(Arrays.asList("fred", "barney", "fanny")); HttpSession hs = mockHttpSession(); SessionLock lock = mockLock(); lock.acquireReadLock(); expect(hs.getAttributeNames()).andReturn(e); replay(); Session session = new SessionImpl(null, hs, lock); assertEquals(session.getAttributeNames("f"), Arrays.asList("fanny", "fred")); verify(); }
public Session getSession(boolean create) { if (session != null && session.isInvalidated()) { session = null; } if (session == null) { // TAP5-1489 - Re-storage of session attributes at end of request should be configurable session = sessionFactory.getSession(create); } return session; }
@Test public void invalidate() { HttpSession hs = mockHttpSession(); SessionLock lock = mockLock(); hs.invalidate(); replay(); Session session = new SessionImpl(null, hs, lock); session.invalidate(); verify(); }
public void set(Object instance, InstanceContext context, Object newValue) { request.getSession(true).setAttribute(key, newValue); }