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 c926451c5270a54772582da2ab3a7eb80cf64b5e Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Jun 13 09:10:56 2019 +0200 CAMEL-13636: camel3 - SPI for ReactiveHelper so we can plugin different reactive engines --- .../org/apache/camel/spi/ReactiveExecutor.java | 47 ++++++++++++++++++++-- .../impl/engine/ReactiveExecutorResolver.java | 4 +- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ReactiveExecutor.java b/core/camel-api/src/main/java/org/apache/camel/spi/ReactiveExecutor.java index 37744fb..f61b012 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ReactiveExecutor.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ReactiveExecutor.java @@ -23,30 +23,69 @@ import org.apache.camel.AsyncCallback; */ public interface ReactiveExecutor { - // TODO: Add javadoc - // TODO: Better name - + /** + * Schedules the task to be run + * + * @param runnable the task + */ default void schedule(Runnable runnable) { schedule(runnable, null); } + /** + * Schedules the task to be run + * + * @param runnable the task + * @param description a human readable description for logging purpose + */ void schedule(Runnable runnable, String description); + /** + * Schedules the task to be prioritized and run asap + * + * @param runnable the task + */ default void scheduleMain(Runnable runnable) { scheduleMain(runnable, null); } + /** + * Schedules the task to be prioritized and run asap + * + * @param runnable the task + * @param description a human readable description for logging purpose + */ void scheduleMain(Runnable runnable, String description); + /** + * Schedules the task to run synchronously + * + * @param runnable the task + */ default void scheduleSync(Runnable runnable) { scheduleSync(runnable, null); } + /** + * Schedules the task to run synchronously + * + * @param runnable the task + * @param description a human readable description for logging purpose + */ void scheduleSync(Runnable runnable, String description); - // TODO: Can we make this so we dont need an method on this interface as its only used once + /** + * Executes the next task + * + * @return true if a task was executed or false if no more pending tasks + */ boolean executeFromQueue(); + /** + * Schedules the callback to be run + * + * @param callback the callable + */ default void callback(AsyncCallback callback) { schedule(new Runnable() { diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/ReactiveExecutorResolver.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/ReactiveExecutorResolver.java index 3a78412..b5a2d03 100644 --- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/ReactiveExecutorResolver.java +++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/ReactiveExecutorResolver.java @@ -40,14 +40,14 @@ public class ReactiveExecutorResolver { // use factory finder to find a custom implementations Class<?> type = null; try { - type = findFactory("reactive-executor-factory", context); + type = findFactory("reactive-executor", context); } catch (Exception e) { // ignore } if (type != null) { if (LOG.isDebugEnabled()) { - LOG.debug("Found ReactiveExecutor: {} via: {}{}", type.getName(), factoryFinder.getResourcePath(), "reactive-executor-factory"); + LOG.debug("Found ReactiveExecutor: {} via: {}{}", type.getName(), factoryFinder.getResourcePath(), "reactive-executor"); } if (ReactiveExecutor.class.isAssignableFrom(type)) { ReactiveExecutor answer = (ReactiveExecutor) context.getInjector().newInstance(type, false);