r65 - trunk/mapstoragemanagerarch/src/main/java/org/nuiton/mapstoragemanager/core
Author: dlanglais Date: 2010-02-08 17:34:29 +0100 (Mon, 08 Feb 2010) New Revision: 65 Modified: trunk/mapstoragemanagerarch/src/main/java/org/nuiton/mapstoragemanager/core/PluginLoader.java Log: Tentative de diminution de la complexit?\195?\169 cyclomatique de la fonction PluginLoader(). Generally 1-4 is considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now ! 12 -> So I've re-factored it NOW !! Modified: trunk/mapstoragemanagerarch/src/main/java/org/nuiton/mapstoragemanager/core/PluginLoader.java =================================================================== --- trunk/mapstoragemanagerarch/src/main/java/org/nuiton/mapstoragemanager/core/PluginLoader.java 2010-02-08 14:32:24 UTC (rev 64) +++ trunk/mapstoragemanagerarch/src/main/java/org/nuiton/mapstoragemanager/core/PluginLoader.java 2010-02-08 16:34:29 UTC (rev 65) @@ -48,18 +48,71 @@ } // adds all the directory jars to the ClassLoader +// for (File file : directory.listFiles()) { +// if (file.getAbsolutePath().endsWith(".jar")) { +// try { +// this.addURL(file.toURI().toURL()); +// } catch (MalformedURLException e) { +// //e.printStackTrace(); +// LOG.error(e.toString(), e); +// } +// } +// } + this.addDirectoryJarsToClassLoader(directory); + + +// File libs = new File("plugins/libs"); +// if (!libs.exists()) { +// throw new Exception("No directory " + libs.getAbsolutePath()); +// } +// +// // adds all the libs jars to the ClassLoader +// for (File file : libs.listFiles()) { +// if (file.getAbsolutePath().endsWith(".jar")) { +// try { +// LOG.info("== LIB " + file.getAbsolutePath() + "..."); +// this.addURL(file.toURI().toURL()); +// } catch (MalformedURLException e) { +// //e.printStackTrace(); +// LOG.error(e.toString(), e); +// } +// } +// } + this.addLibsJarsToClassLoader(); + + // loads the jars classes for (File file : directory.listFiles()) { if (file.getAbsolutePath().endsWith(".jar")) { + LOG.info("== JAR " + file.getAbsolutePath() + "..."); + loadJarClasses(file.getAbsolutePath()); + } + } + } + + /** + * Add directory jars to ClassLoader. + * adds all the directory jars to the ClassLoader. + * @param directory directory + */ + private void addDirectoryJarsToClassLoader(File directory) { + for (File file : directory.listFiles()) { + if (file.getAbsolutePath().endsWith(".jar")) { try { this.addURL(file.toURI().toURL()); } catch (MalformedURLException e) { - //e.printStackTrace(); LOG.error(e.toString(), e); } } } + } + /** + * Add libs jars to ClassLoader. + * Adds all the libs jars to the ClassLoader. + */ + private void addLibsJarsToClassLoader() throws Exception { + File libs = new File("plugins/libs"); if (!libs.exists()) { throw new Exception("No directory " + libs.getAbsolutePath()); @@ -72,19 +125,10 @@ LOG.info("== LIB " + file.getAbsolutePath() + "..."); this.addURL(file.toURI().toURL()); } catch (MalformedURLException e) { - //e.printStackTrace(); LOG.error(e.toString(), e); } } } - - // loads the jars classes - for (File file : directory.listFiles()) { - if (file.getAbsolutePath().endsWith(".jar")) { - LOG.info("== JAR " + file.getAbsolutePath() + "..."); - loadJarClasses(file.getAbsolutePath()); - } - } } /**
participants (1)
-
dlanglais@users.nuiton.org