Author: doogie
Date: Wed Oct 17 11:09:32 2007 New Revision: 585613 URL: http://svn.apache.org/viewvc?rev=585613&view=rev Log: Java 1.5 markup. Closes https://issues.apache.org/jira/browse/OFBIZ-1312 Modified: ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Classpath.java ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java Modified: ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Classpath.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Classpath.java?rev=585613&r1=585612&r2=585613&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Classpath.java (original) +++ ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Classpath.java Wed Oct 17 11:09:32 2007 @@ -35,7 +35,7 @@ */ public class Classpath { - private List _elements = new ArrayList(); + private List<File> _elements = new ArrayList<File>(); public Classpath() {} @@ -93,12 +93,12 @@ StringBuilder cp = new StringBuilder(1024); int cnt = _elements.size(); if (cnt >= 1) { - cp.append(((File) (_elements.get(0))).getPath()); - appendPath(cp, ((File) (_elements.get(0))).getPath()); + cp.append(_elements.get(0).getPath()); + appendPath(cp, _elements.get(0).getPath()); } for (int i = 1; i < cnt; i++) { cp.append(File.pathSeparatorChar); - appendPath(cp, ((File) (_elements.get(i))).getPath()); + appendPath(cp, _elements.get(i).getPath()); } return cp.toString(); } @@ -108,7 +108,7 @@ URL[] urls = new URL[cnt]; for (int i = 0; i < cnt; i++) { try { - urls[i] = ((File) (_elements.get(i))).toURI().toURL(); + urls[i] = _elements.get(i).toURI().toURL(); } catch (MalformedURLException e) { // note: this is printing right to the console because at this point we don't have the rest of the system up, not even the logging stuff System.out.println("Error adding classpath entry: " + e.toString()); @@ -131,7 +131,7 @@ return new URLClassLoader(urls, parent); } - public List getElements() { + public List<File> getElements() { return _elements; } } Modified: ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java?rev=585613&r1=585612&r2=585613&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java (original) +++ ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java Wed Oct 17 11:09:32 2007 @@ -49,7 +49,7 @@ private boolean serverStarted = false; private boolean serverStopping = false; private boolean serverRunning = true; - private List loaders = null; + private List<StartupLoader> loaders = null; private Config config = null; private String[] loaderArgs = null; @@ -61,7 +61,7 @@ String firstArg = args.length > 0 ? args[0] : ""; String cfgFile = Start.getConfigFileName(firstArg); - this.loaders = new ArrayList(); + this.loaders = new ArrayList<StartupLoader>(); this.config = new Config(); // read the default properties first @@ -168,12 +168,13 @@ File libDir = new File(path); if (libDir.exists()) { File files[] = libDir.listFiles(); - for (int i = 0; i < files.length; i++) { - String fileName = files[i].getName(); - if (files[i].isDirectory() && !"CVS".equals(fileName) && recurse) { - loadLibs(files[i].getCanonicalPath(), recurse); + for (File file: files) { + String fileName = file.getName(); + // FIXME: filter out other files? + if (file.isDirectory() && !"CVS".equals(fileName) && recurse) { + loadLibs(file.getCanonicalPath(), recurse); } else if (fileName.endsWith(".jar") || fileName.endsWith(".zip")) { - classPath.addComponent(files[i]); + classPath.addComponent(file); } } } @@ -240,9 +241,7 @@ private void initStartLoaders() { // initialize the loaders - Iterator li = config.loaders.iterator(); - while (li.hasNext()) { - String loaderClassName = (String) li.next(); + for (String loaderClassName: config.loaders) { try { Class loaderClass = classloader.loadClass(loaderClassName); StartupLoader loader = (StartupLoader) loaderClass.newInstance(); @@ -257,9 +256,7 @@ private void startStartLoaders() { // start the loaders - Iterator i = loaders.iterator(); - while (i.hasNext()) { - StartupLoader loader = (StartupLoader) i.next(); + for (StartupLoader loader: loaders) { try { loader.start(); } catch (StartupException e) { @@ -297,9 +294,7 @@ if (serverStopping) return; serverStopping = true; if (loaders != null && loaders.size() > 0) { - Iterator i = loaders.iterator(); - while (i.hasNext()) { - StartupLoader loader = (StartupLoader) i.next(); + for (StartupLoader loader: loaders) { try { loader.unload(); } catch (Exception e) { @@ -439,7 +434,7 @@ public String baseDtd; public String baseConfig; public String logDir; - public List loaders; + public List<String> loaders; public String awtHeadless; public String splashLogo; public boolean shutdownAfterLoad = false; @@ -648,7 +643,7 @@ System.setProperty("org.mortbay.jetty.servlet.AbstractSessionManager.24SessionDestroyed", "true"); // loader classes - loaders = new ArrayList(); + loaders = new ArrayList<String>(); int currentPosition = 1; while (true) { String loaderClass = props.getProperty("ofbiz.start.loader" + currentPosition); |
Free forum by Nabble | Edit this page |