private boolean targetSet;
public void buildPackage() throws Exception {
log.info("Packaging module configuration: " + planFile);
Kernel kernel = createKernel();
if (!targetSet) {
kernel.stopGBean(targetRepositoryAName);
kernel.setAttribute(targetRepositoryAName, "root", targetRepository.toURI());
kernel.startGBean(targetRepositoryAName);
if (kernel.getGBeanState(targetConfigStoreAName) != State.RUNNING_INDEX) {
throw new IllegalStateException("After restarted repository then config store is not running");
}
targetSet = true;
}
log.debug("Starting configurations..." + Arrays.asList(deploymentConfigs));
// start the Configuration we're going to use for this deployment
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
try {
for (String artifactName : deploymentConfigs) {
org.apache.geronimo.kernel.repository.Artifact configName = org.apache.geronimo.kernel.repository.Artifact.create(artifactName);
if (!configurationManager.isLoaded(configName)) {
RecordingLifecycleMonitor monitor = new RecordingLifecycleMonitor();
try {
configurationManager.loadConfiguration(configName, monitor);
} catch (LifecycleException e) {
log.error("Could not load deployer configuration: " + configName + "\n" + monitor.toString(), e);
}
monitor = new RecordingLifecycleMonitor();
try {
configurationManager.startConfiguration(configName, monitor);
log.info("Started deployer: " + configName);
} catch (LifecycleException e) {
log.error("Could not start deployer configuration: " + configName + "\n" + monitor.toString(), e);
}
}
}
} finally {
ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
}
log.debug("Deploying...");
AbstractName deployer = locateDeployer(kernel);
invokeDeployer(kernel, deployer, targetConfigStoreAName.toString());
//use a fresh kernel for each module
kernel.shutdown();
kernel = null;
}