KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > store > Store


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.excalibur.store;
18
19 import java.io.IOException JavaDoc;
20 import java.util.Enumeration JavaDoc;
21
22 import org.apache.avalon.framework.component.Component;
23
24 /**
25  * A Store is an object managing arbitrary data. It holds data stored
26  * under a given key persistently. So if you put something in a store
27  * you can be sure that the next time (even if the application restarted)
28  * your data is in the store (of course unless noone else did remove it).
29  * In some cases (like for example a cache) the data needs not to be
30  * persistent. Therefore with the two role TRANSIENT_STORE and
31  * PERSISTENT_STORE you get a store with exactly that behaviour.
32  *
33  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
34  * @version CVS $Id: Store.java,v 1.5 2004/02/28 11:47:34 cziegeler Exp $
35  */

36 public interface Store
37     extends Component
38 {
39     /** The role for a persistent store */
40     String JavaDoc ROLE = Store.class.getName();
41
42     /** The role for a transient store */
43     String JavaDoc TRANSIENT_STORE = ROLE + "/TransientStore";
44     
45     /** The role for a persistent store */
46     String JavaDoc PERSISTENT_STORE = ROLE + "/PersistentStore";
47
48     /**
49      * Get the object associated to the given unique key.
50      */

51     Object JavaDoc get( Object JavaDoc key );
52
53     /**
54      * Store the given object. It is up to the
55      * caller to ensure that the key has a persistent state across
56      * different JVM executions.
57      */

58     void store( Object JavaDoc key, Object JavaDoc value ) throws IOException JavaDoc;
59
60     /**
61      * Try to free some used memory. The transient store can simply remove
62      * some hold data, the persistent store can free all memory by
63      * writing the data to a persistent store etc.
64      */

65     void free();
66
67     /**
68      * Remove the object associated to the given key.
69      */

70     void remove( Object JavaDoc key );
71
72     /**
73      * Clear the Store of all data it holds
74      */

75     void clear();
76
77     /**
78      * Indicates if the given key is associated to a contained object.
79      */

80     boolean containsKey( Object JavaDoc key );
81
82     /**
83      * Returns the list of used keys as an Enumeration of Objects.
84      */

85     Enumeration JavaDoc keys();
86
87     /**
88      * Returns count of the objects in the store, or -1 if could not be
89      * obtained.
90      */

91     int size();
92 }
93
Popular Tags