KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > kernel > config > LifecycleResults


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.kernel.config;
18
19 import java.util.LinkedHashSet JavaDoc;
20 import java.util.LinkedHashMap JavaDoc;
21 import java.util.Set JavaDoc;
22 import java.util.Map JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.io.Serializable JavaDoc;
26
27 import org.apache.geronimo.kernel.repository.Artifact;
28
29 /**
30  * This class contains the results of a lifecycle operation on the configuation manager.
31  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
32  */

33 public class LifecycleResults implements Serializable JavaDoc {
34     private static final long serialVersionUID = 4660197333193740244L;
35     private final Set JavaDoc loaded = new LinkedHashSet JavaDoc();
36     private final Set JavaDoc unloaded = new LinkedHashSet JavaDoc();
37     private final Set JavaDoc started = new LinkedHashSet JavaDoc();
38     private final Set JavaDoc stopped = new LinkedHashSet JavaDoc();
39     private final Map JavaDoc failed = new LinkedHashMap JavaDoc();
40
41     /**
42      * Checks whether the specified configuration was loaded.
43      *
44      * @param configurationId the configuration identifier, which must be fully
45      * resolved (isResolved() == true)
46      *
47      * @return true if the specified configuration was loaded during the lifecycle operation
48      */

49     public boolean wasLoaded(Artifact configurationId) {
50         return loaded.contains(configurationId);
51     }
52
53     /**
54      * Gets the configuration identifiers (Artifact) of the configurations loaded.
55      * @return the configuration identifiers (Artifact)
56      */

57     public Set JavaDoc getLoaded() {
58         return Collections.unmodifiableSet(loaded);
59     }
60
61     /**
62      * Adds a configuration the set of loaded configurations.
63      * @param configurationId the configuration identifiers (Artifact)
64      */

65     public void addLoaded(Artifact configurationId) {
66         loaded.add(configurationId);
67     }
68
69     /**
70      * Clears the existing loaded set and add alls the specified configurations to the set
71      * @param loaded the configuration identifiers (Artifact)
72      */

73     public void setLoaded(Set JavaDoc loaded) {
74         this.loaded.clear();
75         this.loaded.addAll(loaded);
76     }
77
78     /**
79      * Checks whether the specified configuration was unloaded.
80      *
81      * @param configurationId the configuration identifier, which must be fully
82      * resolved (isResolved() == true)
83      *
84      * @return true if the specified configuration was unloaded during the lifecycle operation
85      */

86     public boolean wasUnloaded(Artifact configurationId) {
87         return unloaded.contains(configurationId);
88     }
89
90     /**
91      * Gets the configuration identifiers (Artifact) of the configurations unloaded.
92      * @return the configuration identifiers (Artifact)
93      */

94     public Set JavaDoc getUnloaded() {
95         return Collections.unmodifiableSet(unloaded);
96     }
97
98     /**
99      * Adds a configuration the set of unloaded configurations.
100      * @param configurationId the configuration identifiers (Artifact)
101      */

102     public void addUnloaded(Artifact configurationId) {
103         unloaded.add(configurationId);
104     }
105
106     /**
107      * Clears the existing unloaded set and add alls the specified configurations to the set
108      * @param unloaded the configuration identifiers (Artifact)
109      */

110     public void setUnloaded(Set JavaDoc unloaded) {
111         this.unloaded.clear();
112         this.unloaded.addAll(unloaded);
113     }
114
115     /**
116      * Checks whether the specified configuration was started.
117      *
118      * @param configurationId the configuration identifier, which must be fully
119      * resolved (isResolved() == true)
120      *
121      * @return true if the specified configuration was started during the lifecycle operation
122      */

123     public boolean wasStarted(Artifact configurationId) {
124         return started.contains(configurationId);
125     }
126
127     /**
128      * Gets the configuration identifiers (Artifact) of the configurations started.
129      * @return the configuration identifiers (Artifact)
130      */

131     public Set JavaDoc getStarted() {
132         return Collections.unmodifiableSet(started);
133     }
134
135     /**
136      * Adds a configuration the set of started configurations.
137      * @param configurationId the configuration identifiers (Artifact)
138      */

139     public void addStarted(Artifact configurationId) {
140         started.add(configurationId);
141     }
142
143     /**
144      * Clears the existing started set and add alls the specified configurations to the set
145      * @param started the configuration identifiers (Artifact)
146      */

147     public void setStarted(Set JavaDoc started) {
148         this.started.clear();
149         this.started.addAll(started);
150     }
151
152     /**
153      * Checks whether the specified configuration was stopped.
154      *
155      * @param configurationId the configuration identifier, which must be fully
156      * resolved (isResolved() == true)
157      *
158      * @return true if the specified configuration was stopped during the lifecycle operation
159      */

160     public boolean wasStopped(Artifact configurationId) {
161         return stopped.contains(configurationId);
162     }
163
164     /**
165      * Gets the configuration identifiers (Artifact) of the configurations stopped.
166      * @return the configuration identifiers (Artifact)
167      */

168     public Set JavaDoc getStopped() {
169         return Collections.unmodifiableSet(stopped);
170     }
171
172     /**
173      * Adds a configuration the set of stopped configurations.
174      * @param configurationId the configuration identifiers (Artifact)
175      */

176     public void addStopped(Artifact configurationId) {
177         stopped.add(configurationId);
178     }
179
180     /**
181      * Clears the existing stopped set and add alls the specified configurations to the set
182      * @param stopped the configuration identifiers (Artifact)
183      */

184     public void setStopped(Set JavaDoc stopped) {
185         this.stopped.clear();
186         this.stopped.addAll(stopped);
187     }
188
189     /**
190      * Was the specified configuration failed the operation and threw an
191      * exception.
192      *
193      * @param configurationId the configuration identifier. May be a partial
194      * ID, in which case will check whether any
195      * matching conifguration failed.
196      *
197      * @return true if the specified (or any matching) configuration failed
198      * the operation and threw an exception during the lifecycle
199      * operation
200      */

201     public boolean wasFailed(Artifact configurationId) {
202         for (Iterator JavaDoc it = failed.keySet().iterator(); it.hasNext();) {
203             Artifact failID = (Artifact) it.next();
204             if(configurationId.matches(failID)) {
205                 return true;
206             }
207         }
208         return false;
209     }
210
211     /**
212      * Gets the exception that caused the operation on the specified configuration to fail.
213      * @return the configuration identifiers (Artifact)
214      */

215     public Throwable JavaDoc getFailedCause(Artifact configurationId) {
216         return (Throwable JavaDoc) failed.get(configurationId);
217     }
218
219     /**
220      * Gets the configuration identifiers (Artifact) of the configurations that failed the operation and threw an exception.
221      * @return the configuration identifiers (Artifact)
222      */

223     public Map JavaDoc getFailed() {
224         return Collections.unmodifiableMap(failed);
225     }
226
227     /**
228      * Adds a configuration and associated causal exception to this result.
229      * @param configurationId the configuration identifiers (Artifact)
230      * @param cause the exception that caused the operation on the specified configuration to fail
231      */

232     public void addFailed(Artifact configurationId, Throwable JavaDoc cause) {
233         failed.put(configurationId, cause);
234     }
235
236     /**
237      * Clears the existing failed map and add alls the specified configurations to the map
238      * @param failed a map from configuration identifier (Artifact) to causal exception
239      */

240     public void setFailed(Map JavaDoc failed) {
241         this.failed.clear();
242         this.failed.putAll(failed);
243     }
244 }
245
Popular Tags