KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > session > SessionManagerImpl


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.session;
5
6 import com.tc.util.sequence.Sequence;
7
8 public class SessionManagerImpl implements SessionManager, SessionProvider {
9
10   private final Sequence sequence;
11   private SessionID sessionID = SessionID.NULL_ID;
12   
13   public SessionManagerImpl(Sequence sequence) {
14     this.sequence = sequence;
15   }
16     
17   public synchronized SessionID getSessionID() {
18     return sessionID;
19   }
20
21   public synchronized void newSession() {
22     sessionID = new SessionID(sequence.next());
23   }
24
25   public synchronized boolean isCurrentSession(SessionID compare) {
26     return sessionID.equals(compare);
27   }
28
29   public synchronized String JavaDoc toString() {
30     return getClass().getName() + "[current session=" + sessionID + "]";
31   }
32   
33 }
34
Popular Tags