/** * Wraps all OMERO invocations with login/logout semantics. */ public Object invoke(MethodInvocation mi) throws Throwable { Principal p = getPrincipal(mi); boolean hp = hasPassword(mi); boolean close = "close".equals(mi.getMethod().getName()); if (!close && methodSecurity.isActive()) { methodSecurity.checkMethod(mi.getThis(), mi.getMethod(), p, hp); } // First try a login try { login(mi, p); } catch (SessionTimeoutException ste) { if (!close) { throw ste; } log.warn("SessionTimeoutException on close:" + p); principalHolder.login(new CloseOnNoSessionContext()); } // Assuming the above block didn't throw an // exception, then continue and cleanup. try { return mi.proceed(); } finally { logout(); } }