You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2011/03/26 20:52:45 UTC

svn commit: r1085794 - in /ofbiz/trunk/framework/start/src/org/ofbiz/base/start: Config.java Start.java

Author: adrianc
Date: Sat Mar 26 19:52:44 2011
New Revision: 1085794

URL: http://svn.apache.org/viewvc?rev=1085794&view=rev
Log:
Moved Config-specific code from Start class to Config class.

Modified:
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Config.java
    ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java

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=1085794&r1=1085793&r2=1085794&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 Sat Mar 26 19:52:44 2011
@@ -220,6 +220,7 @@ public class Config {
         }
 
         Properties props = this.getPropertiesFile(config);
+        System.out.println("Start.java using configuration file " + config);
 
         // set the ofbiz.home
         if (ofbizHome == null) {
@@ -355,4 +356,52 @@ 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
+        classPath.addClasspath(this.ofbizHome);
+        loadLibs(classPath, this.ofbizHome, false);
+        // load the lib directory
+        if (this.baseLib != null) {
+            loadLibs(classPath, this.baseLib, true);
+        }
+        // load the ofbiz-base.jar
+        if (this.baseJar != null) {
+            classPath.addComponent(this.baseJar);
+        }
+        // load the base schema directory
+        if (this.baseDtd != null) {
+            classPath.addComponent(this.baseDtd);
+        }
+        // load the config directory
+        if (this.baseConfig != null) {
+            classPath.addComponent(this.baseConfig);
+        }
+        classPath.instrument(this.instrumenterFile, this.instrumenterClassName);
+    }
+
+    private void loadLibs(Classpath classPath, String path, boolean recurse) throws IOException {
+        File libDir = new File(path);
+        if (libDir.exists()) {
+            File files[] = libDir.listFiles();
+            for (File file: files) {
+                String fileName = file.getName();
+                // FIXME: filter out other files?
+                if (file.isDirectory() && !"CVS".equals(fileName) && !".svn".equals(fileName) && recurse) {
+                    loadLibs(classPath, file.getCanonicalPath(), recurse);
+                } else if (fileName.endsWith(".jar") || fileName.endsWith(".zip")) {
+                    classPath.addComponent(file);
+                }
+            }
+        }
+    }
+
 }

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=1085794&r1=1085793&r2=1085794&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 Sat Mar 26 19:52:44 2011
@@ -92,8 +92,6 @@ public class Start {
         }
     }
 
-    private ClassLoader classloader = null;
-    private Classpath classPath = new Classpath(System.getProperty("java.class.path"));
     private Config config = null;
     private String[] loaderArgs = null;
     private List<StartupLoader> loaders = new ArrayList<StartupLoader>();
@@ -151,44 +149,11 @@ public class Start {
     }
 
     private void initClasspath() throws IOException {
-        // load tools.jar
-        if (config.toolsJar != null) {
-            classPath.addComponent(config.toolsJar);
-        }
-
-        // load comm.jar
-        if (config.commJar != null) {
-            classPath.addComponent(config.commJar);
-        }
-
-        // add OFBIZ_HOME to CP & load libs
-        classPath.addClasspath(config.ofbizHome);
-        loadLibs(config.ofbizHome, false);
-
-        // load the lib directory
-        if (config.baseLib != null) {
-            loadLibs(config.baseLib, true);
-        }
-
-        // load the ofbiz-base.jar
-        if (config.baseJar != null) {
-            classPath.addComponent(config.baseJar);
-        }
-
-        // load the base schema directory
-        if (config.baseDtd != null) {
-            classPath.addComponent(config.baseDtd);
-        }
-
-        // load the config directory
-        if (config.baseConfig != null) {
-            classPath.addComponent(config.baseConfig);
-        }
-
-        classPath.instrument(config.instrumenterFile, config.instrumenterClassName);
-        // set the classpath/classloader
+        Classpath classPath = new Classpath(System.getProperty("java.class.path"));
+        this.config.initClasspath(classPath);
+        // Set the classpath/classloader
         System.setProperty("java.class.path", classPath.toString());
-        this.classloader = classPath.getClassLoader();
+        ClassLoader classloader = classPath.getClassLoader();
         Thread.currentThread().setContextClassLoader(classloader);
         if (System.getProperty("DEBUG") != null) {
             System.out.println("Startup Classloader: " + classloader.toString());
@@ -220,6 +185,7 @@ public class Start {
     }
 
     private void initStartLoaders() {
+        ClassLoader classloader = Thread.currentThread().getContextClassLoader();
         synchronized (this.loaders) {
             // initialize the loaders
             for (String loaderClassName: config.loaders) {
@@ -239,22 +205,6 @@ public class Start {
         }
     }
 
-    private void loadLibs(String path, boolean recurse) throws IOException {
-        File libDir = new File(path);
-        if (libDir.exists()) {
-            File files[] = libDir.listFiles();
-            for (File file: files) {
-                String fileName = file.getName();
-                // FIXME: filter out other files?
-                if (file.isDirectory() && !"CVS".equals(fileName) && !".svn".equals(fileName) && recurse) {
-                    loadLibs(file.getCanonicalPath(), recurse);
-                } else if (fileName.endsWith(".jar") || fileName.endsWith(".zip")) {
-                    classPath.addComponent(file);
-                }
-            }
-        }
-    }
-
     private String sendSocketCommand(String command) throws IOException, ConnectException {
         Socket socket = new Socket(config.adminAddress, config.adminPort);