仿真抽象
This commit is contained in:
parent
57c9fcc04f
commit
50fb1fc564
@ -0,0 +1,28 @@
|
||||
package club.joylink.rtss.simulation;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class HandlerMethod {
|
||||
|
||||
private final Object bean;
|
||||
|
||||
private final Method method;
|
||||
|
||||
private final MethodParameter[] parameters;
|
||||
|
||||
private final String description;
|
||||
/**
|
||||
* Create an instance from a bean instance and a method.
|
||||
*/
|
||||
public HandlerMethod(Object bean, Method method) {
|
||||
Assert.notNull(bean, "Bean is required");
|
||||
Assert.notNull(method, "Method is required");
|
||||
this.bean = bean;
|
||||
this.method = method;
|
||||
this.parameters = null;
|
||||
this.description = null;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package club.joylink.rtss.simulation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Component
|
||||
public @interface SimulationOperationController {
|
||||
String value() default "";
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package club.joylink.rtss.simulation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SimulationOperationDispatcher {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package club.joylink.rtss.simulation;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SimulationOperationHandlerManager implements ApplicationContextAware {
|
||||
public static final Map<String, Object> handlerMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
Map<String, Object> handlerMap = applicationContext.getBeansWithAnnotation(SimulationOperationController.class);
|
||||
for (Object handler : handlerMap.values()) {
|
||||
Method[] methods = handler.getClass().getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
SimulationOperationMapping operationMapping = method.getAnnotation(SimulationOperationMapping.class);
|
||||
if (operationMapping == null) {
|
||||
continue;
|
||||
}
|
||||
String name = operationMapping.name();
|
||||
log.info(String.format("成功加载仿真操作{name: %s, method: %s::%s}", name, handler.getClass().getName(), method.getName()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package club.joylink.rtss.simulation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Component
|
||||
public @interface SimulationOperationMapping {
|
||||
String name();
|
||||
}
|
Loading…
Reference in New Issue
Block a user