*** empty log message ***
[IRC.git] / Robust / Transactions / TransactionalIO / src / TransactionalIO / core / Wrapper.java
1 /*
2  * To change this template, choose Tools | Templates
3  * and open the template in the editor.
4  */
5
6 package TransactionalIO.core;
7
8 import TransactionalIO.core.ExtendedTransaction;
9
10 import TransactionalIO.core.CustomThread;
11 import TransactionalIO.interfaces.TransactionStatu;
12 import java.util.Vector;
13
14
15 /**
16  *
17  * @author navid
18  */
19 public class Wrapper{
20     
21     
22     private ExtendedTransaction transaction = new ExtendedTransaction();
23     private static ThreadLocal IOtransactioncontainer = new ThreadLocal();
24     private static ThreadLocal onMemoryAbort = new ThreadLocal();
25     private static ThreadLocal onIOAbort = new ThreadLocal();
26     
27
28     
29     public static void prepareIOCommit(){
30         
31         getTransaction().prepareCommit();
32     }
33     
34     public static void commitIO(){
35         getTransaction().commitChanges();
36     }
37     
38     
39     
40     public static void Initialize(TransactionStatu memory){
41         ExtendedTransaction transaction = new ExtendedTransaction();
42         setTransaction(transaction);
43         transaction.setOtherSystem(memory);
44         
45         if (memory != null)
46             memory.setOtherSystem(transaction);
47         
48         
49         
50    /*     setonIOAbort(new Vector());
51         setonMemoryAbort(new Vector());
52         
53         getonIOAbort().add(new terminateHandler() {
54                     public void cleanup() {
55                         Thread.getTransaction().abort();
56                         synchronized(benchmark.lock){
57                             System.out.println(Thread.currentThread() +" KEWL");
58                         }
59                     }
60         });
61         
62         getonMemoryAbort().add(new terminateHandler() {
63                     public void cleanup() {
64                         CustomThread.getTransaction().abort();
65                         synchronized(benchmark.lock){
66                             System.out.println(Thread.currentThread() +" KEWL");
67                         }
68                     }
69         });*/
70     }
71     
72     public static void memoryCommit(){
73         
74     }
75     
76     
77     public static void setTransaction(ExtendedTransaction transaction){
78         IOtransactioncontainer.set(transaction);
79     }
80     
81    
82     
83     public static ExtendedTransaction getTransaction(){
84         return (ExtendedTransaction) IOtransactioncontainer.get(); 
85     }
86     
87     public static void setonIOAbort(Vector vec){
88         onIOAbort.set(vec);
89     }
90     
91     
92     private static Vector getonIOAbort(){
93          return (Vector) onIOAbort.get();
94     }
95
96     public static void setonMemoryAbort(Vector vec){
97         onMemoryAbort.set(vec);
98     }
99     
100     
101     private static Vector getonMemoryAbort(){
102          return (Vector) onMemoryAbort.get();
103     }
104
105         
106     
107     
108     
109     
110
111  
112 }
113
114
115