/** * Decides if this interceptor should invalidate the session or mark the session * to be invalidated upon the next request that contains this interceptor in the stack. * * @see com.opensymphony.xwork.interceptor.AroundInterceptor#after(com.opensymphony.xwork.ActionInvocation, java.lang.String) */ protected void after(ActionInvocation invocation, String result) throws Exception { SessionMap sessionMap = (SessionMap) invocation.getInvocationContext().get(ActionContext.SESSION); if (NOW.equalsIgnoreCase(type)) { if (LOG.isDebugEnabled()) LOG.debug("type=now, invalidating session now"); sessionMap.invalidate(); LOG.info("session invalidated"); } else if (NEXT_REQUEST.equalsIgnoreCase(type)) { if (LOG.isDebugEnabled()) LOG.debug("type=NextRequest, mark key in session, such that next request that have this interceptor will invalidate the session"); sessionMap.put(key, "true"); } else if (NO_OPERATION.equalsIgnoreCase(type)) { if (LOG.isDebugEnabled()) LOG.debug("no operation"); } else { LOG.warn("unrecognized type, type should be either "+NOW+", "+NEXT_REQUEST+" or "+NO_OPERATION); } }
/** * Invalidate this session if it is marked to be invalidated from previous request. * * @see com.opensymphony.xwork.interceptor.AroundInterceptor#before(com.opensymphony.xwork.ActionInvocation) */ protected void before(ActionInvocation invocation) throws Exception { SessionMap sessionMap = (SessionMap) invocation.getInvocationContext().get(ActionContext.SESSION); if (sessionMap.containsKey(key) && sessionMap.get(key).equals("true")) { if (LOG.isDebugEnabled()) LOG.debug("found marker in session indicating this is the 'next request', session should be invalidated"); sessionMap.invalidate(); LOG.info("session invalidated"); } } }
( (SessionMap) session ).invalidate();