1 | |
package org.apache.ojb.broker.locking; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
import org.apache.ojb.broker.util.logging.LoggerFactory; |
19 | |
import org.apache.commons.lang.StringUtils; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
public class LockHelper |
26 | |
{ |
27 | |
LockHelper() |
28 | |
{ |
29 | |
} |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
public static int getIsolationLevelFor(String isoLevel) |
37 | |
{ |
38 | |
if(isoLevel == null || StringUtils.isEmpty(isoLevel)) |
39 | |
{ |
40 | |
LoggerFactory.getDefaultLogger().debug( |
41 | |
"[LockHelper] Specified isolation level string is 'null', using the default isolation level"); |
42 | |
return IsolationLevels.IL_DEFAULT; |
43 | |
} |
44 | |
if (isoLevel.equalsIgnoreCase(IsolationLevels.LITERAL_IL_READ_UNCOMMITTED)) |
45 | |
{ |
46 | |
return IsolationLevels.IL_READ_UNCOMMITTED; |
47 | |
} |
48 | |
else if (isoLevel.equalsIgnoreCase(IsolationLevels.LITERAL_IL_READ_COMMITTED)) |
49 | |
{ |
50 | |
return IsolationLevels.IL_READ_COMMITTED; |
51 | |
} |
52 | |
else if (isoLevel.equalsIgnoreCase(IsolationLevels.LITERAL_IL_REPEATABLE_READ)) |
53 | |
{ |
54 | |
return IsolationLevels.IL_REPEATABLE_READ; |
55 | |
} |
56 | |
else if (isoLevel.equalsIgnoreCase(IsolationLevels.LITERAL_IL_SERIALIZABLE)) |
57 | |
{ |
58 | |
return IsolationLevels.IL_SERIALIZABLE; |
59 | |
} |
60 | |
else if (isoLevel.equalsIgnoreCase(IsolationLevels.LITERAL_IL_OPTIMISTIC)) |
61 | |
{ |
62 | |
return IsolationLevels.IL_OPTIMISTIC; |
63 | |
} |
64 | |
else if (isoLevel.equalsIgnoreCase(IsolationLevels.LITERAL_IL_NONE)) |
65 | |
{ |
66 | |
return IsolationLevels.IL_NONE; |
67 | |
} |
68 | |
LoggerFactory.getDefaultLogger().warn("[LockHelper] Unknown isolation-level '" + isoLevel + "', using default isolation level"); |
69 | |
return IsolationLevels.IL_DEFAULT; |
70 | |
} |
71 | |
} |