blob: 8073eb4b921a1e6fffad11e2d105f28b1f1724af [file] [log] [blame]
Felix Meschbergeradd2b4a2007-04-11 18:12:33 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.apache.felix.cm;
20
21
22import java.io.IOException;
23import java.util.Dictionary;
24import java.util.Enumeration;
25
26
27/**
28 * The <code>PersistenceManager</code> interface defines the API to be
29 * implemented to support persisting configuration data. This interface may
30 * be implemented by bundles, which support storing configuration data in
31 * different locations.
32 * <p>
33 * The Apache Felix Configuration Admin Service bundles provides an
34 * implementation of this interface using the platform filesystem to store
35 * configuration data.
36 * <p>
37 * Implementations of this interface must support loading and storing
38 * <code>java.util.Dictionary</code> objects as defined in section 104.4.2,
39 * Configuration Properties, of the Configuration Admin Service Specification
40 * Version 1.2.
41 * <p>
42 * To make implementations of this interface available to the Configuration
43 * Admin Service they must be registered as service for this interface. The
44 * Configuration Admin Service will consider all registered services plus the
45 * default platform file system based implementation to load configuration data.
46 * To store new configuration data, the persistence manager service with the
47 * highest rank value - the <code>service.ranking</code> service property - is
48 * used. If no pesistence manager service has been registered, the platfrom
49 * file system based implementation is used.
Felix Meschbergeradd2b4a2007-04-11 18:12:33 +000050 */
51public interface PersistenceManager
52{
53
54 /**
55 * Returns <code>true</code> if a persisted <code>Dictionary</code> exists
56 * for the given <code>pid</code>.
57 *
58 * @param pid The identifier for the dictionary to test.
59 */
60 boolean exists( String pid );
61
62
63 /**
64 * Returns the <code>Dictionary</code> for the given <code>pid</code>.
65 *
66 * @param pid The identifier for the dictionary to load.
67 *
68 * @return The dictionary for the identifier. This must not be
69 * <code>null</code> but may be empty.
70 *
71 * @throws IOException If an error occurrs loading the dictionary. An
72 * <code>IOException</code> must also be thrown if no dictionary
73 * exists for the given identifier.
74 */
75 Dictionary load( String pid ) throws IOException;
76
77
78 /**
79 * Returns an enumeration of all <code>Dictionary</code> objects known to
80 * this persistence manager.
81 * <p>
82 * Implementations of this method are allowed to return lazy enumerations.
83 * That is, it is allowable for the enumeration to not return a dictionary
84 * if loading it results in an error.
85 *
86 * @return A possibly empty Enumeration of all dictionaries.
87 *
88 * @throws IOException If an error occurrs getting the dictionaries.
89 */
90 Enumeration getDictionaries() throws IOException;
91
92
93 /**
94 * Stores the <code>Dictionary</code> under the given <code>pid</code>.
95 *
96 * @param pid The identifier of the dictionary.
97 * @param properties The <code>Dictionary</code> to store.
98 *
99 * @throws IOException If an error occurrs storing the dictionary. If this
100 * exception is thrown, it is expected, that
101 * {@link #exists(String) exists(pid} returns <code>false</code>.
102 */
103 void store( String pid, Dictionary properties ) throws IOException;
104
105
106 /**
107 * Removes the <code>Dictionary</code> for the given <code>pid</code>. If
108 * such a dictionary does not exist, this method has no effect.
109 *
110 * @param pid The identifier of the dictionary to delet.
111 *
112 * @throws IOException If an error occurrs deleting the dictionary. This
113 * exception must not be thrown if no dictionary with the given
114 * identifier exists.
115 */
116 void delete( String pid ) throws IOException;
117
118}