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 */
017
018 package org.apache.geronimo.kernel.config;
019
020 import java.io.File;
021 import java.io.IOException;
022 import java.io.OutputStream;
023 import java.net.MalformedURLException;
024 import java.util.List;
025 import java.util.Set;
026
027 import org.apache.geronimo.kernel.repository.Artifact;
028 import org.apache.geronimo.gbean.AbstractName;
029
030 /**
031 * Interface to a store for Configurations.
032 *
033 * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
034 */
035 public interface ConfigurationStore {
036
037 /**
038 * Determines if the identified configuration is an in-place one. This
039 * means that the configuration store only stores some meta-data and the
040 * actual content of the configuration is rooted somewhere else.
041 *
042 * @param configId the unique ID of the configuration, which must be fully
043 * resolved (isResolved() == true)
044 *
045 * @return true if the identified configuration is an in-place one.
046 *
047 * @throws NoSuchConfigException if the configuration is not contained in
048 * the store
049 * @throws IOException If the store cannot be read.
050 */
051 boolean isInPlaceConfiguration(Artifact configId) 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) throws IOException, InvalidConfigException;
061
062 /**
063 * Removes a configuration from the store
064 *
065 * @param configId the id of the configuration to remove, which must be
066 * fully resolved (isResolved() == true)
067 *
068 * @throws NoSuchConfigException if the configuration is not contained in the store
069 * @throws IOException if a problem occurs during the removal
070 */
071 void uninstall(Artifact configId) throws NoSuchConfigException, IOException;
072
073 /**
074 * Loads the specified configuration into the kernel
075 *
076 * @param configId the id of the configuration to load, which must be fully
077 * resolved (isResolved() == true)
078 *
079 * @return the the configuration object
080 *
081 * @throws NoSuchConfigException if the configuration is not contained in the kernel
082 * @throws IOException if a problem occurs loading the configuration from the store
083 * @throws InvalidConfigException if the configuration is corrupt
084 */
085 ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException;
086
087 /**
088 * Determines if the store contains a configuration with the specified ID.
089 * The configuration need not be loaded or running, this just checks
090 * whether the configuration store has the data for it.
091 *
092 * @param configId the unique ID of the configuration, which must be fully
093 * resolved (isResolved() == true)
094 *
095 * @return true if the store contains the configuration
096 */
097 boolean containsConfiguration(Artifact configId);
098
099 /**
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 }