示例#1
0
 /**
  * Closes the {@link IsisSession} for the current context.
  *
  * <p>Ignored if already closed.
  *
  * <p>This method is <i>not</i> marked <tt>final</tt> so it can be overridden if necessarily.
  * Generally speaking this shouldn't be necessary; one case where it might though is if an
  * implementation has multiple concurrent uses of a session, in which case "closing" the session
  * really means just deregistering the usage of it by a particular thread; only when all threads
  * have finished with a session can it really be closed.
  */
 public void closeSessionInstance() {
   final IsisSession isisSession = getSessionInstance();
   if (isisSession != null) {
     isisSession.close();
     doClose();
   }
 }
示例#2
0
 /**
  * All known session Ids.
  *
  * <p>Provided primarily for debugging.
  */
 public String[] allSessionIds() {
   final String[] ids = new String[sessionsByThread.size()];
   int i = 0;
   for (final IsisSession data : sessionsByThread.values()) {
     ids[i++] = data.getId();
   }
   return ids;
 }
示例#3
0
 /** The {@link IsisSession} for specified {@link IsisSession#getId()}. */
 protected IsisSession getSessionInstance(final String executionContextId) {
   for (final IsisSession data : sessionsByThread.values()) {
     if (data.getId().equals(executionContextId)) {
       return data;
     }
   }
   return null;
 }
示例#4
0
 protected void shutdownAllThreads() {
   synchronized (sessionsByThread) {
     for (final Map.Entry<Thread, IsisSession> entry : sessionsByThread.entrySet()) {
       LOG.info("Shutting down thread: {}", entry.getKey().getName());
       final IsisSession data = entry.getValue();
       data.closeAll();
     }
   }
 }
示例#5
0
 /**
  * Creates a new {@link IsisSession} and binds into the current context.
  *
  * <p>Is only intended to be called through {@link
  * IsisContext#openSession(AuthenticationSession)}.
  *
  * <p>Implementation note: an alternative design would have just been to bind onto a thread local.
  *
  * @throws IllegalStateException if already opened.
  */
 public IsisSession openSessionInstance(final AuthenticationSession authenticationSession) {
   final Thread thread = Thread.currentThread();
   synchronized (sessionsByThread) {
     applySessionClosePolicy();
     final IsisSession session = getSessionFactoryInstance().openSession(authenticationSession);
     if (LOG.isDebugEnabled()) {
       LOG.debug(
           "  opening session "
               + session
               + " (count "
               + sessionsByThread.size()
               + ") for "
               + authenticationSession.getUserName());
     }
     saveSession(thread, session);
     session.open();
     return session;
   }
 }