}
ht.clear(); saveLogs(); }
    public Object invoke(MethodInvocation arg0) throws Throwable    {        secSys.setCurrentDetails();        boolean readOnly = checkReadOnly(arg0);        // If read-only, we don't save the new current event, which should         // allow us to clear the session.        if ( readOnly )        {        	if (log.isDebugEnabled())        	{        		log.debug("Tx readonly. Not saving current event.");        	}        // write operations are to be expected, prepare the current details        // by saving the current event.        } else {        	secSys.setCurrentEvent((Event)ht.merge(secSys.getCurrentEvent()));        }        // now the user can be considered to be logged in.        log.info(String.format("  Auth:\tuser=%s,group=%s,event=%s(%s)",        		secSys.currentUserId(),secSys.currentGroup().getId(),        		secSys.currentEvent().getId(),secSys.currentEvent().getType()));                boolean failure = false;        Object retVal = null;        try {        	ht.execute(new EnableFilterAction(secSys));            retVal = arg0.proceed();            return retVal;        } catch (Exception ex){        	failure = true;        	throw ex;        } finally {        	try {        		        		boolean stateful = (arg0.getThis() instanceof StatefulServiceInterface);        		// stateful services should NOT be flushed, because that's part         		// of the state that should hang around.        		if ( stateful )         		{        			// we don't want to do anything, really.        		}        		        		// read-only sessions should not have anything changed.        		else if ( readOnly )	        	{	        		ht.execute(new ClearIfDirtyAction(secSys));	        	}        		        		// on failure, we want to make sure that no one attempts         		// any further changes.        		else if ( failure )	        	{        			// TODO we should probably do some forced clean up here.	        	}        		        		// stateless services, don't keep their sesssions about.        		else        		{	        		ht.flush();	        		ht.execute(new CheckDirtyAction(secSys));	        		ht.execute(new DisableFilterAction(secSys));	        	}         		        	} finally {        		secSys.clearCurrentDetails();        	}        }    }