jcscoobyrs 2005/10/11 13:18:58
Modified: modules/core/src/java/org/openejb/cli Main.java
CommandFinder.java
Log:
Updated for new launching concept. Removed all unused scripts, all
unecessary text files and all references to unused code, like Corba. All
scripts have been updated to use the new launch concept. Scripts could be
refactored a bit to utilize the new launcher a bit better but for flow control,
the scripts have been kept as-is in this respect.
Revision Changes Path
1.3 +45 -2 openejb1/modules/core/src/java/org/openejb/cli/Main.java
Index: Main.java
===================================================================
RCS file:
/scm/openejb/openejb1/modules/core/src/java/org/openejb/cli/Main.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Main.java 11 Oct 2005 03:14:03 -0000 1.2
+++ Main.java 11 Oct 2005 17:18:58 -0000 1.3
@@ -1,9 +1,11 @@
package org.openejb.cli;
+import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.JarURLConnection;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Locale;
@@ -11,6 +13,8 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
+import org.openejb.loader.SystemClassPath;
+
/**
* Entry point for ALL things OpenEJB. This will use the new service
* architecture explained here:
@@ -23,10 +27,49 @@
private static String basePath = "META-INF/org.openejb.cli/";
private static String locale = "";
private static String descriptionBase = "description";
-
- public static void main(String[] args) {
+
+ public static void init() {
finder = new CommandFinder(basePath);
locale = Locale.getDefault().getLanguage();
+
+ setupClasspath();
+ }
+
+ public static void setupClasspath() {
+ ClassLoader current =
Thread.currentThread().getContextClassLoader();
+ URL classURL =
Thread.currentThread().getContextClassLoader().getResource(basePath + "start");
+ String propsString = classURL.getFile();
+ URL jarURL = null;
+ File jarFile = null;
+
+ propsString = propsString.substring(0, propsString.indexOf("!"));
+
+ try {
+ jarURL = new URL(propsString);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ jarFile = new File(jarURL.getFile());
+
+ if (jarFile.getName().indexOf("openejb-core") > -1) {
+ File lib = jarFile.getParentFile();
+ File home = lib.getParentFile();
+
+ System.setProperty("openejb.home", home.getAbsolutePath());
+ }
+
+ File lib = new File(System.getProperty("openejb.home") +
File.separator + "lib");
+ SystemClassPath systemCP = new SystemClassPath();
+
+ try {
+ systemCP.addJarsToPath(lib);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ init();
if (args.length > 0) {
Properties props = null;
1.3 +0 -20
openejb1/modules/core/src/java/org/openejb/cli/CommandFinder.java
Index: CommandFinder.java
===================================================================
RCS file:
/scm/openejb/openejb1/modules/core/src/java/org/openejb/cli/CommandFinder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CommandFinder.java 7 Oct 2005 21:16:59 -0000 1.2
+++ CommandFinder.java 11 Oct 2005 17:18:58 -0000 1.3
@@ -1,10 +1,8 @@
package org.openejb.cli;
import java.io.BufferedInputStream;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -37,24 +35,6 @@
reader = new BufferedInputStream(in);
Properties properties = new Properties();
properties.load(reader);
-
- //All is well, set openejb.home
- URL propsURL =
Thread.currentThread().getContextClassLoader().getResource(uri);
- String propsString = propsURL.getFile();
- URL jarURL;
- File jarFile;
-
- propsString = propsString.substring(0, propsString.indexOf("!"));
-
- jarURL = new URL(propsString);
- jarFile = new File(jarURL.getFile());
-
- if (jarFile.getName().indexOf("openejb-core") > -1) {
- File lib = jarFile.getParentFile();
- File home = lib.getParentFile();
-
- System.setProperty("openejb.home", home.getAbsolutePath());
- }
return properties;
} finally {