01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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;
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 PERSISTENT = "Persistent";
34:
35: String CLUSTERED = "Clustered";
36:
37: String 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: boolean hasFeature(String 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: void store(String id, Object data) throws IOException;
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: String store(Object data) throws IOException;
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: Object load(String id) throws IOException;
76:
77: }
|