KickJava   Java API By Example, From Geeks To Geeks.

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


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

22 package fr.dyade.aaa.util;
23
24 import java.io.File JavaDoc;
25 import java.io.IOException JavaDoc;
26
27 /**
28  * This interface defines a repository for serializable objects and bytes
29  * array.
30  */

31 public interface Repository {
32   /**
33    * Initializes the repository.
34    */

35   public void init(File JavaDoc dir) throws IOException JavaDoc;
36
37   /**
38    * Gets a list of persistent objects that name corresponds to prefix.
39    *
40    * @return The list of corresponding names.
41    */

42   public String JavaDoc[] list(String JavaDoc prefix) throws IOException JavaDoc;
43
44   /**
45    * Save the corresponding bytes array.
46    */

47   public void save(String JavaDoc dirName, String JavaDoc name, byte[] content) throws IOException JavaDoc;
48
49   /**
50    * Loads the byte array.
51    *
52    * @return The loaded bytes array.
53    */

54   public byte[] load(String JavaDoc dirName, String JavaDoc name) throws IOException JavaDoc;
55
56   /**
57    * Loads the object.
58    *
59    * @return The loaded object or null if it does not exist.
60    */

61   public Object JavaDoc loadobj(String JavaDoc dirName, String JavaDoc name) throws IOException JavaDoc, ClassNotFoundException JavaDoc;
62
63   /**
64    * Deletes the corresponding objects in repository.
65    */

66   public void delete(String JavaDoc dirName, String JavaDoc name) throws IOException JavaDoc;
67
68   /**
69    * Commits all changes to the repository.
70    */

71   public void commit() throws IOException JavaDoc;
72
73   /**
74    * Closes the repository.
75    */

76   public void close() throws IOException JavaDoc;
77
78   /**
79    * Returns the number of save operation to repository.
80    *
81    * @return The number of save operation to repository.
82    */

83   public int getNbSavedObjects();
84
85   /**
86    * Returns the number of delete operation on repository.
87    *
88    * @return The number of delete operation on repository.
89    */

90   public int getNbDeletedObjects();
91
92   /**
93    * Returns the number of useless delete operation on repository.
94    *
95    * @return The number of useless delete operation on repository.
96    */

97   public int getNbBadDeletedObjects();
98
99   /**
100    * Returns the number of load operation from repository.
101    *
102    * @return The number of load operation from repository.
103    */

104   public int getNbLoadedObjects();
105 }
106
Popular Tags