1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * 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
18 package org.apache.geronimo.kernel.config;
19
20 import java.io.File;
21 import java.io.IOException;
22 import java.io.OutputStream;
23 import java.net.MalformedURLException;
24 import java.util.List;
25 import java.util.Set;
26
27 import org.apache.geronimo.kernel.repository.Artifact;
28 import org.apache.geronimo.gbean.AbstractName;
29
30 /**
31 * Interface to a store for Configurations.
32 *
33 * @version $Rev: 395121 $ $Date: 2006-04-18 20:50:05 -0700 (Tue, 18 Apr 2006) $
34 */
35 public interface ConfigurationStore {
36
37 /**
38 * Determines if the identified configuration is an in-place one. This
39 * means that the configuration store only stores some meta-data and the
40 * actual content of the configuration is rooted somewhere else.
41 *
42 * @param configId the unique ID of the configuration, which must be fully
43 * resolved (isResolved() == true)
44 *
45 * @return true if the identified configuration is an in-place one.
46 *
47 * @throws NoSuchConfigException if the configuration is not contained in
48 * the store
49 * @throws IOException If the store cannot be read.
50 */
51 boolean isInPlaceConfiguration(Artifact configId) throws NoSuchConfigException, IOException;
52
53 /**
54 * Move the unpacked configuration directory into this store
55 *
56 * @param configurationData the configuration data
57 * @throws IOException if the direcotyr could not be moved into the store
58 * @throws InvalidConfigException if there is a configuration problem within the source direcotry
59 */
60 void install(ConfigurationData configurationData) throws IOException, InvalidConfigException;
61
62 /**
63 * Removes a configuration from the store
64 *
65 * @param configId the id of the configuration to remove, which must be
66 * fully resolved (isResolved() == true)
67 *
68 * @throws NoSuchConfigException if the configuration is not contained in the store
69 * @throws IOException if a problem occurs during the removal
70 */
71 void uninstall(Artifact configId) throws NoSuchConfigException, IOException;
72
73 /**
74 * Loads the specified configuration into the kernel
75 *
76 * @param configId the id of the configuration to load, which must be fully
77 * resolved (isResolved() == true)
78 *
79 * @return the the configuration object
80 *
81 * @throws NoSuchConfigException if the configuration is not contained in the kernel
82 * @throws IOException if a problem occurs loading the configuration from the store
83 * @throws InvalidConfigException if the configuration is corrupt
84 */
85 ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException;
86
87 /**
88 * Determines if the store contains a configuration with the specified ID.
89 * The configuration need not be loaded or running, this just checks
90 * whether the configuration store has the data for it.
91 *
92 * @param configId the unique ID of the configuration, which must be fully
93 * resolved (isResolved() == true)
94 *
95 * @return true if the store contains the configuration
96 */
97 boolean containsConfiguration(Artifact configId);
98
99 /**
100 * Return the object name for the store.
101 *
102 * @return the object name for the store
103 */
104 String getObjectName();
105
106 /**
107 * Return the object name for the store.
108 *
109 * @return the object name for the store
110 */
111 AbstractName getAbstractName();
112
113 /**
114 * Return the configurations in the store
115 *
116 * @return a List (with entries of type ConfigurationInfo) of all the
117 * configurations contained in this configuration store
118 */
119 List listConfigurations();
120
121 /**
122 * Creates an empty directory for a new configuration with the specified configId
123 *
124 * @param configId the unique ID of the configuration, which must be fully
125 * resolved (isResolved() == true)
126 *
127 * @return the location of the new directory
128 *
129 * @throws ConfigurationAlreadyExistsException if the configuration already exists in this store
130 */
131 File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException;
132
133 /**
134 * Locate the physical locations which match the supplied path in the given
135 * artifact/module. The path may be an Ant-style pattern.
136 *
137 * @param configId the artifact to search, which must be fully resolved
138 * (isResolved() == true)
139 * @param moduleName the module name or null to search in the top-level
140 * artifact location
141 * @param path the pattern to search for within the artifact/module,
142 * which may also be null to identify the artifact or
143 * module base path
144 *
145 * @return a Set (with entries of type URL) of the matching locations
146 */
147 Set resolve(Artifact configId, String moduleName, String path) throws NoSuchConfigException, MalformedURLException;
148
149 /**
150 * Exports a configuration as a ZIP file.
151 *
152 * @param configId The unique ID of the configuration to export, which
153 * must be fully resolved (isResolved() == true)
154 * @param output The stream to write the ZIP content to
155 */
156 void exportConfiguration(Artifact configId, OutputStream output) throws IOException, NoSuchConfigException;
157 }