From aac89d98210c86b406275f2d59e06259cf4bf460 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Tue, 21 Feb 2012 14:59:12 +0100 Subject: [PATCH] fixing incompatibility with Spring 3.1.1 --- .../provider/AutowireDependencyProvider.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/plugins/org.springframework.ide.eclipse.beans.core.autowire/src/org/springframework/ide/eclipse/beans/core/autowire/internal/provider/AutowireDependencyProvider.java b/plugins/org.springframework.ide.eclipse.beans.core.autowire/src/org/springframework/ide/eclipse/beans/core/autowire/internal/provider/AutowireDependencyProvider.java index 171f0408af..c96eeb232f 100644 --- a/plugins/org.springframework.ide.eclipse.beans.core.autowire/src/org/springframework/ide/eclipse/beans/core/autowire/internal/provider/AutowireDependencyProvider.java +++ b/plugins/org.springframework.ide.eclipse.beans.core.autowire/src/org/springframework/ide/eclipse/beans/core/autowire/internal/provider/AutowireDependencyProvider.java @@ -13,8 +13,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Member; import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -29,6 +27,7 @@ import javax.annotation.Resource; import javax.ejb.EJB; +import javax.inject.Provider; import org.eclipse.core.resources.IMarker; import org.eclipse.jdt.core.IJavaElement; @@ -52,7 +51,7 @@ import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.ParameterNameDiscoverer; -import org.springframework.core.convert.support.ConversionServiceFactory; +import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.ide.eclipse.beans.core.BeansCorePlugin; import org.springframework.ide.eclipse.beans.core.autowire.IAutowireDependencyResolver; import org.springframework.ide.eclipse.beans.core.autowire.internal.provider.InjectionMetadata.InjectedElement; @@ -361,7 +360,7 @@ private Set createInjectionMetadataProviders() { BeanDefinition beanDef = BeansModelUtils.getMergedBeanDefinition(bean, context); if (beanDef.getPropertyValues().size() > 0) { BeanWrapperImpl wrapper = new BeanWrapperImpl(true); - wrapper.setConversionService(ConversionServiceFactory.createDefaultConversionService()); + wrapper.setConversionService(new DefaultConversionService()); wrapper.setWrappedInstance(provider); for (PropertyValue pv : beanDef.getPropertyValues().getPropertyValueList()) { if (wrapper.isWritableProperty(pv.getName())) { @@ -384,7 +383,7 @@ private Set createInjectionMetadataProviders() { BeanDefinition beanDef = BeansModelUtils.getMergedBeanDefinition(bean, context); if (beanDef.getPropertyValues().size() > 0) { BeanWrapperImpl wrapper = new BeanWrapperImpl(true); - wrapper.setConversionService(ConversionServiceFactory.createDefaultConversionService()); + wrapper.setConversionService(new DefaultConversionService()); wrapper.setWrappedInstance(provider); for (PropertyValue pv : beanDef.getPropertyValues().getPropertyValueList()) { if (wrapper.isWritableProperty(pv.getName())) { @@ -595,16 +594,11 @@ protected boolean matchesBeanName(String beanName, String candidateName) { public void resolveDependency(DependencyDescriptor descriptor, Class type, String beanName, Set autowiredBeanNames, TypeConverter typeConverter) { descriptor.initParameterNameDiscovery(this.parameterNameDiscoverer); - if (descriptor.getDependencyType().equals(ObjectFactory.class)) { - type = Object.class; - Type fieldFile = descriptor.getGenericDependencyType(); - if (fieldFile instanceof ParameterizedType) { - Type arg = ((ParameterizedType) fieldFile).getActualTypeArguments()[0]; - if (arg instanceof Class) { - type = (Class) arg; - } - } + if (descriptor.getDependencyType().equals(ObjectFactory.class) || descriptor.getDependencyType().equals(Provider.class)) { + descriptor.increaseNestingLevel(); + type = descriptor.getDependencyType(); } + try { doResolveDependency(descriptor, type, beanName, autowiredBeanNames, typeConverter); }