1public class TransactionContextUtils
2{
3 private static vlocity_cmt.VOIInvoker invoker = vlocity_cmt.VOIInvoker.getInstance();
4 private static vlocity_cmt.VlocityOpenInterface transactionContext = (vlocity_cmt.VlocityOpenInterface)invoker.invoke('DefaultTrxnCtxImplementation', 'debugCreate', null, null, null);
5
6
7 public static Boolean put(String key, Object value)
8 {
9 return (Boolean)invokeMethod('put', key, null, value);
10 }
11
12 public static Object get(String key)
13 {
14 return invokeMethod('get', key, null, null);
15 }
16
17 public static void printTransactionContext()
18 {
19 Map<String, Object> input = new Map<String, Object>();
20 Map<String, Object> output = new Map<String, Object>();
21 Map<String, Object> options = new Map<String, Object>();
22 transactionContext.invokeMethod('debug', input, output, options);
23 }
24
25 public static Object invokeMethod(String methodName, String key, Set<String> keys, Object value)
26 {
27 Map<String, Object> input = new Map<String, Object>();
28 Map<String, Object> output = new Map<String, Object>();
29 Map<String, Object> options = new Map<String, Object>();
30 if (key != null)
31 {
32 input.put('key', key);
33 }
34 else if (keys != null)
35 {
36 input.put('keys', keys);
37 }
38
39 if (value != null)
40 {
41 input.put('value', value);
42 }
43
44 transactionContext.invokeMethod(methodName, input, output, options);
45
46 return output.get('value');
47 }
48}