Exemplo n.º 1
0
 private static void closeSessions(
     Stack<SessionAndTransport> oldStack, Stack<SessionAndTransport> newStack) {
   SessionAndTransport sat;
   while ((sat = pop(oldStack)) != null) {
     if (sat.lastAccess + MAX_AGE < System.currentTimeMillis()) {
       disconnect(sat.transport);
     } else newStack.add(sat);
   }
 }
Exemplo n.º 2
0
  public static SessionAndTransport getSessionAndTransport(Properties props, Authenticator auth)
      throws MessagingException {
    String key = "" + props.hashCode();

    // Session
    SessionAndTransport sat = null;
    Stack<SessionAndTransport> satStack = getSATStack(key);
    sat = pop(satStack);

    // when sat still valid return it
    if (sat != null) {
      if (sat.lastAccess + MAX_AGE > System.currentTimeMillis()) {
        return sat.touch();
      }
      disconnect(sat.transport);
    }

    return new SessionAndTransport(key, props, auth);
  }