ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r551328 - in /ant/core/trunk/src/main/org/apache/tools/ant/util: ScriptRunnerCreator.java ScriptRunnerHelper.java
Date Wed, 27 Jun 2007 21:06:34 GMT
Author: mbenson
Date: Wed Jun 27 14:06:33 2007
New Revision: 551328

URL: http://svn.apache.org/viewvc?view=rev&rev=551328
Log:
formatting; unnecessary elses; etc.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java?view=diff&rev=551328&r1=551327&r2=551328
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java Wed Jun 27
14:06:33 2007
@@ -22,8 +22,7 @@
 
 /**
  * This is a helper class used by ScriptRunnerHelper to
- * create a ScriptRunner based on a classloader and
- * on a language.
+ * create a ScriptRunner based on a classloader and on a language.
  */
 public class ScriptRunnerCreator {
     private static final String AUTO = "auto";
@@ -60,7 +59,7 @@
      * @return the created script runner.
      * @throws BuildException if unable to create the ScriptRunner.
      */
-    public ScriptRunnerBase createRunner(
+    public synchronized ScriptRunnerBase createRunner(
         String manager, String language, ClassLoader classLoader) {
         this.manager      = manager;
         this.language     = language;
@@ -70,8 +69,7 @@
             throw new BuildException("script language must be specified");
         }
         if (!manager.equals(AUTO) && !manager.equals(JAVAX) && !manager.equals(BSF))
{
-                throw new BuildException(
-                    "Unsupported language prefix " + manager);
+            throw new BuildException("Unsupported language prefix " + manager);
         }
 
         // Check for bsf first then javax
@@ -88,17 +86,14 @@
         }
         if (JAVAX.equals(manager)) {
             throw new BuildException(
-                "Unable to load the script engine manager "
-                + "(" + JAVAX_MANAGER + ")");
-        } else if (BSF.equals(manager)) {
-            throw new BuildException(
-                "Unable to load the BSF script engine manager "
-                + "(" + BSF_MANAGER + ")");
-        } else {
+                    "Unable to load the script engine manager " + "(" + JAVAX_MANAGER + ")");
+        }
+        if (BSF.equals(manager)) {
             throw new BuildException(
-                "Unable to load a script engine manager "
-                + "(" + BSF_MANAGER + " or " + JAVAX_MANAGER + ")");
+                    "Unable to load the BSF script engine manager " + "(" + BSF_MANAGER +
")");
         }
+        throw new BuildException("Unable to load a script engine manager "
+                + "(" + BSF_MANAGER + " or " + JAVAX_MANAGER + ")");
     }
 
     /**
@@ -118,8 +113,7 @@
         if (!manager.equals(AUTO) && !manager.equals(checkManager)) {
             return null;
         }
-        if (scriptLoader.getResource(
-                LoaderUtils.classNameToResource(managerClass)) == null) {
+        if (scriptLoader.getResource(LoaderUtils.classNameToResource(managerClass)) == null)
{
             return null;
         }
         if (managerClass.equals(BSF_MANAGER)) {
@@ -127,7 +121,7 @@
         }
         try {
             runner = (ScriptRunnerBase) Class.forName(
-                runnerClass, true, scriptLoader).newInstance();
+                    runnerClass, true, scriptLoader).newInstance();
             runner.setProject(project);
         } catch (Exception ex) {
             throw ReflectUtil.toBuildException(ex);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java?view=diff&rev=551328&r1=551327&r2=551328
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java Wed Jun 27 14:06:33
2007
@@ -17,18 +17,16 @@
  */
 package org.apache.tools.ant.util;
 
+import java.io.File;
+
 import org.apache.tools.ant.ProjectComponent;
 import org.apache.tools.ant.types.Path;
-import java.io.File;
 import org.apache.tools.ant.types.Reference;
-import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
 import org.apache.tools.ant.types.resources.Union;
 
-
 /**
- * A class to help in creating, setting and getting
- * script runners.
+ * A class to help in creating, setting and getting script runners.
  */
 public class ScriptRunnerHelper {
     private ClasspathUtils.Delegate cpDelegate = null;
@@ -39,7 +37,7 @@
     private boolean setBeans = true;
     private ProjectComponent projectComponent;
     private ClassLoader scriptLoader = null;
-    private Union resources=new Union();
+    private Union resources = new Union();
 
     /**
      * Set the project component associated with this helper.
@@ -110,7 +108,7 @@
     }
 
     /**
-     * The script text.
+     * Add script text.
      *
      * @param text a component of the script text to be added.
      */
@@ -166,8 +164,7 @@
         scriptLoader = loader;
     }
 
-
-    private ClassLoader generateClassLoader() {
+    private synchronized ClassLoader generateClassLoader() {
         if (scriptLoader != null) {
             return scriptLoader;
         }
@@ -175,7 +172,6 @@
             scriptLoader = getClass().getClassLoader();
             return scriptLoader;
         }
-
         scriptLoader = cpDelegate.getClassLoader();
         return scriptLoader;
     }
@@ -191,8 +187,7 @@
      * Get a script runner.
      */
     private ScriptRunnerBase getRunner() {
-        return new ScriptRunnerCreator(
-            projectComponent.getProject()).createRunner(
+        return new ScriptRunnerCreator(projectComponent.getProject()).createRunner(
                 manager, language, generateClassLoader());
     }
 
@@ -200,7 +195,7 @@
      * Add any source resource.
      *
      * @param resource source of script
-     * @since Ant1.7.1
+     * @since Ant 1.7.1
      */
     public void add(ResourceCollection resource) {
         resources.add(resource);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message