Changeset 2594
- Timestamp:
- 07/05/08 22:16:05 (3 months ago)
- Location:
- trunk/components/server/src/ome/services/sessions
- Files:
-
- 3 modified
-
SessionContextImpl.java (modified) (3 diffs)
-
SessionManager.java (modified) (1 diff)
-
SessionManagerImpl.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/server/src/ome/services/sessions/SessionContextImpl.java
r2592 r2594 11 11 import java.util.Collections; 12 12 import java.util.List; 13 import java.util.concurrent.atomic.AtomicInteger;14 13 15 14 import ome.model.meta.Session; … … 17 16 public class SessionContextImpl implements SessionContext { 18 17 19 private final AtomicInteger refCount = new AtomicInteger(0); 18 private int ref = 0; 19 private final Object refLock = new Object(); 20 20 private final Session session; 21 21 private final List<Long> leaderOfGroups; … … 34 34 35 35 public int refCount() { 36 return refCount.get(); 36 synchronized (refLock) { 37 return ref; 38 } 37 39 } 38 40 39 41 public int increment() { 40 return refCount.incrementAndGet(); 42 synchronized (refLock) { 43 if (ref < 0) { 44 ref = 1; 45 } else { 46 ref = ref + 1; 47 } 48 return ref; 49 } 41 50 } 42 51 43 52 public int decrement() { 44 return refCount.decrementAndGet(); 53 synchronized (refLock) { 54 if (ref < 1) { 55 ref = 0; 56 } else { 57 ref = ref - 1; 58 } 59 return ref; 60 } 45 61 } 46 62 -
trunk/components/server/src/ome/services/sessions/SessionManager.java
r2592 r2594 75 75 Session find(String uuid); 76 76 77 void close(String uuid); 77 /** 78 * If reference count for the session is less than 1, close the session. 79 * Otherwise decrement the reference count. The current reference count is 80 * returned. If -1, then no such session existed. If -2, then the session 81 * was removed. 82 */ 83 int close(String uuid); 78 84 79 85 // Security methods -
trunk/components/server/src/ome/services/sessions/SessionManagerImpl.java
r2592 r2594 313 313 /* 314 314 */ 315 public voidclose(String uuid) {315 public int close(String uuid) { 316 316 317 317 SessionContext ctx; … … 319 319 ctx = cache.getSessionContext(uuid); 320 320 } catch (SessionException se) { 321 return ; // EARLY EXIT!321 return -1; // EARLY EXIT! 322 322 } 323 323 … … 340 340 // since ehcache is not tx-friendly. 341 341 cache.removeSession(uuid); 342 return -2; 343 } else { 344 return refCount; 342 345 } 343 346 }
