Provide implementation of BeanFactoryNativeConfigurationProcessor for function types#1351
Provide implementation of BeanFactoryNativeConfigurationProcessor for function types#1351sdeleuze merged 2 commits intospring-attic:mainfrom
Conversation
… function types Add initial implementation of FunctionTypeProcessor and FunctionTypeProcessorTests Modified samples to remove TypeHint as well as reference to it in the README Upgrade Spring Cloud dependency to 2021.0.0
| !name.startsWith("javax.")) { | ||
| if (added.add(name)) { | ||
| registry.reflection().forType(FunctionTypeUtils.getRawType(inputType)) | ||
| .withAccess(TypeAccess.DECLARED_CONSTRUCTORS, TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_FIELDS, TypeAccess.PUBLIC_FIELDS, TypeAccess.DECLARED_METHODS, TypeAccess.PUBLIC_METHODS); |
There was a problem hiding this comment.
Are TypeAccess.DECLARED_FIELDS and TypeAccess.PUBLIC_FIELDS really needed here?
There was a problem hiding this comment.
Probably not. It was mainly cut/paste from the 'alike' component, so i'll fix it
|
|
||
| private boolean isFunction(Class<?> beanType) { | ||
| return Function.class.isAssignableFrom(beanType) | ||
| || Consumer.class.isAssignableFrom(beanType); |
There was a problem hiding this comment.
Could we check via the presence of a bean type in beanFactory that Spring Cloud Function is enabled in this application?
There was a problem hiding this comment.
Well, the fact that I am using FunctionTypeUtils means s-c-function is on the classpath. We don't have any explicit enable functionality, hence my earlier question, how do these processors work when the "optional" dependency they are using is not available. So I am not sure what else i can add here
There was a problem hiding this comment.
Like discussed I am not sure how those processors do not break when for example here FunctionTypeUtils is not in the classpath, I think that's what I observed on other ones. Maybe @snicoll will know ?
There was a problem hiding this comment.
@olegz you got the Processor nested class pattern right, except you're not checking any condition so that makes it useless. See https://github.com/spring-projects-experimental/spring-native/blob/906925e9d4e0b5c13fe755b86d934dc7eb479aa8/spring-aot/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointNativeConfigurationProcessor.java#L49 for example.
Well, the fact that I am using FunctionTypeUtils means s-c-function is on the classpath.
Right now if you run this hint without Spring Cloud Function, it will fail with NCDFE.
There was a problem hiding this comment.
Yeah, sorry missed it. That is what I was asking Sebastien earlier about Conditional. Anyway, let me fix that
| @@ -0,0 +1 @@ | |||
|
|
|||
| org.springframework.core.IndexedBeanHierarchyNativeConfigurationProcessor,\ | ||
| org.springframework.context.annotation.ScopeNativeConfigurationProcessor | ||
| org.springframework.cloud.function.FunctionTypeProcessor |
Add initial implementation of FunctionTypeProcessor and FunctionTypeProcessorTests
Modified samples to remove TypeHint as well as reference to it in the README
Upgrade Spring Cloud dependency to 2021.0.0