parent
a22b566b5b
commit
739fa9f120
|
|
@ -3,13 +3,17 @@ package org.dromara.common.core.utils;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import org.springframework.aop.framework.AopContext;
|
import org.springframework.aop.framework.AopContext;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
|
import org.springframework.boot.autoconfigure.thread.Threading;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spring工具类
|
* spring工具类
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public final class SpringUtils extends SpringUtil {
|
public final class SpringUtils extends SpringUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -57,4 +61,8 @@ public final class SpringUtils extends SpringUtil {
|
||||||
return getApplicationContext();
|
return getApplicationContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isVirtual() {
|
||||||
|
return Threading.VIRTUAL.isActive(getBean(Environment.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,10 @@ public class UndertowConfig implements WebServerFactoryCustomizer<UndertowServle
|
||||||
webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(false, 512));
|
webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(false, 512));
|
||||||
deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", webSocketDeploymentInfo);
|
deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", webSocketDeploymentInfo);
|
||||||
// 使用虚拟线程 解除下方注释 仅限jdk21
|
// 使用虚拟线程 解除下方注释 仅限jdk21
|
||||||
// if (SpringUtils.getProperty("spring.threads.virtual.enabled", Boolean.class, false)) {
|
// if (SpringUtils.isVirtual()) {
|
||||||
// deploymentInfo.setExecutor(Executors.newVirtualThreadPerTaskExecutor());
|
// ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
|
||||||
|
// deploymentInfo.setExecutor(executor);
|
||||||
|
// deploymentInfo.setAsyncExecutor(executor);
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue