blob: b64df44cb4b89dedeb0d6096751db133b0139b04 [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.
50 *
51 * @author fmeschbe
52 */
53public interface PersistenceManager
54{
55
56 /**
57 * Returns <code>true</code> if a persisted <code>Dictionary</code> exists
58 * for the given <code>pid</code>.
59 *
60 * @param pid The identifier for the dictionary to test.
61 */
62 boolean exists( String pid );
63
64
65 /**
66 * Returns the <code>Dictionary</code> for the given <code>pid</code>.
67 *
68 * @param pid The identifier for the dictionary to load.
69 *
70 * @return The dictionary for the identifier. This must not be
71 * <code>null</code> but may be empty.
72 *
73 * @throws IOException If an error occurrs loading the dictionary. An
74 * <code>IOException</code> must also be thrown if no dictionary
75 * exists for the given identifier.
76 */
77 Dictionary load( String pid ) throws IOException;
78
79
80 /**
81 * Returns an enumeration of all <code>Dictionary</code> objects known to
82 * this persistence manager.
83 * <p>
84 * Implementations of this method are allowed to return lazy enumerations.
85 * That is, it is allowable for the enumeration to not return a dictionary
86 * if loading it results in an error.
87 *
88 * @return A possibly empty Enumeration of all dictionaries.
89 *
90 * @throws IOException If an error occurrs getting the dictionaries.
91 */
92 Enumeration getDictionaries() throws IOException;
93
94
95 /**
96 * Stores the <code>Dictionary</code> under the given <code>pid</code>.
97 *
98 * @param pid The identifier of the dictionary.
99 * @param properties The <code>Dictionary</code> to store.
100 *
101 * @throws IOException If an error occurrs storing the dictionary. If this
102 * exception is thrown, it is expected, that
103 * {@link #exists(String) exists(pid} returns <code>false</code>.
104 */
105 void store( String pid, Dictionary properties ) throws IOException;
106
107
108 /**
109 * Removes the <code>Dictionary</code> for the given <code>pid</code>. If
110 * such a dictionary does not exist, this method has no effect.
111 *
112 * @param pid The identifier of the dictionary to delet.
113 *
114 * @throws IOException If an error occurrs deleting the dictionary. This
115 * exception must not be thrown if no dictionary with the given
116 * identifier exists.
117 */
118 void delete( String pid ) throws IOException;
119
120}