001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.kernel.config;
017:
018: import java.io.File;
019: import java.io.IOException;
020: import java.io.OutputStream;
021: import java.net.MalformedURLException;
022: import java.net.URL;
023: import java.util.List;
024: import java.util.Set;
025:
026: import org.apache.geronimo.kernel.repository.Artifact;
027: import org.apache.geronimo.gbean.AbstractName;
028:
029: /**
030: * Interface to a store for Configurations.
031: *
032: * @version $Rev: 566893 $ $Date: 2007-08-16 17:52:52 -0700 (Thu, 16 Aug 2007) $
033: */
034: public interface ConfigurationStore {
035:
036: /**
037: * Determines if the identified configuration is an in-place one. This
038: * means that the configuration store only stores some meta-data and the
039: * actual content of the configuration is rooted somewhere else.
040: *
041: * @param configId the unique ID of the configuration, which must be fully
042: * resolved (isResolved() == true)
043: *
044: * @return true if the identified configuration is an in-place one.
045: *
046: * @throws NoSuchConfigException if the configuration is not contained in
047: * the store
048: * @throws IOException If the store cannot be read.
049: */
050: boolean isInPlaceConfiguration(Artifact configId)
051: throws NoSuchConfigException, IOException;
052:
053: /**
054: * Move the unpacked configuration directory into this store
055: *
056: * @param configurationData the configuration data
057: * @throws IOException if the direcotyr could not be moved into the store
058: * @throws InvalidConfigException if there is a configuration problem within the source direcotry
059: */
060: void install(ConfigurationData configurationData)
061: throws IOException, InvalidConfigException;
062:
063: /**
064: * Removes a configuration from the store
065: *
066: * @param configId the id of the configuration to remove, which must be
067: * fully resolved (isResolved() == true)
068: *
069: * @throws NoSuchConfigException if the configuration is not contained in the store
070: * @throws IOException if a problem occurs during the removal
071: */
072: void uninstall(Artifact configId) throws NoSuchConfigException,
073: IOException;
074:
075: /**
076: * Loads the specified configuration into the kernel
077: *
078: * @param configId the id of the configuration to load, which must be fully
079: * resolved (isResolved() == true)
080: *
081: * @return the the configuration object
082: *
083: * @throws NoSuchConfigException if the configuration is not contained in the kernel
084: * @throws IOException if a problem occurs loading the configuration from the store
085: * @throws InvalidConfigException if the configuration is corrupt
086: */
087: ConfigurationData loadConfiguration(Artifact configId)
088: throws NoSuchConfigException, IOException,
089: InvalidConfigException;
090:
091: /**
092: * Determines if the store contains a configuration with the specified ID.
093: * The configuration need not be loaded or running, this just checks
094: * whether the configuration store has the data for it.
095: *
096: * @param configId the unique ID of the configuration, which must be fully
097: * resolved (isResolved() == true)
098: *
099: * @return true if the store contains the configuration
100: */
101: boolean containsConfiguration(Artifact configId);
102:
103: /**
104: * Return the object name for the store.
105: *
106: * @return the object name for the store
107: */
108: String getObjectName();
109:
110: /**
111: * Return the object name for the store.
112: *
113: * @return the object name for the store
114: */
115: AbstractName getAbstractName();
116:
117: /**
118: * Return the configurations in the store
119: *
120: * @return a List (with entries of type ConfigurationInfo) of all the
121: * configurations contained in this configuration store
122: */
123: List<ConfigurationInfo> listConfigurations();
124:
125: /**
126: * Creates an empty directory for a new configuration with the specified configId
127: *
128: * @param configId the unique ID of the configuration, which must be fully
129: * resolved (isResolved() == true)
130: *
131: * @return the location of the new directory
132: *
133: * @throws ConfigurationAlreadyExistsException if the configuration already exists in this store
134: */
135: File createNewConfigurationDir(Artifact configId)
136: throws ConfigurationAlreadyExistsException;
137:
138: /**
139: * Locate the physical locations which match the supplied path in the given
140: * artifact/module. The path may be an Ant-style pattern.
141: *
142: * @param configId the artifact to search, which must be fully resolved
143: * (isResolved() == true)
144: * @param moduleName the module name or null to search in the top-level
145: * artifact location
146: * @param path the pattern to search for within the artifact/module,
147: * which may also be null to identify the artifact or
148: * module base path
149: *
150: * @return a Set (with entries of type URL) of the matching locations
151: */
152: Set<URL> resolve(Artifact configId, String moduleName, String path)
153: throws NoSuchConfigException, MalformedURLException;
154:
155: /**
156: * Exports a configuration as a ZIP file.
157: *
158: * @param configId The unique ID of the configuration to export, which
159: * must be fully resolved (isResolved() == true)
160: * @param output The stream to write the ZIP content to
161: */
162: void exportConfiguration(Artifact configId, OutputStream output)
163: throws IOException, NoSuchConfigException;
164: }
|