- 创建注解
@Target({
ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Match {
String value();
}
- 处理 match 的工具类
import com.google.common.collect.Maps;
import org.apache.commons.collections4.MapUtils;
import org.springframework.aop.support.AopUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.Map;
@Component
public class HandlerMatcher {
private LazyMap<Class, Map<String, Object>> handlerPool;
private Matcher equalMatcher;
@Resource
private ApplicationContext applicationContext;
public HandlerMatcher(ApplicationContext applicationContext) {
this.handlerPool = new NamelessClass();
this.equalMatcher = new DefaultMatcher(null);
this.applicationContext