diff --git a/adapter/adapter-dubbo/src/main/java/org/dromara/dynamictp/adapter/dubbo/apache/EagerThreadPoolExecutorProxy.java b/adapter/adapter-dubbo/src/main/java/org/dromara/dynamictp/adapter/dubbo/apache/EagerThreadPoolExecutorProxy.java index 266529ede..838e20c8e 100644 --- a/adapter/adapter-dubbo/src/main/java/org/dromara/dynamictp/adapter/dubbo/apache/EagerThreadPoolExecutorProxy.java +++ b/adapter/adapter-dubbo/src/main/java/org/dromara/dynamictp/adapter/dubbo/apache/EagerThreadPoolExecutorProxy.java @@ -59,7 +59,7 @@ public EagerThreadPoolExecutorProxy(EagerThreadPoolExecutor executor) { @Override public void execute(Runnable command) { - command = getEnhancedTask(command, taskWrappers); + command = getEnhancedTask(command); AwareManager.execute(this, command); super.execute(command); } @@ -76,6 +76,11 @@ protected void afterExecute(Runnable r, Throwable t) { AwareManager.afterExecute(this, r, t); } + @Override + public List getTaskWrappers() { + return taskWrappers; + } + @Override public void setTaskWrappers(List taskWrappers) { this.taskWrappers = taskWrappers; diff --git a/adapter/adapter-motan/src/main/java/org/dromara/dynamictp/adapter/motan/StandardThreadExecutorProxy.java b/adapter/adapter-motan/src/main/java/org/dromara/dynamictp/adapter/motan/StandardThreadExecutorProxy.java index eceee7a89..ac398bd68 100644 --- a/adapter/adapter-motan/src/main/java/org/dromara/dynamictp/adapter/motan/StandardThreadExecutorProxy.java +++ b/adapter/adapter-motan/src/main/java/org/dromara/dynamictp/adapter/motan/StandardThreadExecutorProxy.java @@ -54,7 +54,7 @@ public StandardThreadExecutorProxy(StandardThreadExecutor executor) { @Override public void execute(Runnable command) { - command = getEnhancedTask(command, taskWrappers); + command = getEnhancedTask(command); AwareManager.execute(this, command); super.execute(command); } @@ -71,6 +71,11 @@ protected void afterExecute(Runnable r, Throwable t) { AwareManager.afterExecute(this, r, t); } + @Override + public List getTaskWrappers() { + return taskWrappers; + } + @Override public void setTaskWrappers(List taskWrappers) { this.taskWrappers = taskWrappers; diff --git a/core/src/main/java/org/dromara/dynamictp/core/aware/TaskEnhanceAware.java b/core/src/main/java/org/dromara/dynamictp/core/aware/TaskEnhanceAware.java index 97df7d9b0..15f2466ee 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/aware/TaskEnhanceAware.java +++ b/core/src/main/java/org/dromara/dynamictp/core/aware/TaskEnhanceAware.java @@ -50,6 +50,23 @@ default Runnable getEnhancedTask(Runnable command, List taskWrapper return command; } + /** + * Enhance task + * + * @param command command + * @return enhanced task + */ + default Runnable getEnhancedTask(Runnable command) { + return getEnhancedTask(command, getTaskWrappers()); + } + + /** + * Get task wrappers + * + * @return task wrappers + */ + List getTaskWrappers(); + /** * Set task wrappers * diff --git a/core/src/main/java/org/dromara/dynamictp/core/executor/DtpExecutor.java b/core/src/main/java/org/dromara/dynamictp/core/executor/DtpExecutor.java index b5f5aa6bf..ad1566bcf 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/executor/DtpExecutor.java +++ b/core/src/main/java/org/dromara/dynamictp/core/executor/DtpExecutor.java @@ -179,7 +179,7 @@ public void execute(Runnable task, long startTimeout) { @Override public void execute(Runnable command) { - command = getEnhancedTask(command, taskWrappers); + command = getEnhancedTask(command); AwareManager.execute(this, command); super.execute(command); } @@ -273,6 +273,7 @@ public void setPlatformIds(List platformIds) { this.platformIds = platformIds; } + @Override public List getTaskWrappers() { return taskWrappers; } diff --git a/core/src/main/java/org/dromara/dynamictp/core/support/ExecutorType.java b/core/src/main/java/org/dromara/dynamictp/core/executor/ExecutorType.java similarity index 84% rename from core/src/main/java/org/dromara/dynamictp/core/support/ExecutorType.java rename to core/src/main/java/org/dromara/dynamictp/core/executor/ExecutorType.java index 3e33237de..e5888bb12 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/support/ExecutorType.java +++ b/core/src/main/java/org/dromara/dynamictp/core/executor/ExecutorType.java @@ -15,12 +15,9 @@ * limitations under the License. */ -package org.dromara.dynamictp.core.support; +package org.dromara.dynamictp.core.executor; -import org.dromara.dynamictp.core.executor.DtpExecutor; -import org.dromara.dynamictp.core.executor.ScheduledDtpExecutor; -import org.dromara.dynamictp.core.executor.EagerDtpExecutor; -import org.dromara.dynamictp.core.executor.OrderedDtpExecutor; +import org.dromara.dynamictp.core.executor.eager.EagerDtpExecutor; import lombok.Getter; /** diff --git a/core/src/main/java/org/dromara/dynamictp/core/executor/EagerDtpExecutor.java b/core/src/main/java/org/dromara/dynamictp/core/executor/eager/EagerDtpExecutor.java similarity index 97% rename from core/src/main/java/org/dromara/dynamictp/core/executor/EagerDtpExecutor.java rename to core/src/main/java/org/dromara/dynamictp/core/executor/eager/EagerDtpExecutor.java index 1dc8a38f3..137f1042f 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/executor/EagerDtpExecutor.java +++ b/core/src/main/java/org/dromara/dynamictp/core/executor/eager/EagerDtpExecutor.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.dromara.dynamictp.core.executor; +package org.dromara.dynamictp.core.executor.eager; -import org.dromara.dynamictp.core.support.TaskQueue; +import org.dromara.dynamictp.core.executor.DtpExecutor; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executors; diff --git a/core/src/main/java/org/dromara/dynamictp/core/support/TaskQueue.java b/core/src/main/java/org/dromara/dynamictp/core/executor/eager/TaskQueue.java similarity index 96% rename from core/src/main/java/org/dromara/dynamictp/core/support/TaskQueue.java rename to core/src/main/java/org/dromara/dynamictp/core/executor/eager/TaskQueue.java index 5ddd80b9f..8a440661d 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/support/TaskQueue.java +++ b/core/src/main/java/org/dromara/dynamictp/core/executor/eager/TaskQueue.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.dromara.dynamictp.core.support; +package org.dromara.dynamictp.core.executor.eager; import org.dromara.dynamictp.common.queue.VariableLinkedBlockingQueue; -import org.dromara.dynamictp.core.executor.EagerDtpExecutor; +import org.dromara.dynamictp.core.executor.eager.EagerDtpExecutor; import org.springframework.lang.NonNull; import java.util.concurrent.RejectedExecutionException; diff --git a/core/src/main/java/org/dromara/dynamictp/core/spring/DtpBeanDefinitionRegistrar.java b/core/src/main/java/org/dromara/dynamictp/core/spring/DtpBeanDefinitionRegistrar.java index 9abcd0302..5f56727de 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/spring/DtpBeanDefinitionRegistrar.java +++ b/core/src/main/java/org/dromara/dynamictp/core/spring/DtpBeanDefinitionRegistrar.java @@ -24,12 +24,12 @@ import org.dromara.dynamictp.common.entity.DtpExecutorProps; import org.dromara.dynamictp.common.properties.DtpProperties; import org.dromara.dynamictp.common.spring.SpringBeanHelper; -import org.dromara.dynamictp.core.executor.EagerDtpExecutor; +import org.dromara.dynamictp.core.executor.eager.EagerDtpExecutor; import org.dromara.dynamictp.core.executor.NamedThreadFactory; import org.dromara.dynamictp.core.reject.RejectHandlerGetter; import org.dromara.dynamictp.core.support.BinderHelper; -import org.dromara.dynamictp.core.support.ExecutorType; -import org.dromara.dynamictp.core.support.TaskQueue; +import org.dromara.dynamictp.core.executor.ExecutorType; +import org.dromara.dynamictp.core.executor.eager.TaskQueue; import org.dromara.dynamictp.core.support.task.wrapper.TaskWrappers; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.context.EnvironmentAware; diff --git a/core/src/main/java/org/dromara/dynamictp/core/spring/DtpPostProcessor.java b/core/src/main/java/org/dromara/dynamictp/core/spring/DtpPostProcessor.java index ffd425d71..092f4a136 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/spring/DtpPostProcessor.java +++ b/core/src/main/java/org/dromara/dynamictp/core/spring/DtpPostProcessor.java @@ -24,11 +24,11 @@ import org.dromara.dynamictp.common.util.ReflectionUtil; import org.dromara.dynamictp.core.DtpRegistry; import org.dromara.dynamictp.core.executor.DtpExecutor; -import org.dromara.dynamictp.core.executor.EagerDtpExecutor; +import org.dromara.dynamictp.core.executor.eager.EagerDtpExecutor; import org.dromara.dynamictp.core.plugin.DtpInterceptorRegistry; import org.dromara.dynamictp.core.support.DynamicTp; import org.dromara.dynamictp.core.support.ExecutorWrapper; -import org.dromara.dynamictp.core.support.TaskQueue; +import org.dromara.dynamictp.core.executor.eager.TaskQueue; import org.dromara.dynamictp.core.support.ThreadPoolExecutorProxy; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; diff --git a/core/src/main/java/org/dromara/dynamictp/core/support/ThreadPoolBuilder.java b/core/src/main/java/org/dromara/dynamictp/core/support/ThreadPoolBuilder.java index b687df898..4df4d9f61 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/support/ThreadPoolBuilder.java +++ b/core/src/main/java/org/dromara/dynamictp/core/support/ThreadPoolBuilder.java @@ -25,10 +25,11 @@ import org.dromara.dynamictp.common.em.RejectedTypeEnum; import org.dromara.dynamictp.common.entity.NotifyItem; import org.dromara.dynamictp.common.queue.VariableLinkedBlockingQueue; +import org.dromara.dynamictp.core.executor.eager.TaskQueue; import org.dromara.dynamictp.core.reject.RejectHandlerGetter; import org.dromara.dynamictp.core.support.task.wrapper.TaskWrapper; import org.dromara.dynamictp.core.executor.DtpExecutor; -import org.dromara.dynamictp.core.executor.EagerDtpExecutor; +import org.dromara.dynamictp.core.executor.eager.EagerDtpExecutor; import org.dromara.dynamictp.core.executor.NamedThreadFactory; import org.dromara.dynamictp.core.executor.OrderedDtpExecutor; import org.dromara.dynamictp.core.executor.ScheduledDtpExecutor; diff --git a/core/src/main/java/org/dromara/dynamictp/core/support/ThreadPoolExecutorProxy.java b/core/src/main/java/org/dromara/dynamictp/core/support/ThreadPoolExecutorProxy.java index 7c255ecaa..427effcc7 100644 --- a/core/src/main/java/org/dromara/dynamictp/core/support/ThreadPoolExecutorProxy.java +++ b/core/src/main/java/org/dromara/dynamictp/core/support/ThreadPoolExecutorProxy.java @@ -45,11 +45,12 @@ public class ThreadPoolExecutorProxy extends ThreadPoolExecutor implements TaskE /** * Reject handler type. */ - private final String rejectHandlerType; + private String rejectHandlerType; public ThreadPoolExecutorProxy(ThreadPoolExecutor executor) { super(executor.getCorePoolSize(), executor.getMaximumPoolSize(), - executor.getKeepAliveTime(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS, executor.getQueue(), + executor.getKeepAliveTime(TimeUnit.MILLISECONDS), + TimeUnit.MILLISECONDS, executor.getQueue(), executor.getThreadFactory(), executor.getRejectedExecutionHandler()); this.rejectHandlerType = getRejectedExecutionHandler().getClass().getSimpleName(); setRejectedExecutionHandler(RejectHandlerGetter.getProxy(getRejectedExecutionHandler())); @@ -58,7 +59,7 @@ public ThreadPoolExecutorProxy(ThreadPoolExecutor executor) { @Override public void execute(Runnable command) { - command = getEnhancedTask(command, taskWrappers); + command = getEnhancedTask(command); AwareManager.execute(this, command); super.execute(command); } @@ -76,6 +77,11 @@ protected void afterExecute(Runnable r, Throwable t) { AwareManager.afterExecute(this, r, t); } + @Override + public List getTaskWrappers() { + return taskWrappers; + } + @Override public void setTaskWrappers(List taskWrappers) { this.taskWrappers = taskWrappers; diff --git a/dependencies/pom.xml b/dependencies/pom.xml index d03a66efb..659f23ec8 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -12,7 +12,7 @@ https://github.com/yanhom1314/dynamic-tp - 1.1.4 + 1.1.4.1 5.8.12 1.18.24 1.5.0 diff --git a/pom.xml b/pom.xml index bf8d2480a..013ee6a5e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ https://github.com/yanhom1314/dynamic-tp - 1.1.4 + 1.1.4.1 1.8 2.5.14 2020.0.5 diff --git a/starter/starter-adapter/starter-adapter-webserver/src/main/java/org/dromara/dynamictp/starter/adapter/webserver/tomcat/TomcatExecutorProxy.java b/starter/starter-adapter/starter-adapter-webserver/src/main/java/org/dromara/dynamictp/starter/adapter/webserver/tomcat/TomcatExecutorProxy.java index d05d2e33a..c9edd5377 100644 --- a/starter/starter-adapter/starter-adapter-webserver/src/main/java/org/dromara/dynamictp/starter/adapter/webserver/tomcat/TomcatExecutorProxy.java +++ b/starter/starter-adapter/starter-adapter-webserver/src/main/java/org/dromara/dynamictp/starter/adapter/webserver/tomcat/TomcatExecutorProxy.java @@ -76,7 +76,7 @@ public TomcatExecutorProxy(ThreadPoolExecutor executor) { @Override public void execute(Runnable command) { - command = getEnhancedTask(command, taskWrappers); + command = getEnhancedTask(command); AwareManager.execute(this, command); super.execute(command); } @@ -93,6 +93,11 @@ protected void afterExecute(Runnable r, Throwable t) { AwareManager.afterExecute(this, r, t); } + @Override + public List getTaskWrappers() { + return taskWrappers; + } + @Override public void setTaskWrappers(List taskWrappers) { this.taskWrappers = taskWrappers;