You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@batchee.apache.org by rm...@apache.org on 2015/11/30 11:42:47 UTC

incubator-batchee git commit: adding @Exit

Repository: incubator-batchee
Updated Branches:
  refs/heads/master 0ab8285da -> 68bbcb961


adding @Exit


Project: http://git-wip-us.apache.org/repos/asf/incubator-batchee/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-batchee/commit/68bbcb96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-batchee/tree/68bbcb96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-batchee/diff/68bbcb96

Branch: refs/heads/master
Commit: 68bbcb9617cb2da1ae4b2e026f92374529f9731c
Parents: 0ab8285
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Mon Nov 30 11:43:17 2015 +0100
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Mon Nov 30 11:43:17 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/batchee/cli/BatchEECLI.java | 11 +++++++
 .../org/apache/batchee/cli/command/Exit.java    | 32 ++++++++++++++++++++
 2 files changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/68bbcb96/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java
----------------------------------------------------------------------
diff --git a/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java b/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java
index ef737b4..d184d6c 100644
--- a/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java
+++ b/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java
@@ -21,6 +21,7 @@ import io.airlift.airline.Help;
 import io.airlift.airline.ParseException;
 import org.apache.batchee.cli.command.Abandon;
 import org.apache.batchee.cli.command.Executions;
+import org.apache.batchee.cli.command.Exit;
 import org.apache.batchee.cli.command.Instances;
 import org.apache.batchee.cli.command.Names;
 import org.apache.batchee.cli.command.Restart;
@@ -86,6 +87,16 @@ public class BatchEECLI {
             parser.parse(args).run();
         } catch (final ParseException e) {
             parser.parse("help").run();
+        } catch (final RuntimeException e) {
+            Class<?> current = e.getClass();
+            while (current != null) {
+                final Exit annotation = current.getAnnotation(Exit.class);
+                if (annotation != null) {
+                    System.exit(annotation.value());
+                }
+                current = current.getSuperclass();
+            }
+            throw e;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/68bbcb96/tools/cli/src/main/java/org/apache/batchee/cli/command/Exit.java
----------------------------------------------------------------------
diff --git a/tools/cli/src/main/java/org/apache/batchee/cli/command/Exit.java b/tools/cli/src/main/java/org/apache/batchee/cli/command/Exit.java
new file mode 100644
index 0000000..f24f3ac
--- /dev/null
+++ b/tools/cli/src/main/java/org/apache/batchee/cli/command/Exit.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.batchee.cli.command;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface Exit {
+    /**
+     * @return the exit code to use.
+     */
+    int value();
+}