|
@@ -7,8 +7,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.http.HttpStatus;
|
|
import org.apache.http.HttpStatus;
|
|
|
-import seecoder.devcloud.core.pipeline.handler.*;
|
|
|
|
|
-
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
@@ -23,12 +21,12 @@ import java.util.Map;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class HandlerConfigTable {
|
|
public class HandlerConfigTable {
|
|
|
|
|
|
|
|
- private static final Map<String, Class<?>> handlerConfigMap;
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 表驱动的设置
|
|
|
|
|
- * 注意这里的对应并不是一一对应,而是多对一
|
|
|
|
|
|
|
+ * 根据名称映射对应的流水线执行类
|
|
|
*/
|
|
*/
|
|
|
|
|
+ private static final Map<String, Class<?>> handlerConfigMap;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
static {
|
|
static {
|
|
|
handlerConfigMap = new HashMap<>();
|
|
handlerConfigMap = new HashMap<>();
|
|
|
handlerConfigMap.put("node-image-build", NodeImageBuildHandler.class);
|
|
handlerConfigMap.put("node-image-build", NodeImageBuildHandler.class);
|
|
@@ -40,7 +38,7 @@ public class HandlerConfigTable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static Handler transToHandler(String name, JsonNode config) throws Exception {
|
|
public static Handler transToHandler(String name, JsonNode config) throws Exception {
|
|
|
- Handler handler = null;
|
|
|
|
|
|
|
+ Handler handler;
|
|
|
try {
|
|
try {
|
|
|
handler = (Handler) handlerConfigMap.get(name).newInstance();
|
|
handler = (Handler) handlerConfigMap.get(name).newInstance();
|
|
|
} catch (InstantiationException | IllegalAccessException e) {
|
|
} catch (InstantiationException | IllegalAccessException e) {
|
|
@@ -53,7 +51,7 @@ public class HandlerConfigTable {
|
|
|
String propertyName = entry.getKey();
|
|
String propertyName = entry.getKey();
|
|
|
JsonNode propertyValues = entry.getValue();
|
|
JsonNode propertyValues = entry.getValue();
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
- Field field = null;
|
|
|
|
|
|
|
+ Field field ;
|
|
|
field = handler.getClass().getDeclaredField(propertyName);
|
|
field = handler.getClass().getDeclaredField(propertyName);
|
|
|
field.setAccessible(true);
|
|
field.setAccessible(true);
|
|
|
field.set(handler, mapper.readValue(propertyValues.traverse(), field.getType()));
|
|
field.set(handler, mapper.readValue(propertyValues.traverse(), field.getType()));
|