KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > lock > LockStrategyFactory


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.lock;
8
9
10 /**
11  * Factory to create LockStragtegy instance.
12  *
13  * @author Ben Wang
14  */

15 public class LockStrategyFactory
16 {
17
18    /**
19     * Transaction locking isolation level. Default.
20     */

21    private static IsolationLevel lockingLevel_ = IsolationLevel.REPEATABLE_READ;
22
23    /**
24     *
25     */

26    protected LockStrategyFactory()
27    {
28    }
29
30    public static LockStrategy getLockStrategy() {
31       return getLockStrategy(lockingLevel_);
32    }
33
34    public static LockStrategy getLockStrategy(IsolationLevel lockingLevel)
35    {
36       //if(log_.isTraceEnabled()) {
37
// log_.trace("LockStrategy is: " + lockingLevel);
38
//}
39
if (lockingLevel == null)
40          return new LockStrategyNone();
41       return lockingLevel.getLockStrategy();
42    }
43
44    public static void setIsolationLevel(IsolationLevel level)
45    {
46       lockingLevel_ = level;
47    }
48
49 }
50
Popular Tags