The IsisContext class (in nof-core) is responsible for locating the current execution context. @see IsisSessionFactory
153154155156157158159160161162
return session; } } protected IsisSession createAndOpenSession(final Thread thread, final AuthenticationSession authenticationSession) { final IsisSession session = getSessionFactoryInstance().openSession(authenticationSession); session.open(); LOG.info(" opening session " + session + " (count " + sessionsByThread.size() + ") for " + authenticationSession.getUserName()); return session; }
179180181182183184185186
* @see #openSessionInstance(AuthenticationSession) */ @Override public IsisSession getSessionInstance() { final Thread thread = Thread.currentThread(); final IsisSession session = sessionsByThread.get(thread); return session; }
428429430431432433434435436437438439
*/ return null; } private void debugDisplayContext(final String selector, final DebugBuilder debug) { final IsisSession d = IsisContext.getSession(selector); if (d != null) { d.debugAll(debug); } else { debug.appendln("No context: " + selector); } }
441442443444445446447448449450
private void debugListContexts(final DebugBuilder debug) { final String[] contextIds = IsisContext.getInstance().allSessionIds(); for (final String contextId : contextIds) { debug.appendln(contextId); debug.appendln("-----"); final IsisSession d = IsisContext.getSession(contextId); d.debug(debug); debug.appendln(); } }
377378379380381382383384
// /////////////////////////////////////////////////////////// // Static Convenience methods (session scoped) // /////////////////////////////////////////////////////////// public static boolean inSession() { final IsisSession session = getInstance().getSessionInstance(); return session != null; }
385386387388389390391392393394395
/** * Convenience method returning the current {@link IsisSession}. */ public static IsisSession getSession() { final IsisSession session = getInstance().getSessionInstance(); if (session == null) { throw new IllegalStateException("No Session opened for this thread"); } return session; }
347348349350351352353354355356357358
360361362363364365366367368369
8788899091929394959697
public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler) { if(LOG.isDebugEnabled()) { LOG.debug("onRequestHandlerExecuted: handler: " + handler); } final IsisSession session = getIsisContext().getSessionInstance(); if (session != null) { try { // will commit (or abort) the transaction; // an abort will cause the exception to be thrown. getTransactionManager().endTransaction();
119120121122123124125126127128129
/** * It is not possible to throw exceptions here, hence use of {@link #onRequestHandlerExecuted(RequestCycle, IRequestHandler)}. */ @Override public synchronized void onEndRequest(RequestCycle cycle) { final IsisSession session = getIsisContext().getSessionInstance(); if (session != null) { try { // belt and braces getTransactionManager().endTransaction(); } finally {