@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { boolean existed = ThreadContext.exists(); if (existed == false) { ThreadContext.setApplication(application); } try { return method.invoke(o, args); } finally { if (existed == false) { ThreadContext.detach(); } } } });
protected CookieManager getPersonalCookieManager() { try { if(!ThreadContext.exists() || RequestCycle.get()==null) return defaultManager; OrientDbWebSession session = OrientDbWebSession.get(); session.bind(); String id = session.getId(); if(session.isSignedIn()) id=session.getUsername()+'-'+id; return cache.get(id, new Callable<CookieManager>() { @Override public CookieManager call() throws Exception { return new CookieManager(); } }); } catch (ExecutionException e) { throw new IllegalStateException("Cookie Manager should be always calculated"); } }
protected CookieManager getPersonalCookieManager() { try { if(!ThreadContext.exists() || RequestCycle.get()==null) return defaultManager; OrientDbWebSession session = OrientDbWebSession.get(); session.bind(); String id = session.getId(); if(session.isSignedIn()) id=session.getUsername()+'-'+id; return cache.get(id, new Callable<CookieManager>() { @Override public CookieManager call() throws Exception { return new CookieManager(); } }); } catch (ExecutionException e) { throw new IllegalStateException("Cookie Manager should be always calculated"); } }
Session oldSession = ThreadContext.exists() ? ThreadContext.getSession() : null; ThreadContext oldContext = ThreadContext.detach();