KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > util > Transaction


1 /*
2  * Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
3  * Copyright (C) 1996 - 2000 BULL
4  * Copyright (C) 1996 - 2000 INRIA
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  *
21  * Initial developer(s): Dyade
22  * Contributor(s): ScalAgent Distributed Technologies
23  */

24 package fr.dyade.aaa.util;
25
26 import java.io.*;
27
28 public interface Transaction {
29   final int INIT = 0; // Initialization state
30
final int FREE = 1; // No transaction
31
final int RUN = 2; // A transaction is running
32
final int COMMIT = 3; // A transaction is commiting
33
final int ROLLBACK = 4; // A transaction is aborting
34
final int GARBAGE = 5; // A garbage phase start
35
final int FINALIZE = 6; // During last garbage.
36

37   public static String JavaDoc[] PhaseInfo = {"init", "free",
38                                       "run", "commit", "rollback",
39                                       "garbage", "finalize"};
40
41   final int Kb = 1024;
42   final int Mb = Kb * Kb;
43
44   void init(String JavaDoc path) throws IOException;
45
46   /**
47    *
48    */

49   public int getPhase();
50
51   public String JavaDoc getPhaseInfo();
52
53   void begin() throws IOException;
54
55   File getDir();
56   String JavaDoc[] getList(String JavaDoc prefix);
57
58   boolean isPersistent();
59
60   void save(Serializable obj, String JavaDoc name) throws IOException;
61   void saveByteArray(byte[] buf, String JavaDoc name) throws IOException;
62   Object JavaDoc load(String JavaDoc name) throws IOException, ClassNotFoundException JavaDoc;
63   byte[] loadByteArray(String JavaDoc name) throws IOException, ClassNotFoundException JavaDoc;
64   void delete(String JavaDoc name);
65
66   void save(Serializable obj, String JavaDoc dirName, String JavaDoc name) throws IOException;
67   void saveByteArray(byte[] buf, String JavaDoc dirName, String JavaDoc name) throws IOException;
68   Object JavaDoc load(String JavaDoc dirName, String JavaDoc name) throws IOException, ClassNotFoundException JavaDoc;
69   byte[] loadByteArray(String JavaDoc dirName, String JavaDoc name) throws IOException;
70   void delete(String JavaDoc dirName, String JavaDoc name);
71
72   void commit() throws IOException;
73   void rollback() throws IOException;
74
75   void release() throws IOException;
76
77   /**
78    * Stops the transaction module.
79    * It waits all transactions termination, then the module is kept
80    * in a FREE 'ready to use' state.
81    */

82   void stop();
83   /**
84    * Close the transaction module.
85    * It waits all transactions termination, the module will be initialized
86    * anew before reusing it.
87    */

88   void close();
89 }
90
Popular Tags