openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r634150 - /openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
Date Thu, 06 Mar 2008 04:12:12 GMT
Author: allee8285
Date: Wed Mar  5 20:12:11 2008
New Revision: 634150

URL: http://svn.apache.org/viewvc?rev=634150&view=rev
Log:
OPENJPA-532 This patch enables command runnable to process once when no persistence unit is
found by the tool commands. This allows command option(s) which does not require pu definition
to function properly.

Modified:
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java?rev=634150&r1=634149&r2=634150&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
Wed Mar  5 20:12:11 2008
@@ -686,17 +686,28 @@
             opts.remove("p");
 
         boolean ret = true;
-        for (Iterator iter = anchors.iterator(); iter.hasNext(); ) {
-            Options clonedOptions = (Options) opts.clone();
-            clonedOptions.setProperty("properties", iter.next().toString());
-            try {
-                ret &= runnable.run(clonedOptions);
-            } catch (Exception e) {
-                if (!(e instanceof RuntimeException))
-                    throw new RuntimeException(e);
-                else
-                    throw (RuntimeException) e;
+        if (anchors.size() == 0) {
+            ret = launchRunnable(opts, runnable);
+        } else {
+            for (Iterator iter = anchors.iterator(); iter.hasNext(); ) { 
+                Options clonedOptions = (Options) opts.clone();
+                clonedOptions.setProperty("properties", iter.next().toString());
+                ret &= launchRunnable(clonedOptions, runnable);
             }
+        }
+        return ret;
+    }
+
+    private static boolean launchRunnable(Options opts,
+        Configurations.Runnable runnable) {
+        boolean ret = true;
+        try {
+            ret = runnable.run(opts);
+        } catch (Exception e) {
+            if (!(e instanceof RuntimeException))
+                throw new RuntimeException(e);
+            else
+                throw (RuntimeException) e;
         }
         return ret;
     }



Mime
View raw message