use of org.apache.tapestry5.http.services.SessionPersistedObjectAnalyzer in project tapestry-5 by apache.
the class SessionImplTest method dirty_persisted_object_is_forced_to_update.
@Test
public void dirty_persisted_object_is_forced_to_update() {
HttpSession hs = mockHttpSession();
HttpServletRequest hsr = mockHttpServletRequest();
SessionPersistedObjectAnalyzer analyzer = newMock(SessionPersistedObjectAnalyzer.class);
Object dirty = new Object();
SessionLock lock = mockLock();
lock.acquireWriteLock();
train_getAttribute(hs, "dirty", dirty);
replay();
Session session = new ClusteredSessionImpl(hsr, hs, lock, analyzer);
assertSame(session.getAttribute("dirty"), dirty);
verify();
expect(analyzer.checkAndResetDirtyState(dirty)).andReturn(true);
train_getSession(hsr, false, hs);
lock.acquireWriteLock();
hs.setAttribute("dirty", dirty);
replay();
session.restoreDirtyObjects();
verify();
}
use of org.apache.tapestry5.http.services.SessionPersistedObjectAnalyzer in project tapestry-5 by apache.
the class TapestryHttpModule method contributeSessionPersistedObjectAnalyzer.
/**
* Identifies String, Number and Boolean as immutable objects, a catch-all
* handler for Object (that understands
* the {@link org.apache.tapestry5.http.annotations.ImmutableSessionPersistedObject} annotation),
* and a handler for {@link org.apache.tapestry5.http.OptimizedSessionPersistedObject}.
*
* @since 5.1.0.0
*/
@SuppressWarnings("rawtypes")
public static void contributeSessionPersistedObjectAnalyzer(MappedConfiguration<Class, SessionPersistedObjectAnalyzer> configuration) {
configuration.add(Object.class, new DefaultSessionPersistedObjectAnalyzer());
SessionPersistedObjectAnalyzer<Object> immutable = new SessionPersistedObjectAnalyzer<Object>() {
public boolean checkAndResetDirtyState(Object sessionPersistedObject) {
return false;
}
};
configuration.add(String.class, immutable);
configuration.add(Number.class, immutable);
configuration.add(Boolean.class, immutable);
configuration.add(OptimizedSessionPersistedObject.class, new OptimizedSessionPersistedObjectAnalyzer());
}
Aggregations