addConfigurationsToMonitor(monitor, restartList);
// stop the configuations
LifecycleResults results = new LifecycleResults();
for (Iterator iterator = restartList.iterator(); iterator.hasNext();) {
Artifact configurationId = (Artifact) iterator.next();
Configuration configuration = getConfiguration(configurationId);
monitor.stopping(configurationId);
stop(configuration);
monitor.succeeded(configurationId);
results.addStopped(configurationId);
}
// reverse the list
restartList = reverse(restartList);
// restart the configurations
Set skip = new HashSet();
for (Iterator iterator = restartList.iterator(); iterator.hasNext();) {
Artifact configurationId = (Artifact) iterator.next();
// skip the configurations that have alredy failed or are children of failed configurations
if (skip.contains(configurationId)) {
continue;
}
// try to start the configuation
try {
Configuration configuration = getConfiguration(configurationId);
monitor.starting(configurationId);
start(configuration);
monitor.succeeded(configurationId);
results.addStarted(configurationId);
} catch (Exception e) {
// the configuraiton failed to restart
results.addFailed(configurationId, e);
monitor.failed(configurationId, e);
skip.add(configurationId);
// officially stop the configuration in the model (without gc)
LinkedHashSet stopList = configurationModel.stop(configurationId, false);
// all of the configurations to be stopped must be in our restart list, or the model is corrupt
if (!restartList.containsAll(stopList)) {
throw new AssertionError("Configuration data model is corrupt. You must restart your server.");
}
// add the children of the failed configuration to the results as stopped
for (Iterator iterator1 = stopList.iterator(); iterator1.hasNext();) {
Artifact failedId = (Artifact) iterator1.next();
// if any of the failed configuration is in the restarted set, the model is
// corrupt because we started a child before a parent
if (results.wasStarted(failedId)) {
throw new AssertionError("Configuration data model is corrupt. You must restart your server.");