svn commit: r1623352 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/container/ start/src/org/ofbiz/base/start/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1623352 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/container/ start/src/org/ofbiz/base/start/

jacopoc
Author: jacopoc
Date: Mon Sep  8 10:38:28 2014
New Revision: 1623352

URL: http://svn.apache.org/r1623352
Log:
A series of simplifications, cleanups of old code, and improvements to the code that setup the class paths for the OFBiz classloaders; the former code was setting the same jars (e.g. ofbiz.jar and all the base libs) in both the parent/child classloaders; it was unnecessarily setting the classpath system property when not required/useful.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Config.java
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/both.properties
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/install.properties
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/jetty.properties
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/pos.properties
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/rmi.properties
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/setup.properties
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/start.properties
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/test.properties
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ComponentContainer.java Mon Sep  8 10:38:28 2014
@@ -47,7 +47,7 @@ public class ComponentContainer implemen
     public static final String module = ComponentContainer.class.getName();
 
     //protected static List loadedComponents2 = null;
-    protected Classpath classPath = new Classpath(System.getProperty("java.class.path"));
+    protected Classpath classPath = new Classpath();
     protected Classpath libraryPath = new Classpath(System.getProperty("java.library.path"));
     protected String configFileLocation = null;
     private String name;
@@ -136,7 +136,6 @@ public class ComponentContainer implemen
                 classPath.instrument(instrumenterFile, instrumenterClassName);
             }
 
-            System.setProperty("java.class.path", classPath.toString());
             System.setProperty("java.library.path", libraryPath.toString());
             ClassLoader cl = classPath.getClassLoader();
             Thread.currentThread().setContextClassLoader(cl);
@@ -235,6 +234,7 @@ public class ComponentContainer implemen
         }
 
         Debug.logInfo("Loading component : [" + config.getComponentName() + "]", module);
+        boolean isBaseComponent = "base".equals(config.getComponentName());
         List<ComponentConfig.ClasspathInfo> classpathInfos = config.getClasspathInfos();
         String configRoot = config.getRootLocation();
         configRoot = configRoot.replace('\\', '/');
