You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/11/22 09:58:18 UTC
[camel] 01/02: CAMEL-17215: camel-main - MainShutdownStrategy polished
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 40943be07fc20ea80d9383e39d416fd4131bf526
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Nov 22 07:33:41 2021 +0100
CAMEL-17215: camel-main - MainShutdownStrategy polished
---
.../camel/main/DefaultMainShutdownStrategy.java | 4 ++--
.../org/apache/camel/main/MainShutdownStrategy.java | 20 +++++++++++++++-----
.../camel/main/SimpleMainShutdownStrategy.java | 4 ++--
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
index 9958622..5c73c05 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
@@ -66,9 +66,9 @@ public class DefaultMainShutdownStrategy extends SimpleMainShutdownStrategy {
}
@Override
- public void await(long timeout, TimeUnit unit) throws InterruptedException {
+ public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
installHangupInterceptor();
- super.await(timeout, unit);
+ return super.await(timeout, unit);
}
private void handleHangup() {
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainShutdownStrategy.java b/core/camel-main/src/main/java/org/apache/camel/main/MainShutdownStrategy.java
index 023ad48..46ab437 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainShutdownStrategy.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainShutdownStrategy.java
@@ -35,28 +35,38 @@ public interface MainShutdownStrategy {
}
+ /**
+ * Adds a shutdown listener
+ *
+ * @param listener the listener
+ */
void addShutdownListener(ShutdownEventListener listener);
/**
+ * Returns true if the application is allowed to run.
+ *
* @return true if the application is allowed to run.
*/
boolean isRunAllowed();
/**
+ * Return true if the shutdown has been initiated by the caller.
+ *
* @return true if the shutdown has been initiated by the caller.
*/
boolean shutdown();
/**
- * Wait for main to complete.
+ * Waiting for Camel Main to complete.
*/
void await() throws InterruptedException;
/**
- * Wait for main to complete.
+ * Waiting for Camel Main to complete.
*
- * @param timeout the maximum time to wait
- * @param unit the time unit of the {@code timeout} argument
+ * @param timeout the maximum time to wait
+ * @param unit the time unit of the {@code timeout} argument
+ * @return true if Camel Main was completed before the timeout, false if timeout was triggered.
*/
- void await(long timeout, TimeUnit unit) throws InterruptedException;
+ boolean await(long timeout, TimeUnit unit) throws InterruptedException;
}
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/SimpleMainShutdownStrategy.java b/core/camel-main/src/main/java/org/apache/camel/main/SimpleMainShutdownStrategy.java
index 7675edb..18b7ae4 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/SimpleMainShutdownStrategy.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/SimpleMainShutdownStrategy.java
@@ -74,8 +74,8 @@ public class SimpleMainShutdownStrategy implements MainShutdownStrategy {
}
@Override
- public void await(long timeout, TimeUnit unit) throws InterruptedException {
+ public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
LOG.debug("Await shutdown to complete with timeout: {} {}", timeout, unit);
- latch.await(timeout, unit);
+ return latch.await(timeout, unit);
}
}