流程不重复发起调整
This commit is contained in:
parent
42eafa33d2
commit
7b94273155
|
@ -8,6 +8,8 @@ import com.chint.infrastructure.echo_framework.command.EmptyCommand;
|
|||
import com.chint.infrastructure.echo_framework.dispatch.ResultContainer;
|
||||
import com.chint.infrastructure.echo_framework.queue.SimpleMessageQueue;
|
||||
import lombok.Data;
|
||||
import org.springframework.aop.framework.AopProxyUtils;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
@ -59,13 +61,25 @@ public class EventManager implements ApplicationContextAware, BeanNameAware, Ini
|
|||
String[] allBeanNames = context.getBeanDefinitionNames();
|
||||
for (String beanName : allBeanNames) {
|
||||
if (this.beanName.equals(beanName)) continue;
|
||||
Object bean = context.getBean(beanName);
|
||||
Object bean = context.getBean(beanName);//获取的可能是动态代理的类
|
||||
scanAndRegister(bean);
|
||||
}
|
||||
}
|
||||
|
||||
private void scanAndRegister(Object bean) {
|
||||
Method[] methods = bean.getClass().getDeclaredMethods();
|
||||
Method[] methods = null;
|
||||
//判断是何种类型的代理,使得动态代理的自定义注解不会失效
|
||||
if (AopUtils.isJdkDynamicProxy(bean)) {
|
||||
Object singletonTarget = AopProxyUtils.getSingletonTarget(bean);
|
||||
if (singletonTarget != null) {
|
||||
methods = singletonTarget.getClass().getDeclaredMethods();
|
||||
}
|
||||
} else if (AopUtils.isCglibProxy(bean)) {
|
||||
methods = bean.getClass().getSuperclass().getDeclaredMethods();
|
||||
} else {
|
||||
methods = bean.getClass().getDeclaredMethods();
|
||||
}
|
||||
if (methods != null) {
|
||||
for (Method method : methods) {
|
||||
if (method.isAnnotationPresent(ListenTo.class)) {
|
||||
ListenTo listenTo = method.getAnnotation(ListenTo.class);
|
||||
|
@ -79,6 +93,7 @@ public class EventManager implements ApplicationContextAware, BeanNameAware, Ini
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ResultContainer> processCommand(Command command, Object... args) {
|
||||
List<MethodContainer> containers = listenerMethods.getOrDefault(command.getCommandName(), Collections.emptyList());
|
||||
|
|
Loading…
Reference in New Issue