DATACMNS-1158 - ProjectionFactory is now configurable by module implementations.
Introduced RepositoryFactorySupport.getProjectionFactory(…) to create a ProjectionFactory to be used for repository instances created. The default implementation uses the SpelAwareProxyProjectionFactory. The ProjectionInformation implementation is now a named class so it can be used for more specialized implementations. Original pull request: #243. Related issue: DATAJPA-1173.
This commit is contained in:
committed by
Oliver Gierke
parent
0237760345
commit
300f3cfd66
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
* @since 1.10
|
||||
*/
|
||||
public class SpelAwareProxyProjectionFactory extends ProxyProjectionFactory implements BeanFactoryAware {
|
||||
@@ -63,29 +64,7 @@ public class SpelAwareProxyProjectionFactory extends ProxyProjectionFactory impl
|
||||
*/
|
||||
@Override
|
||||
protected ProjectionInformation createProjectionInformation(Class<?> projectionType) {
|
||||
|
||||
return new DefaultProjectionInformation(projectionType) {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.projection.DefaultProjectionInformation#isInputProperty(java.beans.PropertyDescriptor)
|
||||
*/
|
||||
@Override
|
||||
protected boolean isInputProperty(PropertyDescriptor descriptor) {
|
||||
|
||||
if (!super.isInputProperty(descriptor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Method readMethod = descriptor.getReadMethod();
|
||||
|
||||
if (readMethod == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return AnnotationUtils.findAnnotation(readMethod, Value.class) == null;
|
||||
}
|
||||
};
|
||||
return new SpelAwareProjectionInformation(projectionType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,4 +100,31 @@ public class SpelAwareProxyProjectionFactory extends ProxyProjectionFactory impl
|
||||
|
||||
return callback.hasFoundAnnotation();
|
||||
}
|
||||
|
||||
protected static class SpelAwareProjectionInformation extends DefaultProjectionInformation {
|
||||
|
||||
protected SpelAwareProjectionInformation(Class<?> projectionType) {
|
||||
super(projectionType);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.projection.DefaultProjectionInformation#isInputProperty(java.beans.PropertyDescriptor)
|
||||
*/
|
||||
@Override
|
||||
protected boolean isInputProperty(PropertyDescriptor descriptor) {
|
||||
|
||||
if (!super.isInputProperty(descriptor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Method readMethod = descriptor.getReadMethod();
|
||||
|
||||
if (readMethod == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return AnnotationUtils.findAnnotation(readMethod, Value.class) == null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user