KickJava   Java API By Example, From Geeks To Geeks.

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


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

17 package org.apache.servicemix.store;
18
19 import java.io.IOException JavaDoc;
20
21 /**
22  * A Store is an interface representing a storage where objects can be
23  * put and retrieved. A store can support different features, mainly
24  * persistence, clustered or transactional.
25  *
26  * A store is not designed to be a thread-safe map. If a user tries to
27  * store an object with an existing id, the behavior is undefined.
28  *
29  * @author gnodet
30  */

31 public interface Store {
32
33     String JavaDoc PERSISTENT = "Persistent";
34     
35     String JavaDoc CLUSTERED = "Clustered";
36     
37     String JavaDoc TRANSACTIONAL = "Transactional";
38     
39     /**
40      * Returns true if the store implementation supports the given feature.
41      * @param name the feature to check
42      * @return <code>true</code> if the feature is supported
43      */

44     public boolean hasFeature(String JavaDoc name);
45     
46     /**
47      * Put an object in the store under the given id.
48      * This method must be used with caution and the behavior is
49      * unspecified if an object already exist for the same id.
50      *
51      * @param id the id of the object to store
52      * @param data the object to store
53      * @throws IOException if an error occurs
54      */

55     public void store(String JavaDoc id, Object JavaDoc data) throws IOException JavaDoc;
56     
57     /**
58      * Put an object into the store and return the unique id that
59      * may be used at a later time to retrieve the object.
60      *
61      * @param data the object to store
62      * @return the id of the object stored
63      * @throws IOException if an error occurs
64      */

65     public String JavaDoc store(Object JavaDoc data) throws IOException JavaDoc;
66     
67     /**
68      * Loads an object that has been previously stored under the specified key.
69      * The object is removed from the store.
70      *
71      * @param id the id of the object
72      * @return the object, or <code>null></code> if the object could not be found
73      * @throws IOException if an error occurs
74      */

75     public Object JavaDoc load(String JavaDoc id) throws IOException JavaDoc;
76     
77 }
78
Popular Tags