geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r706145 - in /geronimo/gshell/trunk: gshell-assembly/src/main/assembly/ gshell-bootstrap/ gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/ gshell-bootstrap/src/main/resources/org/apache/geronimo/gshell/bootstrap/
Date Mon, 20 Oct 2008 08:19:03 GMT
Author: jdillon
Date: Mon Oct 20 01:19:02 2008
New Revision: 706145

URL: http://svn.apache.org/viewvc?rev=706145&view=rev
Log:
Completely ripped out ClassWorlds, using a smaller/faster custom Launcher

Added:
    geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
  (contents, props changed)
      - copied, changed from r706134, geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
    geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java
  (contents, props changed)
      - copied, changed from r706134, geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
    geronimo/gshell/trunk/gshell-bootstrap/src/main/resources/org/apache/geronimo/gshell/bootstrap/default-log4j.xml
  (props changed)
      - copied unchanged from r706134, geronimo/gshell/trunk/gshell-bootstrap/src/main/resources/org/apache/geronimo/gshell/bootstrap/log4j.xml
Removed:
    geronimo/gshell/trunk/gshell-bootstrap/src/main/resources/org/apache/geronimo/gshell/bootstrap/classworlds.conf
    geronimo/gshell/trunk/gshell-bootstrap/src/main/resources/org/apache/geronimo/gshell/bootstrap/log4j.xml
Modified:
    geronimo/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml
    geronimo/gshell/trunk/gshell-bootstrap/pom.xml
    geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java

Modified: geronimo/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml?rev=706145&r1=706144&r2=706145&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml (original)
+++ geronimo/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml Mon Oct 20 01:19:02 2008
@@ -67,18 +67,9 @@
             <outputDirectory>lib</outputDirectory>
             <useStrictFiltering>true</useStrictFiltering>
             <excludes>
-                <exclude>org.codehaus.plexus:plexus-classworlds</exclude>
                 <exclude>org.apache.geronimo.gshell:gshell-bootstrap</exclude>
             </excludes>
         </dependencySet>
-
-        <dependencySet>
-            <outputDirectory>lib/boot</outputDirectory>
-            <useStrictFiltering>true</useStrictFiltering>
-            <includes>
-                <include>org.codehaus.plexus:plexus-classworlds</include>
-            </includes>
-        </dependencySet>
         
         <dependencySet>
             <outputDirectory>lib/boot</outputDirectory>

Modified: geronimo/gshell/trunk/gshell-bootstrap/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-bootstrap/pom.xml?rev=706145&r1=706144&r2=706145&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-bootstrap/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-bootstrap/pom.xml Mon Oct 20 01:19:02 2008
@@ -37,20 +37,6 @@
         Provides the tiny GShell bootstrap jar to keep platform scripts as simple as possible.
     </description>
     
-    <dependencies>
-        <dependency>
-            <groupId>org.codehaus.plexus</groupId>
-            <artifactId>plexus-classworlds</artifactId>
-            <version>1.2-alpha-13</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>junit</groupId>
-                    <artifactId>junit</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-    </dependencies>
-    
     <build>
         <plugins>
             <plugin>

Copied: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
(from r706134, geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java?p2=geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java&p1=geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java&r1=706134&r2=706145&rev=706145&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
(original)
+++ geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
Mon Oct 20 01:19:02 2008
@@ -20,91 +20,78 @@
 package org.apache.geronimo.gshell.bootstrap;
 
 import java.io.File;
-import java.lang.reflect.InvocationTargetException;
+import java.io.IOException;
+import java.io.FileFilter;
 import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
- * Platform independent launcher to setup common configuration and launch the application.
+ * Bootstrap configuration.
  *
  * @version $Rev$ $Date$
  */
-public class Launcher
-    extends org.codehaus.plexus.classworlds.launcher.Launcher
+public class Configuration
 {
+    private static final String GSHELL_HOME = "gshell.home";
+
     private static final String PROGRAM_NAME = "program.name";
 
-    private static final String GSHELL_HOME = "gshell.home";
+    private static final String DEFAULT_PROGRAM_NAME = "gsh";
 
     private static final String LOG4J_CONF = "log4j.configuration";
 
-    private static final String DEFAULT_LOG4J_CONF = "org/apache/geronimo/gshell/bootstrap/log4j.xml";
+    private static final String DEFAULT_LOG4J_CONF = "org/apache/geronimo/gshell/bootstrap/default-log4j.xml";
 
-    private static final String DEFAULT_CLASSWORLDS_CONF = "org/apache/geronimo/gshell/bootstrap/classworlds.conf";
+    private File homeDir;
 
-    private static boolean debug = Boolean.getBoolean(Launcher.class.getName() + ".debug");
+    private String programName;
 
-    private static String programName;
-    
-    private static File homeDir;
+    private String log4jConfig;
 
-    private static void debug(final String message) {
-        if (debug) {
-            System.err.println("[DEBUG] " + message);
-        }
-    }
+    private ClassLoader classLoader;
 
-    private static void warn(final String message) {
-        System.err.println("[WARN] " + message);
-    }
+    public File getHomeDir() throws IOException {
+        if (homeDir == null) {
+            String path = System.getProperty(GSHELL_HOME);
+            File dir;
 
-    private static void error(final String message) {
-        System.err.println("[ERROR] " + message);
-        throw new Error(message);
-    }
+            if (path == null) {
+                String jarPath = Launcher.class.getProtectionDomain().getCodeSource().getLocation().getFile();
+                jarPath = java.net.URLDecoder.decode(jarPath, "UTF-8");
 
-    private static void setProperty(final String name, final String value) {
-        System.setProperty(name, value);
-        debug("Setting property: " + name + "=" + value);
-    }
+                // The jar containing this class is expected to be in <gshell.home>/lib/boot
+                File bootJar = new File(jarPath);
+                dir = bootJar.getParentFile().getParentFile().getParentFile().getCanonicalFile();
+            }
+            else {
+                dir = new File(path).getCanonicalFile();
+            }
 
-    private static String getProgramName() {
-        String name = System.getProperty(PROGRAM_NAME);
-        if (name == null) {
-            name = "gsh";
+            homeDir = dir;
         }
 
-        return name;
+        return homeDir;
     }
 
-    private static File getHomeDir() throws Exception {
-        String path = System.getProperty(GSHELL_HOME);
-        File dir;
-
-        if (path == null) {
-            String jarPath = Launcher.class.getProtectionDomain().getCodeSource().getLocation().getFile();
-            jarPath = java.net.URLDecoder.decode(jarPath, "UTF-8");
-
-            // The jar containing this class is expected to be in <gshell.home>/lib/boot
-            File bootJar = new File(jarPath);
-            dir = bootJar.getParentFile().getParentFile().getParentFile().getCanonicalFile();
-        }
-        else {
-            dir = new File(path).getCanonicalFile();
+    public String getProgramName() {
+        if (programName == null) {
+            programName = System.getProperty(PROGRAM_NAME, DEFAULT_PROGRAM_NAME);
         }
 
-        return dir;
+        return programName;
     }
 
-    private static File getProgramConfigurationFile(final String filename) {
+    public File getProgramConfigurationFile(final String filename) throws IOException {
         assert filename != null;
 
-        File etcDir = new File(homeDir, "etc");
-
-        File file = new File(etcDir, programName + "-" + filename);
+        File etcDir = new File(getHomeDir(), "etc");
+        File file = new File(etcDir, getProgramName() + "-" + filename);
 
         if (!file.exists()) {
             File unprefixedFile = new File(etcDir, filename);
-            
+
             if (unprefixedFile.exists()) {
                 file = unprefixedFile;
             }
@@ -113,138 +100,69 @@
         return file;
     }
 
-    private static String getClassworldsConf() throws Exception {
-        String path = System.getProperty(CLASSWORLDS_CONF);
-        File file;
-
-        if (path == null) {
-            file = getProgramConfigurationFile("classworlds.conf");
-        }
-        else {
-            file = new File(path).getCanonicalFile();
-        }
-
-        if (file.exists()) {
-            return file.getCanonicalPath();
-        }
-
-        return DEFAULT_CLASSWORLDS_CONF;
-    }
-
-    private static String getLog4jConf() throws Exception {
-        String path = System.getProperty(LOG4J_CONF);
-        File file;
-
-        if (path == null) {
-            file = getProgramConfigurationFile("log4j.xml");
-        }
-        else {
-            file = new File(path).getCanonicalFile();
-        }
-
-        if (file.exists()) {
-            return file.toURI().toURL().toExternalForm();
-        }
-
-        return DEFAULT_LOG4J_CONF;
-    }
-
-    private static void configure() throws Exception {
-        // Branding information is not available here, so we must use the basic GShell properties
to configure the bootstrap loader.
-
-        programName = getProgramName();
-        setProperty(PROGRAM_NAME, programName);
-
-        homeDir = getHomeDir();
-        setProperty(GSHELL_HOME, homeDir.getCanonicalPath());
-
-        String classworldsConf = getClassworldsConf();
-        if (classworldsConf != null) {
-            setProperty(CLASSWORLDS_CONF, classworldsConf);
-        }
-
-        String log4jConf = getLog4jConf();
-        if (log4jConf != null) {
-            setProperty(LOG4J_CONF, log4jConf);
-        }
-        else {
-            warn("Missing Log4j configuration! Logging may not properly initialize;  Please
set the '" +
-                    LOG4J_CONF + "' property to a valid configuration file or resource name.");
-        }
-    }
-
-    public static int mainWithExitCode(final String[] args) throws Exception {
-        assert args != null;
-
-        Launcher launcher = new Launcher();
+    public String getLog4jConfig() throws IOException {
+        if (log4jConfig == null) {
+            String path = System.getProperty(LOG4J_CONF);
+            File file;
 
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        launcher.setSystemClassLoader(cl);
-
-        String classworldsConf = System.getProperty(CLASSWORLDS_CONF);
-        URL configUrl = null;
+            if (path == null) {
+                file = getProgramConfigurationFile("log4j.xml");
+            }
+            else {
+                file = new File(path).getCanonicalFile();
+            }
 
-        if (classworldsConf != null) {
-            File file = new File(classworldsConf);
             if (file.exists()) {
-                configUrl = file.toURI().toURL();
+                log4jConfig = file.toURI().toURL().toExternalForm();
             }
             else {
-                configUrl = cl.getResource(classworldsConf);
+                log4jConfig = DEFAULT_LOG4J_CONF;
             }
         }
 
-        if (configUrl == null) {
-            error("Failed to locate ClassWorlds configuration!  Please set the '" +
-                    CLASSWORLDS_CONF + "' property to a valid configuration file or resource
name.");
-            // Unreachable statement, ^^^ throws Error w/message
-            throw new Error();
-        }
-
-        debug("Resolved " + CLASSWORLDS_CONF + ": " + configUrl);
-
-        launcher.configure(configUrl.openStream());
+        return log4jConfig;
+    }
 
-        try {
-            launcher.launch(args);
-        }
-        catch (InvocationTargetException e) {
-            throw new LaunchFailedError(e.getTargetException());
-        }
+    private void setProperty(final String name, final String value) {
+        System.setProperty(name, value);
+        Log.debug("Property: " + name + "=" + value);
+    }
 
-        return launcher.getExitCode();
+    public void configure() throws Exception {
+        setProperty(PROGRAM_NAME, getProgramName());
+        setProperty(GSHELL_HOME, getHomeDir().getAbsolutePath());
+        setProperty(LOG4J_CONF, getLog4jConfig());
     }
 
-    public static void main(final String[] args) {
-        assert args != null;
+    public ClassLoader getClassLoader() throws Exception {
+        if (classLoader == null) {
+            List<URL> classPath = new ArrayList<URL>();
 
-        try {
-            configure();
+            // Add ${gshell.home}/etc
+            classPath.add(new File(getHomeDir(), "etc").toURI().toURL());
 
-            int exitCode = mainWithExitCode(args);
+            // Add ${gshell.home}/lib/*.jar
+            File libDir = new File(getHomeDir(), "lib");
+            File[] files = libDir.listFiles(new FileFilter() {
+                public boolean accept(final File file) {
+                    return file.isFile();
+                }
+            });
 
-            System.exit(exitCode);
-        }
-        catch (Throwable t) {
-            t.printStackTrace(System.err);
-            System.err.flush();
-            System.exit(100);
-        }
-    }
+            for (File file : files) {
+                classPath.add(file.toURI().toURL());
+            }
 
-    //
-    // LaunchFailedError
-    //
-    
-    private static class LaunchFailedError
-        extends Error
-    {
-        public LaunchFailedError(final Throwable cause) {
-            super(cause);
-        }
+            if (Log.DEBUG) {
+                Log.debug("Classpath:");
+                for (URL url : classPath) {
+                    Log.debug("    " + url);
+                }
+            }
 
-        public LaunchFailedError(final String msg) {
-            super(msg);
+            classLoader = new URLClassLoader(classPath.toArray(new URL[classPath.size()]),
getClass().getClassLoader());
         }
+
+        return classLoader;
     }
-}
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Configuration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java?rev=706145&r1=706144&r2=706145&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
(original)
+++ geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
Mon Oct 20 01:19:02 2008
@@ -19,232 +19,66 @@
 
 package org.apache.geronimo.gshell.bootstrap;
 
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 /**
- * Platform independent launcher to setup common configuration and launch the application.
+ * Bootstrap launcher.
  *
  * @version $Rev$ $Date$
  */
 public class Launcher
-    extends org.codehaus.plexus.classworlds.launcher.Launcher
 {
-    private static final String PROGRAM_NAME = "program.name";
+    private static final int SUCCESS_EXIT_CODE = 0;
 
-    private static final String GSHELL_HOME = "gshell.home";
+    private static final int FAILURE_EXIT_CODE = 100;
 
-    private static final String LOG4J_CONF = "log4j.configuration";
+    private static final String MAIN_CLASS = "org.apache.geronimo.gshell.cli.Main";
 
-    private static final String DEFAULT_LOG4J_CONF = "org/apache/geronimo/gshell/bootstrap/log4j.xml";
-
-    private static final String DEFAULT_CLASSWORLDS_CONF = "org/apache/geronimo/gshell/bootstrap/classworlds.conf";
-
-    private static boolean debug = Boolean.getBoolean(Launcher.class.getName() + ".debug");
-
-    private static String programName;
-    
-    private static File homeDir;
-
-    private static void debug(final String message) {
-        if (debug) {
-            System.err.println("[DEBUG] " + message);
-        }
-    }
-
-    private static void warn(final String message) {
-        System.err.println("[WARN] " + message);
-    }
-
-    private static void error(final String message) {
-        System.err.println("[ERROR] " + message);
-        throw new Error(message);
-    }
-
-    private static void setProperty(final String name, final String value) {
-        System.setProperty(name, value);
-        debug("Setting property: " + name + "=" + value);
-    }
-
-    private static String getProgramName() {
-        String name = System.getProperty(PROGRAM_NAME);
-        if (name == null) {
-            name = "gsh";
-        }
-
-        return name;
-    }
-
-    private static File getHomeDir() throws Exception {
-        String path = System.getProperty(GSHELL_HOME);
-        File dir;
-
-        if (path == null) {
-            String jarPath = Launcher.class.getProtectionDomain().getCodeSource().getLocation().getFile();
-            jarPath = java.net.URLDecoder.decode(jarPath, "UTF-8");
-
-            // The jar containing this class is expected to be in <gshell.home>/lib/boot
-            File bootJar = new File(jarPath);
-            dir = bootJar.getParentFile().getParentFile().getParentFile().getCanonicalFile();
-        }
-        else {
-            dir = new File(path).getCanonicalFile();
-        }
-
-        return dir;
-    }
-
-    private static File getProgramConfigurationFile(final String filename) {
-        assert filename != null;
-
-        File etcDir = new File(homeDir, "etc");
+    public static void main(final String[] args) {
+        assert args != null;
 
-        File file = new File(etcDir, programName + "-" + filename);
+        Configuration config = new Configuration();
 
-        if (!file.exists()) {
-            File unprefixedFile = new File(etcDir, filename);
+        try {
+            Log.debug("Configuring");
             
-            if (unprefixedFile.exists()) {
-                file = unprefixedFile;
-            }
-        }
-
-        return file;
-    }
-
-    private static String getClassworldsConf() throws Exception {
-        String path = System.getProperty(CLASSWORLDS_CONF);
-        File file;
-
-        if (path == null) {
-            file = getProgramConfigurationFile("classworlds.conf");
-        }
-        else {
-            file = new File(path).getCanonicalFile();
-        }
-
-        if (file.exists()) {
-            return file.getCanonicalPath();
-        }
-
-        return DEFAULT_CLASSWORLDS_CONF;
-    }
-
-    private static String getLog4jConf() throws Exception {
-        String path = System.getProperty(LOG4J_CONF);
-        File file;
+            config.configure();
 
-        if (path == null) {
-            file = getProgramConfigurationFile("log4j.xml");
-        }
-        else {
-            file = new File(path).getCanonicalFile();
-        }
-
-        if (file.exists()) {
-            return file.toURI().toURL().toExternalForm();
-        }
-
-        return DEFAULT_LOG4J_CONF;
-    }
+            ClassLoader cl = config.getClassLoader();
+            Class type = cl.loadClass(MAIN_CLASS);
+            Method method = getMainMethod(type);
 
-    private static void configure() throws Exception {
-        // Branding information is not available here, so we must use the basic GShell properties
to configure the bootstrap loader.
+            Thread.currentThread().setContextClassLoader(cl);
 
-        programName = getProgramName();
-        setProperty(PROGRAM_NAME, programName);
+            Log.debug("Launching: " + method);
 
-        homeDir = getHomeDir();
-        setProperty(GSHELL_HOME, homeDir.getCanonicalPath());
+            method.invoke(null, new Object[] { args });
 
-        String classworldsConf = getClassworldsConf();
-        if (classworldsConf != null) {
-            setProperty(CLASSWORLDS_CONF, classworldsConf);
-        }
+            Log.debug("Exiting");
 
-        String log4jConf = getLog4jConf();
-        if (log4jConf != null) {
-            setProperty(LOG4J_CONF, log4jConf);
+            System.exit(SUCCESS_EXIT_CODE);
         }
-        else {
-            warn("Missing Log4j configuration! Logging may not properly initialize;  Please
set the '" +
-                    LOG4J_CONF + "' property to a valid configuration file or resource name.");
+        catch (Throwable t) {
+            t.printStackTrace(System.err);
+            System.err.flush();
+            System.exit(FAILURE_EXIT_CODE);
         }
     }
 
-    public static int mainWithExitCode(final String[] args) throws Exception {
-        assert args != null;
-
-        Launcher launcher = new Launcher();
+    private static Method getMainMethod(final Class type) throws Exception {
+        assert type != null;
 
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        launcher.setSystemClassLoader(cl);
+        Method m = type.getMethod("main", String[].class);
 
-        String classworldsConf = System.getProperty(CLASSWORLDS_CONF);
-        URL configUrl = null;
+        int modifiers = m.getModifiers();
 
-        if (classworldsConf != null) {
-            File file = new File(classworldsConf);
-            if (file.exists()) {
-                configUrl = file.toURI().toURL();
-            }
-            else {
-                configUrl = cl.getResource(classworldsConf);
+        if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
+            if (m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE) {
+                return m;
             }
         }
 
-        if (configUrl == null) {
-            error("Failed to locate ClassWorlds configuration!  Please set the '" +
-                    CLASSWORLDS_CONF + "' property to a valid configuration file or resource
name.");
-            // Unreachable statement, ^^^ throws Error w/message
-            throw new Error();
-        }
-
-        debug("Resolved " + CLASSWORLDS_CONF + ": " + configUrl);
-
-        launcher.configure(configUrl.openStream());
-
-        try {
-            launcher.launch(args);
-        }
-        catch (InvocationTargetException e) {
-            throw new LaunchFailedError(e.getTargetException());
-        }
-
-        return launcher.getExitCode();
-    }
-
-    public static void main(final String[] args) {
-        assert args != null;
-
-        try {
-            configure();
-
-            int exitCode = mainWithExitCode(args);
-
-            System.exit(exitCode);
-        }
-        catch (Throwable t) {
-            t.printStackTrace(System.err);
-            System.err.flush();
-            System.exit(100);
-        }
-    }
-
-    //
-    // LaunchFailedError
-    //
-    
-    private static class LaunchFailedError
-        extends Error
-    {
-        public LaunchFailedError(final Throwable cause) {
-            super(cause);
-        }
-
-        public LaunchFailedError(final String msg) {
-            super(msg);
-        }
+        throw new NoSuchMethodException("public static void main(String[] args) in " + type);
     }
 }

Copied: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java
(from r706134, geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java?p2=geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java&p1=geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java&r1=706134&r2=706145&rev=706145&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
(original)
+++ geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java
Mon Oct 20 01:19:02 2008
@@ -19,232 +19,18 @@
 
 package org.apache.geronimo.gshell.bootstrap;
 
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-
 /**
- * Platform independent launcher to setup common configuration and launch the application.
+ * Bootstrap logger.
  *
  * @version $Rev$ $Date$
  */
-public class Launcher
-    extends org.codehaus.plexus.classworlds.launcher.Launcher
+public class Log
 {
-    private static final String PROGRAM_NAME = "program.name";
-
-    private static final String GSHELL_HOME = "gshell.home";
-
-    private static final String LOG4J_CONF = "log4j.configuration";
-
-    private static final String DEFAULT_LOG4J_CONF = "org/apache/geronimo/gshell/bootstrap/log4j.xml";
-
-    private static final String DEFAULT_CLASSWORLDS_CONF = "org/apache/geronimo/gshell/bootstrap/classworlds.conf";
-
-    private static boolean debug = Boolean.getBoolean(Launcher.class.getName() + ".debug");
+    public static final boolean DEBUG = Boolean.getBoolean(Log.class.getName() + ".debug");
 
-    private static String programName;
-    
-    private static File homeDir;
-
-    private static void debug(final String message) {
-        if (debug) {
+    public static void debug(final String message) {
+        if (DEBUG) {
             System.err.println("[DEBUG] " + message);
         }
     }
-
-    private static void warn(final String message) {
-        System.err.println("[WARN] " + message);
-    }
-
-    private static void error(final String message) {
-        System.err.println("[ERROR] " + message);
-        throw new Error(message);
-    }
-
-    private static void setProperty(final String name, final String value) {
-        System.setProperty(name, value);
-        debug("Setting property: " + name + "=" + value);
-    }
-
-    private static String getProgramName() {
-        String name = System.getProperty(PROGRAM_NAME);
-        if (name == null) {
-            name = "gsh";
-        }
-
-        return name;
-    }
-
-    private static File getHomeDir() throws Exception {
-        String path = System.getProperty(GSHELL_HOME);
-        File dir;
-
-        if (path == null) {
-            String jarPath = Launcher.class.getProtectionDomain().getCodeSource().getLocation().getFile();
-            jarPath = java.net.URLDecoder.decode(jarPath, "UTF-8");
-
-            // The jar containing this class is expected to be in <gshell.home>/lib/boot
-            File bootJar = new File(jarPath);
-            dir = bootJar.getParentFile().getParentFile().getParentFile().getCanonicalFile();
-        }
-        else {
-            dir = new File(path).getCanonicalFile();
-        }
-
-        return dir;
-    }
-
-    private static File getProgramConfigurationFile(final String filename) {
-        assert filename != null;
-
-        File etcDir = new File(homeDir, "etc");
-
-        File file = new File(etcDir, programName + "-" + filename);
-
-        if (!file.exists()) {
-            File unprefixedFile = new File(etcDir, filename);
-            
-            if (unprefixedFile.exists()) {
-                file = unprefixedFile;
-            }
-        }
-
-        return file;
-    }
-
-    private static String getClassworldsConf() throws Exception {
-        String path = System.getProperty(CLASSWORLDS_CONF);
-        File file;
-
-        if (path == null) {
-            file = getProgramConfigurationFile("classworlds.conf");
-        }
-        else {
-            file = new File(path).getCanonicalFile();
-        }
-
-        if (file.exists()) {
-            return file.getCanonicalPath();
-        }
-
-        return DEFAULT_CLASSWORLDS_CONF;
-    }
-
-    private static String getLog4jConf() throws Exception {
-        String path = System.getProperty(LOG4J_CONF);
-        File file;
-
-        if (path == null) {
-            file = getProgramConfigurationFile("log4j.xml");
-        }
-        else {
-            file = new File(path).getCanonicalFile();
-        }
-
-        if (file.exists()) {
-            return file.toURI().toURL().toExternalForm();
-        }
-
-        return DEFAULT_LOG4J_CONF;
-    }
-
-    private static void configure() throws Exception {
-        // Branding information is not available here, so we must use the basic GShell properties
to configure the bootstrap loader.
-
-        programName = getProgramName();
-        setProperty(PROGRAM_NAME, programName);
-
-        homeDir = getHomeDir();
-        setProperty(GSHELL_HOME, homeDir.getCanonicalPath());
-
-        String classworldsConf = getClassworldsConf();
-        if (classworldsConf != null) {
-            setProperty(CLASSWORLDS_CONF, classworldsConf);
-        }
-
-        String log4jConf = getLog4jConf();
-        if (log4jConf != null) {
-            setProperty(LOG4J_CONF, log4jConf);
-        }
-        else {
-            warn("Missing Log4j configuration! Logging may not properly initialize;  Please
set the '" +
-                    LOG4J_CONF + "' property to a valid configuration file or resource name.");
-        }
-    }
-
-    public static int mainWithExitCode(final String[] args) throws Exception {
-        assert args != null;
-
-        Launcher launcher = new Launcher();
-
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        launcher.setSystemClassLoader(cl);
-
-        String classworldsConf = System.getProperty(CLASSWORLDS_CONF);
-        URL configUrl = null;
-
-        if (classworldsConf != null) {
-            File file = new File(classworldsConf);
-            if (file.exists()) {
-                configUrl = file.toURI().toURL();
-            }
-            else {
-                configUrl = cl.getResource(classworldsConf);
-            }
-        }
-
-        if (configUrl == null) {
-            error("Failed to locate ClassWorlds configuration!  Please set the '" +
-                    CLASSWORLDS_CONF + "' property to a valid configuration file or resource
name.");
-            // Unreachable statement, ^^^ throws Error w/message
-            throw new Error();
-        }
-
-        debug("Resolved " + CLASSWORLDS_CONF + ": " + configUrl);
-
-        launcher.configure(configUrl.openStream());
-
-        try {
-            launcher.launch(args);
-        }
-        catch (InvocationTargetException e) {
-            throw new LaunchFailedError(e.getTargetException());
-        }
-
-        return launcher.getExitCode();
-    }
-
-    public static void main(final String[] args) {
-        assert args != null;
-
-        try {
-            configure();
-
-            int exitCode = mainWithExitCode(args);
-
-            System.exit(exitCode);
-        }
-        catch (Throwable t) {
-            t.printStackTrace(System.err);
-            System.err.flush();
-            System.exit(100);
-        }
-    }
-
-    //
-    // LaunchFailedError
-    //
-    
-    private static class LaunchFailedError
-        extends Error
-    {
-        public LaunchFailedError(final Throwable cause) {
-            super(cause);
-        }
-
-        public LaunchFailedError(final String msg) {
-            super(msg);
-        }
-    }
-}
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Log.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/resources/org/apache/geronimo/gshell/bootstrap/default-log4j.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/resources/org/apache/geronimo/gshell/bootstrap/default-log4j.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-bootstrap/src/main/resources/org/apache/geronimo/gshell/bootstrap/default-log4j.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message