01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package org.terracotta.modules.ehcache.commons_1_0.util;
05:
06: import com.tc.config.lock.LockLevel;
07: import com.tc.object.bytecode.ManagerUtil;
08: import com.tc.properties.TCProperties;
09:
10: public class Util {
11: private final static String LOCK_CONCURRENT = "CONCURRENT";
12:
13: public static int hash(Object obj, int limit) {
14: return com.tc.util.Util.hash(obj, limit);
15: }
16:
17: public static int getEhcacheReadLockLevel() {
18: int lockLevel = LockLevel.READ;
19: TCProperties ehcacheProperies = ManagerUtil.getTCProperties()
20: .getPropertiesFor("ehcache.lock");
21: if (ehcacheProperies != null) {
22: String lockLevelStr = ehcacheProperies
23: .getProperty("readLevel");
24: if (LOCK_CONCURRENT.equalsIgnoreCase(lockLevelStr)) {
25: lockLevel = LockLevel.CONCURRENT;
26: }
27: }
28: return lockLevel;
29: }
30:
31: public static int getEhcacheWriteLockLevel() {
32: int lockLevel = LockLevel.WRITE;
33: TCProperties ehcacheProperies = ManagerUtil.getTCProperties()
34: .getPropertiesFor("ehcache.lock");
35: if (ehcacheProperies != null) {
36: String lockLevelStr = ehcacheProperies
37: .getProperty("writeLevel");
38: if (LOCK_CONCURRENT.equalsIgnoreCase(lockLevelStr)) {
39: lockLevel = LockLevel.CONCURRENT;
40: }
41: }
42: return lockLevel;
43: }
44:
45: }
|