Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

ProtocolExecutorService now implements ScheduledExecutorService

Rich Turner602a81c3ad4c
diff --git a/agent/src/main/java/org/openremote/agent/protocol/ProtocolExecutorService.java b/agent/src/main/java/org/openremote/agent/protocol/ProtocolExecutorService.java
index ce95e005b..6e8cb6984 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/ProtocolExecutorService.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/ProtocolExecutorService.java
@@ -21,6 +21,7 @@ package org.openremote.agent.protocol;
import org.openremote.container.ContainerService;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
/**
@@ -28,7 +29,7 @@ import java.util.concurrent.ScheduledFuture;
* <p>
* TODO: If we need to run blocking tasks in protocols we can add a regular thread pool/ExecutorService here
*/
-public interface ProtocolExecutorService extends ContainerService {
+public interface ProtocolExecutorService extends ScheduledExecutorService, ContainerService {
/**
* @see java.util.concurrent.ScheduledExecutorService#schedule
diff --git a/manager/server/src/main/java/org/openremote/manager/server/concurrent/ManagerExecutorService.java b/manager/server/src/main/java/org/openremote/manager/server/concurrent/ManagerExecutorService.java
index afb2ef668..588946833 100644
--- a/manager/server/src/main/java/org/openremote/manager/server/concurrent/ManagerExecutorService.java
+++ b/manager/server/src/main/java/org/openremote/manager/server/concurrent/ManagerExecutorService.java
@@ -24,10 +24,9 @@ import org.openremote.container.Container;
import org.openremote.container.concurrent.ContainerExecutor;
import org.openremote.container.concurrent.ContainerScheduledExecutor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.*;
import static org.openremote.container.util.MapAccess.getInteger;
@@ -91,6 +90,93 @@ public class ManagerExecutorService implements ProtocolExecutorService {
return scheduledTasksExecutor.scheduleWithFixedDelay(runnable, initialDelayMillis, periodMillis, TimeUnit.MILLISECONDS);
}
+ @Override
+ public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
+ return scheduledTasksExecutor.schedule(command, delay, unit);
+ }
+
+ @Override
+ public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
+ return scheduledTasksExecutor.schedule(callable, delay, unit);
+ }
+
+ @Override
+ public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
+ return scheduledTasksExecutor.scheduleAtFixedRate(command, initialDelay, period, unit);
+ }
+
+ @Override
+ public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
+ return scheduledTasksExecutor.scheduleWithFixedDelay(command, initialDelay, delay, unit);
+ }
+
+ @Override
+ public void shutdown() {
+ // Don't allow protocols to shutdown the executor
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<Runnable> shutdownNow() {
+ // Don't allow protocols to shutdown the executor
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return scheduledTasksExecutor.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return scheduledTasksExecutor.isTerminated();
+ }
+
+ @Override
+ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
+ return scheduledTasksExecutor.awaitTermination(timeout, unit);
+ }
+
+ @Override
+ public <T> Future<T> submit(Callable<T> task) {
+ return scheduledTasksExecutor.submit(task);
+ }
+
+ @Override
+ public <T> Future<T> submit(Runnable task, T result) {
+ return scheduledTasksExecutor.submit(task, result);
+ }
+
+ @Override
+ public Future<?> submit(Runnable task) {
+ return scheduledTasksExecutor.submit(task);
+ }
+
+ @Override
+ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
+ return scheduledTasksExecutor.invokeAll(tasks);
+ }
+
+ @Override
+ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
+ return scheduledTasksExecutor.invokeAll(tasks, timeout, unit);
+ }
+
+ @Override
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
+ return scheduledTasksExecutor.invokeAny(tasks);
+ }
+
+ @Override
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ return scheduledTasksExecutor.invokeAny(tasks, timeout, unit);
+ }
+
+ @Override
+ public void execute(Runnable command) {
+ scheduledTasksExecutor.execute(command);
+ }
+
@Override
public String toString() {
return getClass().getSimpleName() + "{}";