/** * Call {@link ScriptSession#invalidate()} on the {@link ScriptSession} * that called this method. * Used by the page unloader. */ public void pageUnloaded() { WebContext wctx = WebContextFactory.get(); ScriptSession scriptSession = wctx.getScriptSession(); log.debug("pageUnloaded is invalidating scriptSession: " + scriptSession); scriptSession.invalidate(); }
public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception { ScriptSession session = WebContextFactory.get().getScriptSession(); Long lastAccess = (Long) session.getAttribute(ATTRIBUTE_LAST_ACTION); // Free pass in if you've not done anything so far. if (lastAccess != null) { long now = System.currentTimeMillis(); if (now > lastAccess + actionTimeoutMillis) { session.addScript(new ScriptBuffer(onTimeout)); session.invalidate(); throw new DwrConvertedException("Your session has timed out"); } } Object reply = chain.doFilter(obj, method, params); session.setAttribute(ATTRIBUTE_LAST_ACTION, System.currentTimeMillis()); return reply; }