// 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());
mainAttributes.putValue(CommandLineManifest.ENDORSED_DIRS.toString(), deployerEndorsedDirs);
mainAttributes.putValue(CommandLineManifest.EXTENSION_DIRS.toString(), deployerExtensionDirs);
// 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
ConfigurationData configurationData = builder.buildConfiguration(deployerSystemConfig, null, configurationDir);
ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, manifest, configurationDir, new File(deployerJar));
// install the configuration
configStore.install(configurationData, 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);
}
//get the domain and server from the parent xml config
String domain = deployerSystemConfig.getDomain();
String server = deployerSystemConfig.getServer();
// build and install the j2ee-deployer configuration
try {
configurationDir = configStore.createNewConfigurationDir();
// build the j2ee-deployer configuration into the configurationDir
ConfigurationData configurationData = builder.buildConfiguration(j2eeDeployerConfig, domain, server, configurationDir);
// install the configuration
configStore.install(configurationData, configurationDir);
} catch (Throwable e) {
DeploymentUtil.recursiveDelete(configurationDir);