KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > deployment > DeploymentConfigurationManager


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.LinkedHashSet JavaDoc;
22 import java.util.Map JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.Collections JavaDoc;
25 import java.util.Arrays JavaDoc;
26 import java.io.IOException JavaDoc;
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: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
46  */

47 public class DeploymentConfigurationManager extends SimpleConfigurationManager {
48     private final ConfigurationManager configurationManager;
49
50     public DeploymentConfigurationManager(ConfigurationManager configurationManager, Collection JavaDoc repositories) {
51         super(Arrays.asList(configurationManager.getStores()), configurationManager.getArtifactResolver(), repositories);
52         this.configurationManager = configurationManager;
53     }
54
55     //
56
// GENERAL DATA
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
// 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 JavaDoc resolvedParentIds, Map JavaDoc 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 JavaDoc loadParents = getLoadParents(configuration);
130         for (Iterator JavaDoc 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 JavaDoc startParents = getStartParents(configuration);
138         for (Iterator JavaDoc 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 JavaDoc();
178     }
179
180     public Artifact[] getLoaded(Artifact query) {
181         throw new UnsupportedOperationException JavaDoc();
182     }
183
184     public Artifact[] getRunning(Artifact query) {
185         throw new UnsupportedOperationException JavaDoc();
186     }
187
188     public List JavaDoc listStores() {
189         throw new UnsupportedOperationException JavaDoc();
190     }
191
192     public ConfigurationStore[] getStores() {
193         throw new UnsupportedOperationException JavaDoc();
194     }
195
196     public List JavaDoc listConfigurations() {
197         throw new UnsupportedOperationException JavaDoc();
198     }
199
200     public ConfigurationStore getStoreForConfiguration(Artifact configId) {
201         throw new UnsupportedOperationException JavaDoc();
202     }
203
204     public List JavaDoc listConfigurations(AbstractName storeName) throws NoSuchStoreException {
205         throw new UnsupportedOperationException JavaDoc();
206     }
207
208     public synchronized LifecycleResults startConfiguration(Artifact id) throws NoSuchConfigException, LifecycleException {
209         throw new UnsupportedOperationException JavaDoc();
210     }
211
212     public synchronized LifecycleResults startConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
213         throw new UnsupportedOperationException JavaDoc();
214     }
215
216     protected void start(Configuration configuration) throws Exception JavaDoc {
217         throw new UnsupportedOperationException JavaDoc();
218     }
219
220     public synchronized LifecycleResults stopConfiguration(Artifact id) throws NoSuchConfigException {
221         throw new UnsupportedOperationException JavaDoc();
222     }
223
224     public synchronized LifecycleResults stopConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException {
225         throw new UnsupportedOperationException JavaDoc();
226     }
227
228     public synchronized LifecycleResults restartConfiguration(Artifact id) throws NoSuchConfigException, LifecycleException {
229         throw new UnsupportedOperationException JavaDoc();
230     }
231
232     public synchronized LifecycleResults restartConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
233         throw new UnsupportedOperationException JavaDoc();
234     }
235
236     public synchronized LifecycleResults reloadConfiguration(Artifact id) throws NoSuchConfigException, LifecycleException {
237         throw new UnsupportedOperationException JavaDoc();
238     }
239
240     public synchronized LifecycleResults reloadConfiguration(Artifact id, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
241         throw new UnsupportedOperationException JavaDoc();
242     }
243
244     public synchronized LifecycleResults reloadConfiguration(Artifact id, Version version) throws NoSuchConfigException, LifecycleException {
245         throw new UnsupportedOperationException JavaDoc();
246     }
247
248     public synchronized LifecycleResults reloadConfiguration(Artifact id, Version version, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
249         throw new UnsupportedOperationException JavaDoc();
250     }
251
252     public LifecycleResults reloadConfiguration(ConfigurationData configurationData) throws LifecycleException, NoSuchConfigException {
253         throw new UnsupportedOperationException JavaDoc();
254     }
255
256     public LifecycleResults reloadConfiguration(ConfigurationData configurationData, LifecycleMonitor monitor) throws LifecycleException, NoSuchConfigException {
257         throw new UnsupportedOperationException JavaDoc();
258     }
259
260     public synchronized void uninstallConfiguration(Artifact configurationId) throws IOException JavaDoc, NoSuchConfigException {
261         throw new UnsupportedOperationException JavaDoc();
262     }
263 }
264
Popular Tags