|
|
@ -1,29 +1,44 @@
|
|
|
|
package io.dynamic.threadpool.starter.config;
|
|
|
|
package io.dynamic.threadpool.starter.handler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import io.dynamic.threadpool.starter.config.DynamicThreadPoolProperties;
|
|
|
|
|
|
|
|
import lombok.NonNull;
|
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
|
import org.springframework.boot.ansi.AnsiColor;
|
|
|
|
import org.springframework.boot.ansi.AnsiColor;
|
|
|
|
import org.springframework.boot.ansi.AnsiOutput;
|
|
|
|
import org.springframework.boot.ansi.AnsiOutput;
|
|
|
|
import org.springframework.boot.ansi.AnsiStyle;
|
|
|
|
import org.springframework.boot.ansi.AnsiStyle;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 动态线程池 Banner
|
|
|
|
* 动态线程池打印 Banner.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author chen.ma
|
|
|
|
* @author chen.ma
|
|
|
|
* @date 2021/7/4 15:58
|
|
|
|
* @date 2021/6/20 16:34
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class DynamicThreadPoolBanner {
|
|
|
|
@Slf4j
|
|
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
|
|
|
public class ThreadPoolBannerHandler implements InitializingBean {
|
|
|
|
|
|
|
|
|
|
|
|
private static final String DYNAMIC_THREAD_POOL = " :: Dynamic ThreadPool :: ";
|
|
|
|
@NonNull
|
|
|
|
|
|
|
|
private final DynamicThreadPoolProperties properties;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int STRAP_LINE_SIZE = 50;
|
|
|
|
private final String DYNAMIC_THREAD_POOL = " :: Dynamic ThreadPool :: ";
|
|
|
|
|
|
|
|
|
|
|
|
public static void printBanner(boolean isBanner) {
|
|
|
|
private final int STRAP_LINE_SIZE = 50;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void afterPropertiesSet() {
|
|
|
|
|
|
|
|
printBanner();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void printBanner() {
|
|
|
|
String banner = "\n___ _ _____ ___ \n" +
|
|
|
|
String banner = "\n___ _ _____ ___ \n" +
|
|
|
|
"| \\ _ _ _ _ __ _ _ __ (_)__ |_ _| _ \\\n" +
|
|
|
|
"| \\ _ _ _ _ __ _ _ __ (_)__ |_ _| _ \\\n" +
|
|
|
|
"| |) | || | ' \\/ _` | ' \\| / _| | | | _/\n" +
|
|
|
|
"| |) | || | ' \\/ _` | ' \\| / _| | | | _/\n" +
|
|
|
|
"|___/ \\_, |_||_\\__,_|_|_|_|_\\__| |_| |_| \n" +
|
|
|
|
"|___/ \\_, |_||_\\__,_|_|_|_|_\\__| |_| |_| \n" +
|
|
|
|
" |__/ \n";
|
|
|
|
" |__/ \n";
|
|
|
|
|
|
|
|
|
|
|
|
if (isBanner) {
|
|
|
|
if (properties.isBanner()) {
|
|
|
|
String version = getVersion();
|
|
|
|
String version = getVersion();
|
|
|
|
version = (version != null) ? " (v" + version + ")" : "no version.";
|
|
|
|
version = (version != null) ? " (v" + version + ")" : "no version.";
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +53,7 @@ public class DynamicThreadPoolBanner {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String getVersion() {
|
|
|
|
public static String getVersion() {
|
|
|
|
final Package pkg = DynamicThreadPoolBanner.class.getPackage();
|
|
|
|
final Package pkg = ThreadPoolBannerHandler.class.getPackage();
|
|
|
|
return pkg != null ? pkg.getImplementationVersion() : "";
|
|
|
|
return pkg != null ? pkg.getImplementationVersion() : "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|