@@ -263,6 +263,7 @@ public class ComponentContainer implemen
                 if (path.exists()) {
                     if (path.isDirectory()) {
                         if ("dir".equals(cp.type)) {
+                            if (!isBaseComponent)
                             classPath.addComponent(configRoot + location);
                         }
                         // load all .jar, .zip files and native libs in this directory
@@ -270,6 +271,7 @@ public class ComponentContainer implemen
                         for (File file: path.listFiles()) {
                             String fileName = file.getName().toLowerCase();
                             if (fileName.endsWith(".jar") || fileName.endsWith(".zip")) {
+                                if (!isBaseComponent)
                                 classPath.addComponent(file);
                             } else if (fileName.endsWith(nativeLibExt)) {
                                 containsNativeLibs = true;
@@ -280,6 +282,7 @@ public class ComponentContainer implemen
                         }
                     } else {
                         // add a single file
+                        if (!isBaseComponent)
                         classPath.addComponent(configRoot + location);
                     }
                 } else {

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Config.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Config.java?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Config.java (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Config.java Mon Sep  8 10:38:28 2014
@@ -43,18 +43,14 @@ public class Config {
     public final String baseDtd;
     public final String baseJar;
     public final String baseLib;
-    public final String commJar;
     public final String containerConfig;
     public final String instrumenterClassName;
     public final String instrumenterFile;
     public final List<Map<String, String>> loaders;
     public final String logDir;
     public final String ofbizHome;
-    public final boolean requireCommJar;
-    public final boolean requireToolsJar;
     public final boolean shutdownAfterLoad;
     public final String splashLogo;
-    public final String toolsJar;
     public final boolean useShutdownHook;
 
     Config(String[] args) throws IOException {
@@ -73,10 +69,6 @@ public class Config {
         }
         String config =  "org/ofbiz/base/start/" + firstArg + ".properties";
 
-        // check the java_version
-        String javaVersion = System.getProperty("java.version");
-        String javaVendor = System.getProperty("java.vendor");
-
         Properties props = this.getPropertiesFile(config);
         System.out.println("Start.java using configuration file " + config);
 
@@ -103,16 +95,6 @@ public class Config {
         // base jar file
         baseJar = getOfbizHomeProp(props, "ofbiz.base.jar", "framework/base/build/lib/ofbiz-base.jar");
 
-        // tools jar
-        String reqTJ = getProp(props, "java.tools.jar.required", "false");
-        requireToolsJar = "true".equalsIgnoreCase(reqTJ);
-        toolsJar = this.findSystemJar(props, javaVendor, javaVersion, "tools.jar", requireToolsJar);
-
-        // comm jar
-        String reqCJ = getProp(props, "java.comm.jar.required", "false");
-        requireCommJar = "true".equalsIgnoreCase(reqCJ);
-        commJar = this.findSystemJar(props, javaVendor, javaVersion, "comm.jar", requireCommJar);
-
         // log directory
         logDir = getOfbizHomeProp(props, "ofbiz.log.dir", "runtime/logs");
 
@@ -223,97 +205,6 @@ public class Config {
         loaders = Collections.unmodifiableList(loadersTmp);
     }
 
-    private String findSystemJar(Properties props, String javaVendor, String javaVersion, String jarName, boolean required) {
-        String fileSep = System.getProperty("file.separator");
-        String javaHome = System.getProperty("java.home");
-        String errorMsg = "Unable to locate " + jarName + " - ";
-        String jarLoc = "lib" + fileSep + jarName;
-        File tj = null;
-
-        if ("tools.jar".equals(jarName) && javaVendor.startsWith("Apple")) {
-            // tools.jar is always available in Apple's JDK implementation
-            return null;
-        }
-
-        // check to see if it is in the OFBIZ_HOME directory
-        tj = new File(ofbizHome + fileSep + jarName);
-        if (tj.exists()) {
-            return null;
-        }
-
-        // check to see if it is in the base/lib directory
-        tj = new File(baseLib + fileSep + jarName);
-        if (tj.exists()) {
-            return null;
-        }
-
-        // try to locate tools.jar from the properties file
-        String jarProps = props.getProperty("java." + jarName, null);
-        if (jarProps != null) {
-            tj = new File(jarProps);
-            if (!tj.exists()) {
-                if (required) {
-                    System.err.println(errorMsg + tj.getAbsolutePath());
-                }
-            } else {
-                // System.out.println(foundMsg + tj.getAbsolutePath());
-                return jarProps;
-            }
-        }
-
-        // next check the JAVA_HOME lib dir
-        tj = new File(javaHome + fileSep + jarLoc);
-        if (!tj.exists()) {
-            if (required) {
-                System.err.println(errorMsg + tj.getAbsolutePath());
-            }
-        } else {
-            // System.out.println(foundMsg + tj.getAbsolutePath());
-            return tj.getAbsolutePath();
-        }
-
-        // next if we are a JRE dir check the parent dir
-        String jreExt = fileSep + "jre";
-        if (javaHome.toLowerCase().endsWith(jreExt)) {
-            javaHome = javaHome.substring(0, javaHome.lastIndexOf(fileSep));
-            tj = new File(javaHome + fileSep + jarLoc);
-            if (!tj.exists()) {
-                if (required) {
-                    System.err.println(errorMsg + tj.getAbsolutePath());
-                }
-            } else {
-                // System.out.println(foundMsg + tj.getAbsolutePath());
-                return tj.getAbsolutePath();
-            }
-        }
-
-        // special windows checking
-        if (javaHome.toLowerCase().charAt(1) == ':') {
-            String driveLetter = javaHome.substring(0, 2);
-            String windowsPath = driveLetter + fileSep + "j2sdk" + javaVersion;
-            tj = new File(windowsPath + fileSep + jarLoc);
-            if (!tj.exists()) {
-                if (required) {
-                    System.err.println(errorMsg + tj.getAbsolutePath());
-                }
-            } else {
-                // System.out.println(foundMsg + tj.getAbsolutePath());
-                return tj.getAbsolutePath();
-            }
-        }
-
-        if (required) {
-            System.err.println("");
-            System.err.println("Required library " + jarName + " could not be located.");
-            System.err.println("You may need to copy " + jarName + " into a loadable lib directory");
-            System.err.println("(i.e. OFBIZ_HOME or OFBIZ_HOME/base/lib)");
-            System.err.println("");
-            System.exit(-1);
-        }
-
-        return null;
-    }
-
     private String getOfbizHomeProp(Properties props, String key, String def) {
         String value = System.getProperty(key);
         if (value != null)
@@ -371,18 +262,11 @@ public class Config {
     }
 
     public void initClasspath(Classpath classPath) throws IOException {
-        // load tools.jar
-        if (this.toolsJar != null) {
-            classPath.addComponent(this.toolsJar);
-        }
-        // load comm.jar
-        if (this.commJar != null) {
-            classPath.addComponent(this.commJar);
-        }
-        // add OFBIZ_HOME to class path & load libs
+        // add OFBIZ_HOME to class path
         classPath.addClasspath(this.ofbizHome);
-        loadLibs(classPath, this.ofbizHome, false);
-        // load the lib directory
+
+        // load all the resources from the framework base component
+        // load all the jars from the base lib directory
         if (this.baseLib != null) {
             loadLibs(classPath, this.baseLib, true);
         }

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java Mon Sep  8 10:38:28 2014
@@ -219,8 +219,6 @@ public final class Start {
         if (!fullInit) {
             return;
         }
-        // initialize the classpath
-        initClasspath();
         // create the log directory
         createLogDirectory();
         // create the listener thread
@@ -241,25 +239,15 @@ public final class Start {
         initStartLoaders();
     }
 
-    private void initClasspath() throws StartupException {
-        Classpath classPath = new Classpath(System.getProperty("java.class.path"));
+    private void initStartLoaders() throws StartupException {
+        Classpath classPath = new Classpath();
         try {
             this.config.initClasspath(classPath);
         } catch (IOException e) {
             throw (StartupException) new StartupException("Couldn't initialized classpath").initCause(e);
         }
-        // Set the classpath/classloader
-        System.setProperty("java.class.path", classPath.toString());
         ClassLoader classloader = classPath.getClassLoader();
         Thread.currentThread().setContextClassLoader(classloader);
-        if (System.getProperty("DEBUG") != null) {
-            System.out.println("Startup Classloader: " + classloader.toString());
-            System.out.println("Startup Classpath: " + classPath.toString());
-        }
-    }
-
-    private void initStartLoaders() throws StartupException {
-        ClassLoader classloader = Thread.currentThread().getContextClassLoader();
         synchronized (this.loaders) {
             // initialize the loaders
             for (Map<String, String> loaderMap : config.loaders) {

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/both.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/both.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/both.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/both.properties Mon Sep  8 10:38:28 2014
@@ -17,15 +17,12 @@
 # under the License.
 ###############################################################################
 ####
-# OFBiz Startup Application Settings
-####
-
-# --- Java LIB tools.jar is not required
-#java.tools.jar.required=false
-
-# --- External Base configuration files (relative to ofbiz.home)
-#ofbiz.base.config=framework/base/config
-
+# OFBiz Startup Application Settings
+####
+
+# --- External Base configuration files (relative to ofbiz.home)
+#ofbiz.base.config=framework/base/config
+
 # --- External Base schema files (relative to ofbiz.home)
 #ofbiz.base.schema=framework/base/dtd
 

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/install.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/install.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/install.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/install.properties Mon Sep  8 10:38:28 2014
@@ -20,9 +20,6 @@
 # OFBiz Startup Application Settings
 ####
 
-# --- Java LIB tools.jar is not required
-#java.tools.jar.required=false
-
 # --- External Base configuration files (relative to ofbiz.home)
 #ofbiz.base.config=framework/base/config
 

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/jetty.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/jetty.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/jetty.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/jetty.properties Mon Sep  8 10:38:28 2014
@@ -20,10 +20,6 @@
 # OFBiz Startup Application Settings
 ####
 
-# --- By default we will locate the file using the java.home set by java (executable)
-#java.tools.jar=
-java.tools.jar.required=true
-
 # --- By default we will use the current directory
 #ofbiz.home=
 

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/pos.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/pos.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/pos.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/pos.properties Mon Sep  8 10:38:28 2014
@@ -20,9 +20,6 @@
 # OFBiz Startup Application Settings
 ####
 
-# --- Java LIB tools.jar is not required
-#java.tools.jar.required=false
-
 # --- External Base configuration files (relative to ofbiz.home)
 #ofbiz.base.config=framework/base/config
 

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/rmi.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/rmi.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/rmi.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/rmi.properties Mon Sep  8 10:38:28 2014
@@ -20,9 +20,6 @@
 # OFBiz Startup Application Settings
 ####
 
-# --- By default we will locate the file using the java.home set by java (executable)
-#java.tools.jar.required=false
-
 # --- External Base configuration files (relative to ofbiz.home)
 #ofbiz.base.config=framework/base/config
 

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/setup.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/setup.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/setup.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/setup.properties Mon Sep  8 10:38:28 2014
@@ -20,9 +20,6 @@
 # OFBiz Startup Application Settings
 ####
 
-# --- Java LIB tools.jar is not required
-#java.tools.jar.required=false
-
 # --- External Base configuration files (relative to ofbiz.home)
 #ofbiz.base.config=framework/base/config
 

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/start.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/start.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/start.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/start.properties Mon Sep  8 10:38:28 2014
@@ -20,10 +20,6 @@
 # OFBiz Startup Application Settings
 ####
 
-# --- By default we will locate the file using the java.home set by java (executable)
-#java.tools.jar=
-#java.tools.jar.required=false
-
 # --- By default we will use the current directory
 #ofbiz.home=
 

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/test.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/test.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/test.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/test.properties Mon Sep  8 10:38:28 2014
@@ -20,9 +20,6 @@
 # OFBiz Startup Application Settings
 ####
 
-# --- Java LIB tools.jar is not required
-#java.tools.jar.required=false
-
 # --- External Base configuration files (relative to ofbiz.home)
 #ofbiz.base.config=framework/base/config
 

Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties?rev=1623352&r1=1623351&r2=1623352&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/testlist.properties Mon Sep  8 10:38:28 2014
@@ -20,12 +20,8 @@
 # OFBiz Startup Application Settings
 ####
 
-# --- Java LIB tools.jar is not required
-#java.tools.jar.required=false
-
 # --- External Base configuration files (relative to ofbiz.home)
 #ofbiz.base.config=framework/base/config
-
 # --- External Base schema files (relative to ofbiz.home)
 #ofbiz.base.schema=framework/base/dtd