refactor: 修改 engine factory 中engine的初始化方式

This commit is contained in:
CaptainB 2022-04-21 11:29:25 +08:00 committed by 刘瑞斌
parent 1a5ac05302
commit d2d8b06ece
1 changed files with 4 additions and 2 deletions

View File

@ -31,6 +31,7 @@ import org.reflections8.Reflections;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@ -46,8 +47,9 @@ public class EngineFactory {
private static TestResourcePoolService testResourcePoolService;
private static Class<? extends KubernetesTestEngine> kubernetesTestEngineClass;
static {
Reflections reflections = new Reflections(Application.class.getPackage().getName());
@PostConstruct
public void init() {
Reflections reflections = new Reflections(Application.class);
Set<Class<? extends KubernetesTestEngine>> implClass = reflections.getSubTypesOf(KubernetesTestEngine.class);
for (Class<? extends KubernetesTestEngine> aClass : implClass) {
kubernetesTestEngineClass = aClass;