tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r419894 - /incubator/tuscany/sandbox/jboynes/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java
Date Fri, 07 Jul 2006 14:04:17 GMT
Author: jboynes
Date: Fri Jul  7 07:04:16 2006
New Revision: 419894

URL: http://svn.apache.org/viewvc?rev=419894&view=rev
Log:
simplify classpath creation by using listFiles

Modified:
    incubator/tuscany/sandbox/jboynes/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java

Modified: incubator/tuscany/sandbox/jboynes/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java?rev=419894&r1=419893&r2=419894&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java
(original)
+++ incubator/tuscany/sandbox/jboynes/sca/commands/launcher/src/main/java/org/apache/tuscany/launcher/MainLauncherBooter.java
Fri Jul  7 07:04:16 2006
@@ -69,42 +69,21 @@
         }
     }
 
-    /**
-     * Create a classloader for a classpath supplied as individual file names.
-     *
-     * @param files  a list of file/directory names
-     * @param parent the parent for the new classloader
-     * @return a classloader that will load classes from the supplied path
-     */
-    protected static ClassLoader createClassLoader(ClassLoader parent, String[] files) {
-        URL[] urls = new URL[files.length];
-        for (int i = 0; i < files.length; i++) {
-            try {
-                File file = new File(files[i]);
-                urls[i] = file.toURI().toURL();
-            } catch (MalformedURLException e) {
-                // just ignore this value
-                continue;
-            }
-        }
-
-        return new URLClassLoader(urls, parent);
-    }
-
     protected static ClassLoader getTuscanyClassLoader() {
         // assume that even though the the rest of tuscany jars are not loaded
         // it co-located with the rest of the tuscany jars.
         File tuscanylib = findLoadLocation();
-        String[] jars = tuscanylib.list(FILE_FILTER);
-        String[] urls = new String[jars.length];
-        int i = 0;
-        for (String jar : jars) {
-
-            urls[i++] = tuscanylib.getAbsolutePath() + "/" + jar;
-
+        File[] jars = tuscanylib.listFiles(FILE_FILTER);
+        URL[] urls = new URL[jars.length];
+        for (int i = 0; i < jars.length; i++) {
+            try {
+                urls[i] = jars[i].toURI().toURL();
+            } catch (MalformedURLException e) {
+                // toURI should have escaped the URL
+                throw new AssertionError();
+            }
         }
-
-        return createClassLoader(MainLauncherBooter.class.getClassLoader(), urls);
+        return new URLClassLoader(urls, MainLauncherBooter.class.getClassLoader());
     }
 
     protected static File findLoadLocation() {



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message