|
|
|
@ -3,7 +3,9 @@ package io.dynamic.threadpool.starter.toolkit.thread;
|
|
|
|
|
import io.dynamic.threadpool.starter.spi.DynamicTpServiceLoader;
|
|
|
|
|
import io.dynamic.threadpool.starter.spi.rejected.CustomRejectedExecutionHandler;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.concurrent.RejectedExecutionHandler;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
@ -61,6 +63,10 @@ public enum RejectedTypeEnum {
|
|
|
|
|
this.rejectedHandler = rejectedHandler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static {
|
|
|
|
|
DynamicTpServiceLoader.register(CustomRejectedExecutionHandler.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static RejectedExecutionHandler createPolicy(Integer type) {
|
|
|
|
|
Optional<RejectedExecutionHandler> rejectedTypeEnum = Stream.of(RejectedTypeEnum.values())
|
|
|
|
|
.filter(each -> Objects.equals(type, each.type))
|
|
|
|
|