DATACMNS-718 - Class loader improvements in ProxyProjectionFactory.

ProxyProjectionFactory now implements ResourceLoaderAware to be able to use the class loader used by the framework. SpringDataWebConfiguration now forwards the Application context as ResourceLoader through ProxyingHandlerMethodArgumentResolver into the target factory.
This commit is contained in:
Oliver Gierke
2015-06-19 13:05:56 +02:00
parent 26e398e553
commit c49f8357b6
3 changed files with 37 additions and 5 deletions

View File

@@ -19,8 +19,10 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebDataBinderFactory;
@@ -34,7 +36,8 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
* @author Oliver Gierke
* @since 1.10
*/
public class ProxyingHandlerMethodArgumentResolver extends ModelAttributeMethodProcessor implements BeanFactoryAware {
public class ProxyingHandlerMethodArgumentResolver extends ModelAttributeMethodProcessor
implements BeanFactoryAware, ResourceLoaderAware {
private final SpelAwareProxyProjectionFactory proxyFactory;
private final ConversionService conversionService;
@@ -61,6 +64,15 @@ public class ProxyingHandlerMethodArgumentResolver extends ModelAttributeMethodP
this.proxyFactory.setBeanFactory(beanFactory);
}
/*
* (non-Javadoc)
* @see org.springframework.context.ResourceLoaderAware#setResourceLoader(org.springframework.core.io.ResourceLoader)
*/
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
this.proxyFactory.setResourceLoader(resourceLoader);
}
/*
* (non-Javadoc)
* @see org.springframework.web.method.support.HandlerMethodArgumentResolver#supportsParameter(org.springframework.core.MethodParameter)

View File

@@ -97,6 +97,11 @@ public class SpringDataWebConfiguration extends WebMvcConfigurerAdapter {
argumentResolvers.add(sortResolver());
argumentResolvers.add(pageableResolver());
argumentResolvers.add(new ProxyingHandlerMethodArgumentResolver(conversionService.getObject()));
ProxyingHandlerMethodArgumentResolver resolver = new ProxyingHandlerMethodArgumentResolver(
conversionService.getObject());
resolver.setBeanFactory(context);
resolver.setResourceLoader(context);
argumentResolvers.add(resolver);
}
}