From ca079dd0d12fa85ca2d56b04f75f654f2bf242b5 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Sat, 24 Dec 2016 16:04:13 -0500 Subject: [PATCH] IdempotentReceiverAutoProxyCreatorInit refinement No reason to load class one more time if `MethodMetadata` is already `StandardMethodMetadata` See https://jira.spring.io/browse/SPR-14505 **Cherry-pick to 4.3.x** (cherry picked from commit 1e46fb8) --- ...ntReceiverAutoProxyCreatorInitializer.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreatorInitializer.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreatorInitializer.java index 207e132c58..ec173def7c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreatorInitializer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreatorInitializer.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.support.ManagedMap; import org.springframework.core.type.MethodMetadata; +import org.springframework.core.type.StandardMethodMetadata; import org.springframework.integration.annotation.IdempotentReceiver; import org.springframework.integration.handler.advice.IdempotentReceiverInterceptor; import org.springframework.messaging.MessageHandler; @@ -81,17 +82,24 @@ public class IdempotentReceiverAutoProxyCreatorInitializer implements Integratio if (beanMethod.isAnnotated(annotationType)) { Object value = beanMethod.getAnnotationAttributes(annotationType).get("value"); if (value != null) { - String[] interceptors = (String[]) value; - String endpoint = beanName; + Class returnType; - try { - returnType = ClassUtils.forName(beanMethod.getReturnTypeName(), - beanFactory.getBeanClassLoader()); + if (beanMethod instanceof StandardMethodMetadata) { + returnType = ((StandardMethodMetadata) beanMethod).getIntrospectedMethod() + .getReturnType(); } - catch (ClassNotFoundException e) { - throw new CannotLoadBeanClassException(beanDefinition.getDescription(), - beanName, beanMethod.getReturnTypeName(), e); + else { + try { + returnType = ClassUtils.forName(beanMethod.getReturnTypeName(), + beanFactory.getBeanClassLoader()); + } + catch (ClassNotFoundException e) { + throw new CannotLoadBeanClassException(beanDefinition.getDescription(), + beanName, beanMethod.getReturnTypeName(), e); + } } + + String endpoint = beanName; if (!MessageHandler.class.isAssignableFrom(returnType)) { /* MessageHandler beans, populated from @Bean methods, have a complex id, @@ -101,6 +109,8 @@ public class IdempotentReceiverAutoProxyCreatorInitializer implements Integratio endpoint = beanDefinition.getFactoryBeanName() + "." + beanName + ".*" + IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX; } + + String[] interceptors = (String[]) value; for (String interceptor : interceptors) { Map idempotentEndpoint = new ManagedMap(); idempotentEndpoint.put(interceptor, endpoint);