}
if (stores.isEmpty()) {
throw new DeploymentException("No ConfigurationStores!");
}
ConfigurationStore store;
if (targetConfigurationStore != null) {
AbstractName targetStoreName = new AbstractName(new URI(targetConfigurationStore));
store = (ConfigurationStore) kernel.getGBean(targetStoreName);
} else {
store = (ConfigurationStore) stores.iterator().next();
}
// It's our responsibility to close this context, once we're done with it...
DeploymentContext context = builder.buildConfiguration(inPlace, configID, plan, module, stores, artifactResolver, store);
List configurations = new ArrayList();
boolean configsCleanupRequired = false;
configurations.add(context.getConfigurationData());
configurations.addAll(context.getAdditionalDeployment());
if (configurations.isEmpty()) {
throw new DeploymentException("Deployer did not create any configurations");
}
// Set TCCL to the classloader for the configuration being deployed
// so that any static blocks invoked during the loading of classes
// during serialization of the configuration have the correct TCCL
// ( a TCCL that is consistent with what is set when the same
// classes are loaded when the configuration is started.
Thread thread = Thread.currentThread();
ClassLoader oldCl = thread.getContextClassLoader();
thread.setContextClassLoader( context.getConfiguration().getConfigurationClassLoader());
try {
if (targetFile != null) {
if (configurations.size() > 1) {
throw new DeploymentException("Deployer created more than one configuration");
}
ConfigurationData configurationData = (ConfigurationData) configurations.get(0);
ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, manifest, targetFile);
}
if (install) {
List deployedURIs = new ArrayList();
for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
ConfigurationData configurationData = (ConfigurationData) iterator.next();
store.install(configurationData);
deployedURIs.add(configurationData.getId().toString());
}
notifyWatchers(deployedURIs);
return deployedURIs;
} else {