From b4d72d5843aab0d7b08b28e0bf07859a47419c67 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Wed, 5 Mar 2008 16:38:46 +0000 Subject: [PATCH] After OPENJPA-9, -help option in scripts is not working anymore. This is caused by Configurations.runAgainstAllAnchors returns true if no error is encountered (including no operation) during function execution. Since the check of the -help option is in the command's run method and if no anchor is found, the help check is skipped. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@633921 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java | 3 --- .../java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java | 3 --- .../java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java | 3 --- .../org/apache/openjpa/jdbc/kernel/ValueTableJDBCSeq.java | 3 --- .../java/org/apache/openjpa/jdbc/meta/MappingTool.java | 3 --- .../org/apache/openjpa/jdbc/meta/ReverseMappingTool.java | 3 --- .../java/org/apache/openjpa/jdbc/schema/SchemaTool.java | 3 --- .../org/apache/openjpa/jdbc/schema/TableSchemaFactory.java | 3 --- .../java/org/apache/openjpa/enhance/ApplicationIdTool.java | 3 --- .../main/java/org/apache/openjpa/enhance/PCEnhancer.java | 3 --- .../main/java/org/apache/openjpa/meta/MetaDataTool.java | 7 ++----- .../java/org/apache/openjpa/lib/conf/Configurations.java | 3 +++ 12 files changed, 5 insertions(+), 35 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java index 2182caae1..00533d390 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ClassTableJDBCSeq.java @@ -189,9 +189,6 @@ public class ClassTableJDBCSeq */ public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws Exception { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - String action = opts.removeProperty("action", "a", null); Configurations.populateConfiguration(conf, opts); return run(conf, args, action, null, null); diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java index 776c6e9dd..cf0621618 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java @@ -337,9 +337,6 @@ public class NativeJDBCSeq public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws Exception { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - String action = opts.removeProperty("action", "a", null); Configurations.populateConfiguration(conf, opts); return run(conf, args, action); diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java index 026cb31d4..af84c4f09 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java @@ -635,9 +635,6 @@ public class TableJDBCSeq public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws Exception { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - String action = opts.removeProperty("action", "a", null); Configurations.populateConfiguration(conf, opts); return run(conf, args, action); diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ValueTableJDBCSeq.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ValueTableJDBCSeq.java index 38d76d92a..329fcad52 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ValueTableJDBCSeq.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ValueTableJDBCSeq.java @@ -142,9 +142,6 @@ public class ValueTableJDBCSeq public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws Exception { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - String action = opts.removeProperty("action", "a", null); Configurations.populateConfiguration(conf, opts); return run(conf, args, action, null, null); diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java index fb6b7d518..d9ac176dc 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java @@ -942,9 +942,6 @@ public class MappingTool public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws IOException, SQLException { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - // flags Flags flags = new Flags(); flags.action = opts.removeProperty("action", "a", flags.action); diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java index f0860efc9..c418bcebf 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java @@ -1843,9 +1843,6 @@ public class ReverseMappingTool public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws IOException, SQLException { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - // flags Flags flags = new Flags(); flags.packageName = opts.removeProperty diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java index 3ea7dea1d..37b99b2dd 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java @@ -1357,9 +1357,6 @@ public class SchemaTool { public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws IOException, SQLException { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - Flags flags = new Flags(); flags.dropTables = opts.removeBooleanProperty ("dropTables", "dt", flags.dropTables); diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java index 53d33dc60..df21bcf4b 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java @@ -473,9 +473,6 @@ public class TableSchemaFactory public static boolean run(JDBCConfiguration conf, String[] args, Options opts) throws IOException, SQLException { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - String action = opts.removeProperty("action", "a", null); Configurations.populateConfiguration(conf, opts); return run(conf, action); diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java index 274fde1d2..a4e968dad 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java @@ -1306,9 +1306,6 @@ public class ApplicationIdTool { public static boolean run(OpenJPAConfiguration conf, String[] args, Options opts) throws IOException, ClassNotFoundException { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - Flags flags = new Flags(); flags.ignoreErrors = opts.removeBooleanProperty ("ignoreErrors", "i", flags.ignoreErrors); diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java index a2f527737..52b4572a1 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java @@ -4365,9 +4365,6 @@ public class PCEnhancer { public static boolean run(OpenJPAConfiguration conf, String[] args, Options opts) throws IOException { - if (opts.containsKey("help") || opts.containsKey("-help")) - return false; - Flags flags = new Flags(); flags.directory = Files.getFile(opts.removeProperty("directory", "d", null), null); diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java index 2b19b7dfc..9b2b9bc02 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java @@ -251,7 +251,8 @@ public class MetaDataTool throws IOException { Options opts = new Options(); final String[] arguments = opts.setFromCmdLine(args); - boolean ret = Configurations.runAgainstAllAnchors(opts, + boolean ret = (args.length > 0) && + Configurations.runAgainstAllAnchors(opts, new Configurations.Runnable() { public boolean run(Options opts) throws Exception { OpenJPAConfiguration conf = new OpenJPAConfigurationImpl(); @@ -272,10 +273,6 @@ public class MetaDataTool public static boolean run(OpenJPAConfiguration conf, String[] args, Options opts) throws IOException { - if (args.length == 0 || opts.containsKey("help") - || opts.containsKey("-help")) - return false; - Flags flags = new Flags(); flags.action = opts.removeProperty("action", "a", flags.action); String fileName = opts.removeProperty("file", "f", null); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java index 9094ee249..668410cb9 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java @@ -673,6 +673,9 @@ public class Configurations { */ public static boolean runAgainstAllAnchors(Options opts, Configurations.Runnable runnable) { + if (opts.containsKey("help") || opts.containsKey("-help")) { + return false; + } List anchors = Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts);