1 /**
2 *
3 * Copyright 2005 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 package org.apache.geronimo.deployment;
18
19 import java.util.Collection;
20 import java.util.List;
21 import java.util.LinkedHashSet;
22 import java.util.Map;
23 import java.util.Iterator;
24 import java.util.Collections;
25 import java.util.Arrays;
26 import java.io.IOException;
27
28 import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
29 import org.apache.geronimo.kernel.config.ConfigurationManager;
30 import org.apache.geronimo.kernel.config.ConfigurationStore;
31 import org.apache.geronimo.kernel.config.NoSuchStoreException;
32 import org.apache.geronimo.kernel.config.Configuration;
33 import org.apache.geronimo.kernel.config.LifecycleResults;
34 import org.apache.geronimo.kernel.config.NoSuchConfigException;
35 import org.apache.geronimo.kernel.config.LifecycleException;
36 import org.apache.geronimo.kernel.config.LifecycleMonitor;
37 import org.apache.geronimo.kernel.config.ConfigurationData;
38 import org.apache.geronimo.kernel.config.InvalidConfigException;
39 import org.apache.geronimo.kernel.repository.ArtifactResolver;
40 import org.apache.geronimo.kernel.repository.Artifact;
41 import org.apache.geronimo.kernel.repository.Version;
42 import org.apache.geronimo.gbean.AbstractName;
43
44 /**
45 * @version $Rev: 410741 $ $Date: 2006-05-31 21:35:48 -0700 (Wed, 31 May 2006) $
46 */
47 public class DeploymentConfigurationManager extends SimpleConfigurationManager {
48 private final ConfigurationManager configurationManager;
49
50 public DeploymentConfigurationManager(ConfigurationManager configurationManager, Collection repositories) {
51 super(Arrays.asList(configurationManager.getStores()), configurationManager.getArtifactResolver(), repositories);
52 this.configurationManager = configurationManager;
53 }
54
55
56
57
58
59 public synchronized boolean isInstalled(Artifact configId) {
60 return super.isInstalled(configId);
61 }
62
63 public synchronized boolean isLoaded(Artifact configId) {
64 return configurationManager.isLoaded(configId) || super.isLoaded(configId);
65 }
66
67 public synchronized boolean isRunning(Artifact configId) {
68 return configurationManager.isRunning(configId) || super.isRunning(configId);
69 }
70
71 public boolean isConfiguration(Artifact artifact) {
72 return configurationManager.isConfiguration(artifact) || super.isConfiguration(artifact);
73 }
74
75 public synchronized Configuration getConfiguration(Artifact configurationId) {
76 Configuration configuration = configurationManager.getConfiguration(configurationId);
77 if (configuration == null) {
78 configuration = super.getConfiguration(configurationId);
79 }
80 return configuration;
81 }
82
83 public ArtifactResolver getArtifactResolver() {
84 return super.getArtifactResolver();
85 }
86
87 /**
88 * This configuration manager never starts any configurations
89 * @return false
90 */
91 public boolean isOnline() {
92 return false;
93 }
94
95 public void setOnline(boolean online) {
96 }
97
98
99
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
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
166
167 protected void stop(Configuration configuration) {
168 super.stop(configuration);
169 }
170
171
172
173
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 }