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 2020/03/14 07:53:13 UTC
[camel] 01/02: Move lifecycle api into its own api for camel
context.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4e67b1e73ae3a234ada56200d07ac9013a003757
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Mar 14 07:33:03 2020 +0100
Move lifecycle api into its own api for camel context.
---
.../main/java/org/apache/camel/CamelContext.java | 44 +-------
.../org/apache/camel/CamelContextLifecycle.java | 124 +++++++++++++++++++++
.../camel/impl/lw/ImmutableCamelContext.java | 2 +-
3 files changed, 127 insertions(+), 43 deletions(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
index 96471ca..a51c1d7 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel;
-import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -59,7 +58,7 @@ import org.apache.camel.support.jsse.SSLContextParameters;
* Interface used to represent the CamelContext used to configure routes and the
* policies to use during message exchanges between endpoints.
* <p/>
- * The CamelContext offers the following methods to control the lifecycle:
+ * The CamelContext offers the following methods {@link CamelContextLifecycle} to control the lifecycle:
* <ul>
* <li>{@link #start()} - to start (<b>important:</b> the start method is not blocked, see more details
* <a href="http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html">here</a>)</li>
@@ -80,20 +79,7 @@ import org.apache.camel.support.jsse.SSLContextParameters;
* <p/>
* For more advanced APIs with {@link CamelContext} see {@link ExtendedCamelContext}, which you can obtain via the adapt method.
*/
-public interface CamelContext extends RuntimeConfiguration, AutoCloseable {
-
- boolean isStarted();
- boolean isStarting();
- boolean isStopped();
- boolean isStopping();
- boolean isSuspended();
- boolean isSuspending();
- boolean isRunAllowed();
- void init();
- void suspend();
- void resume();
- void shutdown();
- void close() throws IOException;
+public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguration {
/**
* Adapts this {@link org.apache.camel.CamelContext} to the specialized type.
@@ -128,25 +114,6 @@ public interface CamelContext extends RuntimeConfiguration, AutoCloseable {
boolean isVetoStarted();
/**
- * Starts the {@link CamelContext} (<b>important:</b> the start method is not blocked, see more details
- * <a href="http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html">here</a>)</li>.
- * <p/>
- * See more details at the class-level javadoc of this class.
- *
- * @throws RuntimeCamelException is thrown if starting failed
- */
- void start();
-
- /**
- * Stop and shutdown the {@link CamelContext} (will stop all routes/components/endpoints etc and clear internal state/cache).
- * <p/>
- * See more details at the class-level javadoc of this class.
- *
- * @throws RuntimeCamelException is thrown if stopping failed
- */
- void stop();
-
- /**
* Gets the name (id) of the this CamelContext.
*
* @return the name
@@ -205,13 +172,6 @@ public interface CamelContext extends RuntimeConfiguration, AutoCloseable {
String getVersion();
/**
- * Get the status of this CamelContext
- *
- * @return the status
- */
- ServiceStatus getStatus();
-
- /**
* Gets the uptime in a human readable format
*
* @return the uptime in days/hours/minutes
diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelContextLifecycle.java b/core/camel-api/src/main/java/org/apache/camel/CamelContextLifecycle.java
new file mode 100644
index 0000000..7c4b327
--- /dev/null
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelContextLifecycle.java
@@ -0,0 +1,124 @@
+/*
+ * 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.camel;
+
+/**
+ * Lifecycle API for {@link CamelContext}.
+ */
+public interface CamelContextLifecycle extends AutoCloseable {
+
+ /**
+ * Starts the {@link CamelContext} (<b>important:</b> the start method is not blocked, see more details
+ * <a href="http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html">here</a>)</li>.
+ * <p/>
+ * See more details at the class-level javadoc of this class.
+ *
+ * @throws RuntimeCamelException is thrown if starting failed
+ */
+ void start();
+
+ /**
+ * Stop and shutdown the {@link CamelContext} (will stop all routes/components/endpoints etc and clear internal state/cache).
+ * <p/>
+ * See more details at the class-level javadoc of this class.
+ *
+ * @throws RuntimeCamelException is thrown if stopping failed
+ */
+ void stop();
+
+ /**
+ * Whether the CamelContext is started
+ *
+ * @return true if this CamelContext has been started
+ */
+ boolean isStarted();
+
+ /**
+ * Whether the CamelContext is starting
+ *
+ * @return true if this CamelContext is being started
+ */
+ boolean isStarting();
+
+ /**
+ * Whether the CamelContext is stopping
+ *
+ * @return true if this CamelContext is in the process of stopping
+ */
+ boolean isStopping();
+
+ /**
+ * Whether the CamelContext is stopped
+ *
+ * @return true if this CamelContext is stopped
+ */
+ boolean isStopped();
+
+ /**
+ * Whether the CamelContext is suspending
+ *
+ * @return true if this CamelContext is in the process of suspending
+ */
+ boolean isSuspending();
+
+ /**
+ * Whether the CamelContext is suspended
+ *
+ * @return true if this CamelContext is suspended
+ */
+ boolean isSuspended();
+
+ /**
+ * Helper methods so the CamelContext knows if it should keep running.
+ * Returns <tt>false</tt> if the CamelContext is being stopped or is stopped.
+ *
+ * @return <tt>true</tt> if the CamelContext should continue to run.
+ */
+ boolean isRunAllowed();
+
+ void init();
+
+ /**
+ * Suspends the CamelContext.
+ */
+ void suspend();
+
+ /**
+ * Resumes the CamelContext.
+ */
+ void resume();
+
+ /**
+ * Shutdown the CamelContext, which means it cannot be started again.
+ */
+ void shutdown();
+
+ /**
+ * Closes (Shutdown) the CamelContext, which means it cannot be started again.
+ *
+ * @throws Exception is thrown if shutdown failed
+ */
+ void close() throws Exception;
+
+ /**
+ * Get the status of this CamelContext
+ *
+ * @return the status
+ */
+ ServiceStatus getStatus();
+
+}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/ImmutableCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/ImmutableCamelContext.java
index 14313aa..71ffe85 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/ImmutableCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/ImmutableCamelContext.java
@@ -229,7 +229,7 @@ public class ImmutableCamelContext implements ExtendedCamelContext, CatalogCamel
}
@Override
- public void close() throws IOException {
+ public void close() throws Exception {
delegate.close();
}