ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(Bootstrap.class.getClassLoader());
// 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());
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);