You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2004/04/05 07:54:11 UTC
cvs commit: incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment Bootstrap.java
dain 2004/04/04 22:54:11
Modified: modules/system/src/java/org/apache/geronimo/system/main
CommandLine.java
modules/deployment/src/java/org/apache/geronimo/deployment
Bootstrap.java
Added: modules/system/src/java/org/apache/geronimo/system/main
CommandLineManifest.java
Log:
Changed Bootstrap to not import CommandLine class so logging is not
intialized in the maven vm
Moved manifest handling code to CommandLineManifest
Build nows works with maven 1.0:rc2
Revision Changes Path
1.6 +5 -86 incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java
Index: CommandLine.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CommandLine.java 10 Mar 2004 09:59:31 -0000 1.5
+++ CommandLine.java 5 Apr 2004 05:54:11 -0000 1.6
@@ -17,19 +17,9 @@
package org.apache.geronimo.system.main;
-import java.io.IOException;
import java.io.ObjectInputStream;
-import java.net.JarURLConnection;
import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
@@ -55,10 +45,6 @@
private CommandLine() {
}
- public static final Attributes.Name MAIN_GBEAN = new Attributes.Name("Main-GBean");
- public static final Attributes.Name MAIN_METHOD = new Attributes.Name("Main-Method");
- public static final Attributes.Name CONFIGURATIONS = new Attributes.Name("Configurations");
-
/**
* Command line entry point called by executable jar
* @param args command line args
@@ -66,7 +52,7 @@
public static void main(String[] args) {
try {
// the interesting entries from the manifest
- ManifestEntries manifestEntries = getManifestEntries();
+ CommandLineManifest manifest = CommandLineManifest.getManifestEntries();
// boot the kernel
Kernel kernel = new Kernel("geronimo.kernel", "geronimo");
@@ -86,7 +72,7 @@
kernel.startRecursiveGBean(configName);
// load and start the configurations listested in the manifest
- for (Iterator iterator = manifestEntries.configurations.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = manifest.getConfigurations().iterator(); iterator.hasNext();) {
URI configurationID = (URI) iterator.next();
ObjectName configurationName = configurationManager.load(configurationID);
kernel.startRecursiveGBean(configurationName);
@@ -94,8 +80,8 @@
// invoke the main method
kernel.invoke(
- manifestEntries.mainGBean,
- manifestEntries.mainMethod,
+ manifest.getMainGBean(),
+ manifest.getMainMethod(),
new Object[]{args},
new String[]{String[].class.getName()});
@@ -111,71 +97,4 @@
}
}
- private static ManifestEntries getManifestEntries() {
- ManifestEntries manifestEntries = new ManifestEntries();
-
- // find the startup jar
- ClassLoader classLoader = CommandLine.class.getClassLoader();
- URL url = classLoader.getResource("META-INF/startup-jar");
- if (url == null) {
- throw new IllegalArgumentException("Unable to determine location of startup jar");
- }
-
- // extract the manifest
- Manifest manifest;
- try {
- JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
- manifest = jarConnection.getManifest();
- } catch (IOException e) {
- System.err.println("Startup jar does not contain a manifest: " + url);
- System.exit(1);
- throw new AssertionError();
- }
- Attributes mainAttributes = manifest.getMainAttributes();
-
- // get the main gbean class
- String mainGBeanString = mainAttributes.getValue(MAIN_GBEAN);
- if (mainGBeanString == null) {
- System.err.println("Manifest does not conatin a Main-GBean entry");
- System.exit(1);
- throw new AssertionError();
- }
- try {
- manifestEntries.mainGBean = new ObjectName(mainGBeanString);
- } catch (MalformedObjectNameException e) {
- System.err.println("Invalid Main-GBean name: " + mainGBeanString);
- System.exit(1);
- throw new AssertionError();
- }
-
- // get the main method
- manifestEntries.mainMethod = mainAttributes.getValue(MAIN_METHOD);
- if (mainGBeanString == null) {
- System.err.println("Manifest does not conatin a Main-Method entry");
- System.exit(1);
- throw new AssertionError();
- }
-
- // get the list of extra configurations to load
- String configurationsString = mainAttributes.getValue(CONFIGURATIONS);
- if (configurationsString != null) {
- for (StringTokenizer tokenizer = new StringTokenizer(configurationsString, " "); tokenizer.hasMoreTokens();) {
- String configuration = tokenizer.nextToken();
- try {
- manifestEntries.configurations.add(new URI(configuration));
- } catch (URISyntaxException e) {
- System.err.println("Invalid URI in Manifest Configurations entry: " + configuration);
- System.exit(1);
- throw new AssertionError();
- }
- }
- }
- return manifestEntries;
- }
-
- private static class ManifestEntries {
- private ObjectName mainGBean;
- private String mainMethod;
- private final List configurations = new ArrayList();
- }
}
1.1 incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/main/CommandLineManifest.java
Index: CommandLineManifest.java
===================================================================
/**
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.geronimo.system.main;
import java.util.List;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Collections;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.net.URL;
import java.net.JarURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.io.IOException;
import javax.management.ObjectName;
import javax.management.MalformedObjectNameException;
/**
*
*
* @version $Revision: 1.1 $ $Date: 2004/04/05 05:54:11 $
*/
public class CommandLineManifest {
public static final Attributes.Name MAIN_GBEAN = new Attributes.Name("Main-GBean");
public static final Attributes.Name MAIN_METHOD = new Attributes.Name("Main-Method");
public static final Attributes.Name CONFIGURATIONS = new Attributes.Name("Configurations");
public static CommandLineManifest getManifestEntries() {
// find the startup jar
ClassLoader classLoader = CommandLine.class.getClassLoader();
URL url = classLoader.getResource("META-INF/startup-jar");
if (url == null) {
throw new IllegalArgumentException("Unable to determine location of startup jar");
}
// extract the manifest
Manifest manifest;
try {
JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
manifest = jarConnection.getManifest();
} catch (IOException e) {
System.err.println("Startup jar does not contain a manifest: " + url);
System.exit(1);
throw new AssertionError();
}
Attributes mainAttributes = manifest.getMainAttributes();
// get the main gbean class
String mainGBeanString = mainAttributes.getValue(MAIN_GBEAN);
if (mainGBeanString == null) {
System.err.println("Manifest does not conatin a Main-GBean entry");
System.exit(1);
throw new AssertionError();
}
ObjectName mainGBean;
try {
mainGBean = new ObjectName(mainGBeanString);
} catch (MalformedObjectNameException e) {
System.err.println("Invalid Main-GBean name: " + mainGBeanString);
System.exit(1);
throw new AssertionError();
}
// get the main method
String mainMethod = mainAttributes.getValue(MAIN_METHOD);
if (mainGBeanString == null) {
System.err.println("Manifest does not conatin a Main-Method entry");
System.exit(1);
throw new AssertionError();
}
// get the list of extra configurations to load
List configurations = new ArrayList();
String configurationsString = mainAttributes.getValue(CONFIGURATIONS);
if (configurationsString != null) {
for (StringTokenizer tokenizer = new StringTokenizer(configurationsString, " "); tokenizer.hasMoreTokens();) {
String configuration = tokenizer.nextToken();
try {
configurations.add(new URI(configuration));
} catch (URISyntaxException e) {
System.err.println("Invalid URI in Manifest Configurations entry: " + configuration);
System.exit(1);
throw new AssertionError();
}
}
}
CommandLineManifest commandLineManifest = new CommandLineManifest(mainGBean, mainMethod, configurations);
return commandLineManifest;
}
private final ObjectName mainGBean;
private final String mainMethod;
private final List configurations;
public CommandLineManifest(ObjectName mainGBean, String mainMethod, List configurations) {
this.mainGBean = mainGBean;
this.mainMethod = mainMethod;
this.configurations = Collections.unmodifiableList(configurations);
}
public ObjectName getMainGBean() {
return mainGBean;
}
public String getMainMethod() {
return mainMethod;
}
public List getConfigurations() {
return configurations;
}
}
1.14 +6 -6 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java
Index: Bootstrap.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Bootstrap.java 3 Apr 2004 22:37:57 -0000 1.13
+++ Bootstrap.java 5 Apr 2004 05:54:11 -0000 1.14
@@ -30,7 +30,7 @@
import org.apache.geronimo.deployment.xbeans.ConfigurationDocument;
import org.apache.geronimo.deployment.xbeans.ConfigurationType;
import org.apache.geronimo.system.configuration.LocalConfigStore;
-import org.apache.geronimo.system.main.CommandLine;
+import org.apache.geronimo.system.main.CommandLineManifest;
import org.apache.geronimo.system.repository.ReadOnlyRepository;
import org.apache.xmlbeans.XmlBeans;
import org.apache.xmlbeans.XmlObject;
@@ -123,11 +123,11 @@
Manifest manifest = new Manifest();
Attributes mainAttributes = manifest.getMainAttributes();
mainAttributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
- mainAttributes.putValue(Attributes.Name.MAIN_CLASS.toString(), CommandLine.class.getName());
+ mainAttributes.putValue(Attributes.Name.MAIN_CLASS.toString(), "org.apache.geronimo.system.main.CommandLine");
mainAttributes.putValue(Attributes.Name.CLASS_PATH.toString(), deployerClassPath);
- mainAttributes.putValue(CommandLine.MAIN_GBEAN.toString(), deployerGBean);
- mainAttributes.putValue(CommandLine.MAIN_METHOD.toString(), "deploy");
- mainAttributes.putValue(CommandLine.CONFIGURATIONS.toString(), j2eeDeployerConfig.getConfigId());
+ mainAttributes.putValue(CommandLineManifest.MAIN_GBEAN.toString(), deployerGBean);
+ mainAttributes.putValue(CommandLineManifest.MAIN_METHOD.toString(), "deploy");
+ mainAttributes.putValue(CommandLineManifest.CONFIGURATIONS.toString(), j2eeDeployerConfig.getConfigId());
// build and install the deployer-system configuration
// write the deployer system out to a jar