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 package org.apache.geronimo.deployment;
018
019 import java.util.Collection;
020 import java.util.List;
021 import java.util.LinkedHashSet;
022 import java.util.Map;
023 import java.util.Iterator;
024 import java.util.Collections;
025 import java.util.Arrays;
026 import java.io.IOException;
027
028 import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
029 import org.apache.geronimo.kernel.config.ConfigurationManager;
030 import org.apache.geronimo.kernel.config.ConfigurationStore;
031 import org.apache.geronimo.kernel.config.NoSuchStoreException;
032 import org.apache.geronimo.kernel.config.Configuration;
033 import org.apache.geronimo.kernel.config.LifecycleResults;
034 import org.apache.geronimo.kernel.config.NoSuchConfigException;
035 import org.apache.geronimo.kernel.config.LifecycleException;
036 import org.apache.geronimo.kernel.config.LifecycleMonitor;
037 import org.apache.geronimo.kernel.config.ConfigurationData;
038 import org.apache.geronimo.kernel.config.InvalidConfigException;
039 import org.apache.geronimo.kernel.repository.ArtifactResolver;
040 import org.apache.geronimo.kernel.repository.Artifact;
041 import org.apache.geronimo.kernel.repository.Version;
042 import org.apache.geronimo.gbean.AbstractName;
043
044 /**
045 * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
046 */
047 public class DeploymentConfigurationManager extends SimpleConfigurationManager {
048 private final ConfigurationManager configurationManager;
049
050 public DeploymentConfigurationManager(ConfigurationManager configurationManager, Collection repositories) {
051 super(Arrays.asList(configurationManager.getStores()), configurationManager.getArtifactResolver(), repositories);
052 this.configurationManager = configurationManager;
053 }
054
055 //
056 // GENERAL DATA
057 //
058
059 public synchronized boolean isInstalled(Artifact configId) {
060 return super.isInstalled(configId);
061 }
062
063 public synchronized boolean isLoaded(Artifact configId) {
064 return configurationManager.isLoaded(configId) || super.isLoaded(configId);
065 }
066
067 public synchronized boolean isRunning(Artifact configId) {
068 return configurationManager.isRunning(configId) || super.isRunning(configId);
069 }
070
071 public boolean isConfiguration(Artifact artifact) {
072 return configurationManager.isConfiguration(artifact) || super.isConfiguration(artifact);
073 }
074
075 public synchronized Configuration getConfiguration(Artifact configurationId) {
076 Configuration configuration = configurationManager.getConfiguration(configurationId);
077 if (configuration == null) {
078 configuration = super.getConfiguration(configurationId);
079 }
080 return configuration;
081 }
082
083 public ArtifactResolver getArtifactResolver() {
084 return super.getArtifactResolver();
085 }
086
087 /**
088 * This configuration manager never starts any configurations
089 * @return false
090 */
091 public boolean isOnline() {
092 return false;
093 }
094
095 public void setOnline(boolean online) {
096 }
097
098 //
099 // LOAD
100 //
101
102 public synchronized LifecycleResults loadConfiguration(Artifact configurationId) throws NoSuchConfigException, LifecycleException {
103 return super.loadConfiguration(configurationId);
104 }
105
106 public synchronized LifecycleResults loadConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
107 return super.loadConfiguration(configurationId, monitor);
108 }
109
110 public synchronized LifecycleResults loadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, LifecycleException {
111 return super.loadConfiguration(configurationData);
112 }
113
114 public synchronized LifecycleResults loadConfiguration(ConfigurationData configurationData, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
115 return super.loadConfiguration(configurationData, monitor);
116 }
117
118 protected Configuration load(ConfigurationData configurationData, LinkedHashSet resolvedParentIds, Map loadedConfigurations) throws InvalidConfigException {
119 return super.load(configurationData, resolvedParentIds, loadedConfigurations);
120 }
121
122 protected void load(Artifact configurationId) throws NoSuchConfigException {
123 if (configurationModel.containsConfiguration(configurationId)) {
124 super.load(configurationId);
125 }
126 }
127
128 protected void addNewConfigurationToModel(Configuration configuration) throws NoSuchConfigException {
129 LinkedHashSet loadParents = getLoadParents(configuration);
130 for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
131 Configuration loadParent= (Configuration) iterator.next();
132 if (!configurationModel.containsConfiguration(loadParent.getId())) {
133 configurationModel.addConfiguation(loadParent.getId(), Collections.EMPTY_SET, Collections.EMPTY_SET);
134 configurationModel.load(loadParent.getId());
135 }
136 }
137 LinkedHashSet startParents = getStartParents(configuration);
138 for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
139 Configuration startParent = (Configuration) iterator.next();
140 if (!configurationModel.containsConfiguration(startParent.getId())) {
141 configurationModel.addConfiguation(startParent.getId(), Collections.EMPTY_SET, Collections.EMPTY_SET);
142 configurationModel.load(startParent.getId());
143 }
144 }
145 super.addNewConfigurationToModel(configuration);
146 }
147
148 //
149 // UNLOAD
150 //
151
152 public synchronized LifecycleResults unloadConfiguration(Artifact id) throws NoSuchConfigException {
153 return super.unloadConfiguration(id);
154 }
155
156 public synchronized LifecycleResults unloadConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException {
157 return super.unloadConfiguration(id, monitor);
158 }
159
160 protected void unload(Configuration configuration) {
161 super.unload(configuration);
162 }
163
164 //
165 // STOP.. used by unload
166 //
167 protected void stop(Configuration configuration) {
168 super.stop(configuration);
169 }
170
171
172 //
173 // UNSUPPORTED
174 //
175
176 public Artifact[] getInstalled(Artifact query) {
177 throw new UnsupportedOperationException();
178 }
179
180 public Artifact[] getLoaded(Artifact query) {
181 throw new UnsupportedOperationException();
182 }
183
184 public Artifact[] getRunning(Artifact query) {
185 throw new UnsupportedOperationException();
186 }
187
188 public List listStores() {
189 throw new UnsupportedOperationException();
190 }
191
192 public ConfigurationStore[] getStores() {
193 throw new UnsupportedOperationException();
194 }
195
196 public List listConfigurations() {
197 throw new UnsupportedOperationException();
198 }
199
200 public ConfigurationStore getStoreForConfiguration(Artifact configId) {
201 throw new UnsupportedOperationException();
202 }
203
204 public List listConfigurations(AbstractName storeName) throws NoSuchStoreException {
205 throw new UnsupportedOperationException();
206 }
207
208 public synchronized LifecycleResults startConfiguration(Artifact id) throws NoSuchConfigException, LifecycleException {
209 throw new UnsupportedOperationException();
210 }
211
212 public synchronized LifecycleResults startConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
213 throw new UnsupportedOperationException();
214 }
215
216 protected void start(Configuration configuration) throws Exception {
217 throw new UnsupportedOperationException();
218 }
219
220 public synchronized LifecycleResults stopConfiguration(Artifact id) throws NoSuchConfigException {
221 throw new UnsupportedOperationException();
222 }
223
224 public synchronized LifecycleResults stopConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException {
225 throw new UnsupportedOperationException();
226 }
227
228 public synchronized LifecycleResults restartConfiguration(Artifact id) throws NoSuchConfigException, LifecycleException {
229 throw new UnsupportedOperationException();
230 }
231
232 public synchronized LifecycleResults restartConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
233 throw new UnsupportedOperationException();
234 }
235
236 public synchronized LifecycleResults reloadConfiguration(Artifact id) throws NoSuchConfigException, LifecycleException {
237 throw new UnsupportedOperationException();
238 }
239
240 public synchronized LifecycleResults reloadConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
241 throw new UnsupportedOperationException();
242 }
243
244 public synchronized LifecycleResults reloadConfiguration(Artifact id, Version version) throws NoSuchConfigException, LifecycleException {
245 throw new UnsupportedOperationException();
246 }
247
248 public synchronized LifecycleResults reloadConfiguration(Artifact id, Version version, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
249 throw new UnsupportedOperationException();
250 }
251
252 public LifecycleResults reloadConfiguration(ConfigurationData configurationData) throws LifecycleException, NoSuchConfigException {
253 throw new UnsupportedOperationException();
254 }
255
256 public LifecycleResults reloadConfiguration(ConfigurationData configurationData, LifecycleMonitor monitor) throws LifecycleException, NoSuchConfigException {
257 throw new UnsupportedOperationException();
258 }
259
260 public synchronized void uninstallConfiguration(Artifact configurationId) throws IOException, NoSuchConfigException {
261 throw new UnsupportedOperationException();
262 }
263 }