onami-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1504119 - /onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java
Date Wed, 17 Jul 2013 13:22:10 GMT
Author: simonetripodi
Date: Wed Jul 17 13:22:10 2013
New Revision: 1504119

URL: http://svn.apache.org/r1504119
Log:
reorganizing internals

Modified:
    onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java

Modified: onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java
URL: http://svn.apache.org/viewvc/onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java?rev=1504119&r1=1504118&r2=1504119&view=diff
==============================================================================
--- onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java
(original)
+++ onami/sandbox/console/src/main/java/org/apache/onami/console/commands/ConsoleRunner.java
Wed Jul 17 13:22:10 2013
@@ -78,43 +78,15 @@ public final class ConsoleRunner
 
     public void run()
     {
-        setupLogging();
-
-        // read the console configuration
-
-        ClassLoader artifactsClassLoader;
-
-        if ( !artifacts.isEmpty() )
-        {
-            URL[] urls = new URL[artifacts.size()];
+        // setup logging configuration
 
-            for ( int i = 0; i < urls.length; i++ )
-            {
-                String artifact = artifacts.get( i );
-
-                logger.debug( "Adding artifact {}...", artifact );
-
-                try
-                {
-                    urls[i] = new URL( artifact );
+        setupLogging();
 
-                    logger.debug( "Artifact {} added for class loading building.", artifact
);
-                }
-                catch ( MalformedURLException e )
-                {
-                    logger.warn( "Artifact {} can not be loaded: {} - It will be ignored",
-                                 artifact, e.getMessage() );
-                }
-            }
+        // setup the classloader
 
-            artifactsClassLoader = new URLClassLoader( urls, getClass().getClassLoader()
);
-        }
-        else
-        {
-            artifactsClassLoader = getClass().getClassLoader();
-        }
+        ClassLoader artifactsClassLoader = getArtifactsClassLoader();
 
-        // setup the injector by discovering modules automatically
+        // setup the injector by discovering modules and commands automatically
 
         Injector injector = createInjector( expandVariables( loadModules( artifactsClassLoader
) ),
                                             new ClassLoaderModule( artifactsClassLoader )
);
@@ -220,4 +192,35 @@ public final class ConsoleRunner
         }
     }
 
+    private ClassLoader getArtifactsClassLoader()
+    {
+        if ( artifacts.isEmpty() )
+        {
+            return getClass().getClassLoader();
+        }
+
+        URL[] urls = new URL[artifacts.size()];
+
+        for ( int i = 0; i < urls.length; i++ )
+        {
+            String artifact = artifacts.get( i );
+
+            logger.debug( "Adding artifact {}...", artifact );
+
+            try
+            {
+                urls[i] = new URL( artifact );
+
+                logger.debug( "Artifact {} added for class loading building.", artifact );
+            }
+            catch ( MalformedURLException e )
+            {
+                logger.warn( "Artifact {} can not be loaded: {} - It will be ignored",
+                             artifact, e.getMessage() );
+            }
+        }
+
+        return new URLClassLoader( urls, getClass().getClassLoader() );
+    }
+
 }



Mime
View raw message