// parse the deployment-system and j2ee-deployer plans
ConfigurationType deployerSystemConfig = ConfigurationDocument.Factory.parse(new File(deployerSystemPlan)).getConfiguration();
ConfigurationType j2eeDeployerConfig = ConfigurationDocument.Factory.parse(new File(j2eeDeployerPlan)).getConfiguration();
// create the service builder, repository and config store objects
LocalConfigStore configStore = new LocalConfigStore(new File(storeDir));
ReadOnlyRepository repository = new ReadOnlyRepository(new File(repositoryDir));
//TODO should the defaultParentId be null??
ServiceConfigBuilder builder = new ServiceConfigBuilder(null, repository);
// create the manifext
Manifest manifest = new Manifest();
Attributes mainAttributes = manifest.getMainAttributes();
mainAttributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
mainAttributes.putValue(Attributes.Name.MAIN_CLASS.toString(), "org.apache.geronimo.deployment.cli.DeployTool");
mainAttributes.putValue(Attributes.Name.CLASS_PATH.toString(), deployerClassPath);
mainAttributes.putValue(CommandLineManifest.MAIN_GBEAN.toString(), deployerGBean);
mainAttributes.putValue(CommandLineManifest.MAIN_METHOD.toString(), "deploy");
mainAttributes.putValue(CommandLineManifest.CONFIGURATIONS.toString(), j2eeDeployerConfig.getConfigId());
// attribute that indicates to a JSR-88 tool that we have a Deployment factory
mainAttributes.putValue("J2EE-DeploymentFactory-Implementation-Class", deploymentFactory);
// write the deployer system out to a jar
// create a temp directory to build into
File configurationDir = null;
try {
configurationDir = configStore.createNewConfigurationDir();
// build the deployer-system configuration into the configurationDir
builder.buildConfiguration(deployerSystemConfig, null, configurationDir);
// Write the manifest
File metaInf = new File(configurationDir, "META-INF");
metaInf.mkdirs();
FileOutputStream out = null;
try {
out = new FileOutputStream(new File(metaInf, "MANIFEST.MF"));
manifest.write(out);
} finally {
DeploymentUtil.close(out);
}
// add the startup file which allows us to locate the startup directory
File startupJarTag = new File(metaInf, "startup-jar");
startupJarTag.createNewFile();
// jar up the directory
DeploymentUtil.jarDirectory(configurationDir, new File(deployerJar));
// delete the startup file before moving this to the config store
startupJarTag.delete();
// install the configuration
configStore.install(configurationDir);
} catch(Throwable e) {
DeploymentUtil.recursiveDelete(configurationDir);
if (e instanceof Error) {
throw (Error)e;
} else if (e instanceof Exception) {
throw (Exception)e;
}
throw new Error(e);
}
// build and install the j2ee-deployer configuration
try {
configurationDir = configStore.createNewConfigurationDir();
// build the j2ee-deployer configuration into the configurationDir
builder.buildConfiguration(j2eeDeployerConfig, null, configurationDir);
// install the configuration
configStore.install(configurationDir);
} catch(Throwable e) {
DeploymentUtil.recursiveDelete(configurationDir);
if (e instanceof Error) {
throw (Error)e;
} else if (e instanceof Exception) {