From edf68fafc12757a4874f43f77c9260393797d6b8 Mon Sep 17 00:00:00 2001 From: igornb Date: Thu, 2 Sep 2021 09:43:04 +0300 Subject: [PATCH] 1) deleted unused io.tesler.api.task package --- ...SecurityContextAwareAsyncTaskExecutor.java | 59 --------- ...ityContextAwareSchedulingTaskExecutor.java | 61 --------- .../SecurityContextAwareTaskExecutor.java | 46 ------- .../SecurityContextAwareTaskScheduler.java | 48 ------- .../decorators/ClassLoaderAwareCallable.java | 55 -------- .../decorators/ClassLoaderAwareRunnable.java | 55 -------- .../task/decorators/SubjectAwareCallable.java | 64 ---------- .../task/decorators/SubjectAwareRunnable.java | 64 ---------- ...DelegatingAsyncListenableTaskExecutor.java | 45 ------- .../DelegatingAsyncTaskExecutor.java | 54 -------- .../task/executors/DelegatingExecutor.java | 48 ------- .../executors/DelegatingExecutorService.java | 118 ------------------ .../DelegatingScheduledExecutorService.java | 56 --------- .../DelegatingSchedulingTaskExecutor.java | 38 ------ .../executors/DelegatingTaskExecutor.java | 32 ----- .../executors/DelegatingTaskScheduler.java | 67 ---------- 16 files changed, 910 deletions(-) delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareAsyncTaskExecutor.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareSchedulingTaskExecutor.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareTaskExecutor.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareTaskScheduler.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/decorators/ClassLoaderAwareCallable.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/decorators/ClassLoaderAwareRunnable.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/decorators/SubjectAwareCallable.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/decorators/SubjectAwareRunnable.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingAsyncListenableTaskExecutor.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingAsyncTaskExecutor.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingExecutor.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingExecutorService.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingScheduledExecutorService.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingSchedulingTaskExecutor.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingTaskExecutor.java delete mode 100644 tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingTaskScheduler.java diff --git a/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareAsyncTaskExecutor.java b/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareAsyncTaskExecutor.java deleted file mode 100644 index f799647016..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareAsyncTaskExecutor.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task; - -import io.tesler.api.task.decorators.ClassLoaderAwareCallable; -import io.tesler.api.task.decorators.ClassLoaderAwareRunnable; -import io.tesler.api.task.decorators.SubjectAwareCallable; -import io.tesler.api.task.decorators.SubjectAwareRunnable; -import io.tesler.api.task.executors.DelegatingAsyncTaskExecutor; -import java.util.concurrent.Callable; -import lombok.SneakyThrows; -import org.springframework.core.task.AsyncTaskExecutor; -import org.springframework.security.concurrent.DelegatingSecurityContextCallable; -import org.springframework.security.concurrent.DelegatingSecurityContextRunnable; - - -public class SecurityContextAwareAsyncTaskExecutor extends DelegatingAsyncTaskExecutor { - - public SecurityContextAwareAsyncTaskExecutor(AsyncTaskExecutor delegate) { - super(delegate); - } - - @Override - @SneakyThrows - protected Callable wrap(Callable task) { - Callable contextAware = DelegatingSecurityContextCallable.create(task, null); - contextAware = SubjectAwareCallable.wrap(contextAware); - contextAware = ClassLoaderAwareCallable.wrap(contextAware); - return contextAware; - } - - @Override - @SneakyThrows - protected Runnable wrap(Runnable command) { - Runnable contextAware = DelegatingSecurityContextRunnable.create(command, null); - contextAware = SubjectAwareRunnable.wrap(contextAware); - contextAware = ClassLoaderAwareRunnable.wrap(contextAware); - return contextAware; - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareSchedulingTaskExecutor.java b/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareSchedulingTaskExecutor.java deleted file mode 100644 index 1279a27e38..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareSchedulingTaskExecutor.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task; - -import io.tesler.api.task.decorators.ClassLoaderAwareCallable; -import io.tesler.api.task.decorators.ClassLoaderAwareRunnable; -import io.tesler.api.task.decorators.SubjectAwareCallable; -import io.tesler.api.task.decorators.SubjectAwareRunnable; -import io.tesler.api.task.executors.DelegatingSchedulingTaskExecutor; -import java.util.concurrent.Callable; -import lombok.SneakyThrows; -import org.springframework.scheduling.SchedulingTaskExecutor; -import org.springframework.security.concurrent.DelegatingSecurityContextCallable; -import org.springframework.security.concurrent.DelegatingSecurityContextRunnable; - - -public class SecurityContextAwareSchedulingTaskExecutor - extends DelegatingSchedulingTaskExecutor { - - public SecurityContextAwareSchedulingTaskExecutor(SchedulingTaskExecutor delegate) { - super(delegate); - } - - @Override - @SneakyThrows - protected Callable wrap(Callable task) { - Callable contextAware = DelegatingSecurityContextCallable.create(task, null); - contextAware = SubjectAwareCallable.wrap(contextAware); - contextAware = ClassLoaderAwareCallable.wrap(contextAware); - return contextAware; - } - - - @Override - @SneakyThrows - protected Runnable wrap(Runnable command) { - Runnable contextAware = DelegatingSecurityContextRunnable.create(command, null); - contextAware = SubjectAwareRunnable.wrap(contextAware); - contextAware = ClassLoaderAwareRunnable.wrap(contextAware); - return contextAware; - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareTaskExecutor.java b/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareTaskExecutor.java deleted file mode 100644 index 2ba62f3b65..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareTaskExecutor.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task; - -import io.tesler.api.task.decorators.ClassLoaderAwareRunnable; -import io.tesler.api.task.decorators.SubjectAwareRunnable; -import io.tesler.api.task.executors.DelegatingTaskExecutor; -import lombok.SneakyThrows; -import org.springframework.core.task.TaskExecutor; -import org.springframework.security.concurrent.DelegatingSecurityContextRunnable; - - -public class SecurityContextAwareTaskExecutor extends DelegatingTaskExecutor { - - public SecurityContextAwareTaskExecutor(TaskExecutor delegate) { - super(delegate); - } - - @Override - @SneakyThrows - protected Runnable wrap(Runnable command) { - Runnable contextAware = DelegatingSecurityContextRunnable.create(command, null); - contextAware = SubjectAwareRunnable.wrap(contextAware); - contextAware = ClassLoaderAwareRunnable.wrap(contextAware); - return contextAware; - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareTaskScheduler.java b/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareTaskScheduler.java deleted file mode 100644 index 6a5927993c..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/SecurityContextAwareTaskScheduler.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task; - -import io.tesler.api.task.decorators.ClassLoaderAwareRunnable; -import io.tesler.api.task.decorators.SubjectAwareRunnable; -import io.tesler.api.task.executors.DelegatingTaskScheduler; -import lombok.SneakyThrows; -import org.springframework.core.task.TaskExecutor; -import org.springframework.scheduling.TaskScheduler; -import org.springframework.security.concurrent.DelegatingSecurityContextRunnable; - - -public class SecurityContextAwareTaskScheduler - extends DelegatingTaskScheduler { - - public SecurityContextAwareTaskScheduler(T delegate) { - super(delegate); - } - - @Override - @SneakyThrows - protected Runnable wrap(Runnable command) { - Runnable contextAware = DelegatingSecurityContextRunnable.create(command, null); - contextAware = SubjectAwareRunnable.wrap(contextAware); - contextAware = ClassLoaderAwareRunnable.wrap(contextAware); - return contextAware; - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/decorators/ClassLoaderAwareCallable.java b/tesler-api/src/main/java/io/tesler/api/task/decorators/ClassLoaderAwareCallable.java deleted file mode 100644 index e26f3a1f65..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/decorators/ClassLoaderAwareCallable.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.decorators; - -import java.util.Objects; -import java.util.concurrent.Callable; - - -public class ClassLoaderAwareCallable implements Callable { - - private final Callable delegate; - - private final ClassLoader classLoader; - - private ClassLoaderAwareCallable(Callable delegate, ClassLoader classLoader) { - this.delegate = Objects.requireNonNull(delegate); - this.classLoader = classLoader; - } - - @SuppressWarnings("unchecked") - public static Callable wrap(Callable task) { - return new ClassLoaderAwareCallable<>(task, Thread.currentThread().getContextClassLoader()); - } - - - @Override - public E call() throws Exception { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(classLoader); - return delegate.call(); - } finally { - Thread.currentThread().setContextClassLoader(cl); - } - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/decorators/ClassLoaderAwareRunnable.java b/tesler-api/src/main/java/io/tesler/api/task/decorators/ClassLoaderAwareRunnable.java deleted file mode 100644 index b7cb252737..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/decorators/ClassLoaderAwareRunnable.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.decorators; - -import java.util.Objects; - - -public class ClassLoaderAwareRunnable implements Runnable { - - private final Runnable delegate; - - private final ClassLoader classLoader; - - private ClassLoaderAwareRunnable(Runnable command, ClassLoader classLoader) { - this.delegate = Objects.requireNonNull(command); - this.classLoader = classLoader; - } - - @SuppressWarnings("unchecked") - public static Runnable wrap(Runnable command) { - return new ClassLoaderAwareRunnable(command, Thread.currentThread().getContextClassLoader()); - } - - - @Override - public void run() { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(classLoader); - delegate.run(); - } finally { - Thread.currentThread().setContextClassLoader(cl); - } - - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/decorators/SubjectAwareCallable.java b/tesler-api/src/main/java/io/tesler/api/task/decorators/SubjectAwareCallable.java deleted file mode 100644 index 5593eceec4..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/decorators/SubjectAwareCallable.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.decorators; - -import io.tesler.api.util.Invoker; -import io.tesler.api.util.ServiceUtils; -import io.tesler.api.util.privileges.IPrivilegedInvoker; -import java.security.GeneralSecurityException; -import java.util.Objects; -import java.util.concurrent.Callable; -import javax.security.auth.Subject; - - -public class SubjectAwareCallable implements Callable { - - private final Callable delegate; - - private final IPrivilegedInvoker invoker; - - private final Subject[] subjects; - - private SubjectAwareCallable(Callable delegate, IPrivilegedInvoker invoker, Subject... subjects) { - this.delegate = Objects.requireNonNull(delegate); - this.invoker = Objects.requireNonNull(invoker); - this.subjects = Objects.requireNonNull(subjects); - } - - @SuppressWarnings("unchecked") - public static Callable wrap(Callable task) throws GeneralSecurityException { - IPrivilegedInvoker invoker = - ServiceUtils.getService(IPrivilegedInvoker.class, SubjectAwareCallable.class); - if (invoker == null) { - return task; - } - Subject callerSubject = invoker.getCallerSubject(); - Subject runAsSubject = invoker.getRunAsSubject(); - return new SubjectAwareCallable<>(task, invoker, runAsSubject, callerSubject); - } - - - @Override - public E call() throws Exception { - return invoker.runAs(Invoker.of(delegate), subjects); - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/decorators/SubjectAwareRunnable.java b/tesler-api/src/main/java/io/tesler/api/task/decorators/SubjectAwareRunnable.java deleted file mode 100644 index 5788999910..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/decorators/SubjectAwareRunnable.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.decorators; - -import io.tesler.api.util.Invoker; -import io.tesler.api.util.ServiceUtils; -import io.tesler.api.util.privileges.IPrivilegedInvoker; -import java.security.GeneralSecurityException; -import java.util.Objects; -import javax.security.auth.Subject; - - -public class SubjectAwareRunnable implements Runnable { - - private final Runnable delegate; - - private final IPrivilegedInvoker invoker; - - private final Subject[] subjects; - - private SubjectAwareRunnable(Runnable command, IPrivilegedInvoker invoker, - Subject... subjects) { - this.delegate = Objects.requireNonNull(command); - this.invoker = Objects.requireNonNull(invoker); - this.subjects = Objects.requireNonNull(subjects); - } - - @SuppressWarnings("unchecked") - public static Runnable wrap(Runnable command) throws GeneralSecurityException { - IPrivilegedInvoker invoker = - ServiceUtils.getService(IPrivilegedInvoker.class, SubjectAwareRunnable.class); - if (invoker == null) { - return command; - } - Subject callerSubject = invoker.getCallerSubject(); - Subject runAsSubject = invoker.getRunAsSubject(); - return new SubjectAwareRunnable(command, invoker, runAsSubject, callerSubject); - } - - - @Override - public void run() { - invoker.runAs(Invoker.of(delegate), subjects); - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingAsyncListenableTaskExecutor.java b/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingAsyncListenableTaskExecutor.java deleted file mode 100644 index 116cf26f16..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingAsyncListenableTaskExecutor.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.executors; - -import java.util.concurrent.Callable; -import org.springframework.core.task.AsyncListenableTaskExecutor; -import org.springframework.util.concurrent.ListenableFuture; - - -public class DelegatingAsyncListenableTaskExecutor - extends DelegatingAsyncTaskExecutor implements AsyncListenableTaskExecutor { - - public DelegatingAsyncListenableTaskExecutor(T delegate) { - super(delegate); - } - - @Override - public ListenableFuture submitListenable(Runnable task) { - return getDelegate().submitListenable(wrap(task)); - } - - @Override - public ListenableFuture submitListenable(Callable task) { - return getDelegate().submitListenable(wrap(task)); - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingAsyncTaskExecutor.java b/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingAsyncTaskExecutor.java deleted file mode 100644 index 4b0001aefa..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingAsyncTaskExecutor.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.executors; - -import java.util.concurrent.Callable; -import java.util.concurrent.Future; -import org.springframework.core.task.AsyncTaskExecutor; - - -public class DelegatingAsyncTaskExecutor extends DelegatingTaskExecutor - implements AsyncTaskExecutor { - - public DelegatingAsyncTaskExecutor(T delegate) { - super(delegate); - } - - @Override - public void execute(Runnable task, long startTimeout) { - getDelegate().execute(wrap(task), startTimeout); - } - - @Override - public Future submit(Runnable task) { - return getDelegate().submit(wrap(task)); - } - - @Override - public Future submit(Callable task) { - return getDelegate().submit(wrap(task)); - } - - protected Callable wrap(Callable task) { - return task; - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingExecutor.java b/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingExecutor.java deleted file mode 100644 index d1997a4a70..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingExecutor.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.executors; - -import java.util.Objects; -import java.util.concurrent.Executor; - - -public class DelegatingExecutor implements Executor { - - private final T delegate; - - public DelegatingExecutor(T delegate) { - this.delegate = Objects.requireNonNull(delegate); - } - - public T getDelegate() { - return delegate; - } - - @Override - public void execute(Runnable command) { - getDelegate().execute(wrap(command)); - } - - protected Runnable wrap(Runnable command) { - return command; - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingExecutorService.java b/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingExecutorService.java deleted file mode 100644 index 54e05c2584..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingExecutorService.java +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.executors; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - - -public class DelegatingExecutorService extends DelegatingExecutor - implements ExecutorService { - - public DelegatingExecutorService(T delegate) { - super(delegate); - } - - @Override - public void shutdown() { - getDelegate().shutdown(); - } - - @Override - public List shutdownNow() { - return getDelegate().shutdownNow(); - } - - @Override - public boolean isShutdown() { - return getDelegate().isShutdown(); - } - - @Override - public boolean isTerminated() { - return getDelegate().isTerminated(); - } - - @Override - public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { - return getDelegate().awaitTermination(timeout, unit); - } - - @Override - public Future submit(Callable task) { - return getDelegate().submit(wrap(task)); - } - - @Override - public Future submit(Runnable task, E result) { - return getDelegate().submit(wrap(task), result); - } - - @Override - public Future submit(Runnable task) { - return getDelegate().submit(wrap(task)); - } - - @Override - public List> invokeAll(Collection> tasks) throws InterruptedException { - return getDelegate().invokeAll(wrap(tasks)); - } - - @Override - public List> invokeAll(Collection> tasks, long timeout, TimeUnit unit) - throws InterruptedException { - return getDelegate().invokeAll(wrap(tasks), timeout, unit); - } - - @Override - public E invokeAny(Collection> tasks) throws InterruptedException, ExecutionException { - return getDelegate().invokeAny(wrap(tasks)); - } - - @Override - public E invokeAny(Collection> tasks, long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - return getDelegate().invokeAny(wrap(tasks), timeout, unit); - } - - protected Callable wrap(Callable task) { - return task; - } - - protected Collection> wrap(Collection> tasks) { - if (tasks == null) { - return null; - } - List> results = new ArrayList<>(tasks.size()); - for (Callable task : tasks) { - results.add(wrap(task)); - } - return results; - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingScheduledExecutorService.java b/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingScheduledExecutorService.java deleted file mode 100644 index c10de54148..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingScheduledExecutorService.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.executors; - -import java.util.concurrent.Callable; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - - -public class DelegatingScheduledExecutorService extends DelegatingExecutorService - implements ScheduledExecutorService { - - public DelegatingScheduledExecutorService(T delegate) { - super(delegate); - } - - @Override - public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { - return getDelegate().schedule(wrap(command), delay, unit); - } - - @Override - public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) { - return getDelegate().schedule(wrap(callable), delay, unit); - } - - @Override - public ScheduledFuture scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { - return getDelegate().scheduleAtFixedRate(wrap(command), initialDelay, period, unit); - } - - @Override - public ScheduledFuture scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { - return getDelegate().scheduleWithFixedDelay(wrap(command), initialDelay, delay, unit); - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingSchedulingTaskExecutor.java b/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingSchedulingTaskExecutor.java deleted file mode 100644 index 496936088d..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingSchedulingTaskExecutor.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.executors; - -import org.springframework.scheduling.SchedulingTaskExecutor; - - -public class DelegatingSchedulingTaskExecutor extends DelegatingAsyncTaskExecutor - implements SchedulingTaskExecutor { - - public DelegatingSchedulingTaskExecutor(T delegate) { - super(delegate); - } - - @Override - public boolean prefersShortLivedTasks() { - return getDelegate().prefersShortLivedTasks(); - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingTaskExecutor.java b/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingTaskExecutor.java deleted file mode 100644 index f1da48132d..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingTaskExecutor.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.executors; - -import org.springframework.core.task.TaskExecutor; - - -public class DelegatingTaskExecutor extends DelegatingExecutor implements TaskExecutor { - - public DelegatingTaskExecutor(T delegate) { - super(delegate); - } - -} diff --git a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingTaskScheduler.java b/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingTaskScheduler.java deleted file mode 100644 index 29fb310a5f..0000000000 --- a/tesler-api/src/main/java/io/tesler/api/task/executors/DelegatingTaskScheduler.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * #%L - * IO Tesler - API - * %% - * Copyright (C) 2018 - 2019 Tesler Contributors - * %% - * Licensed 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. - * #L% - */ - -package io.tesler.api.task.executors; - -import java.util.Date; -import java.util.concurrent.ScheduledFuture; -import org.springframework.core.task.TaskExecutor; -import org.springframework.scheduling.TaskScheduler; -import org.springframework.scheduling.Trigger; - - -public class DelegatingTaskScheduler extends DelegatingExecutor - implements TaskScheduler { - - public DelegatingTaskScheduler(T delegate) { - super(delegate); - } - - @Override - public ScheduledFuture schedule(Runnable task, Trigger trigger) { - return getDelegate().schedule(wrap(task), trigger); - } - - @Override - public ScheduledFuture schedule(Runnable task, Date startTime) { - return getDelegate().schedule(wrap(task), startTime); - } - - @Override - public ScheduledFuture scheduleAtFixedRate(Runnable task, Date startTime, long period) { - return getDelegate().scheduleAtFixedRate(wrap(task), startTime, period); - } - - @Override - public ScheduledFuture scheduleAtFixedRate(Runnable task, long period) { - return getDelegate().scheduleAtFixedRate(wrap(task), period); - } - - @Override - public ScheduledFuture scheduleWithFixedDelay(Runnable task, Date startTime, long delay) { - return getDelegate().scheduleWithFixedDelay(wrap(task), startTime, delay); - } - - @Override - public ScheduledFuture scheduleWithFixedDelay(Runnable task, long delay) { - return getDelegate().scheduleWithFixedDelay(wrap(task), delay); - } - -}