Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Provide implementation of BeanFactoryNativeConfigurationProcessor for function types #1351

Merged
merged 2 commits into from
Dec 6, 2021

Conversation

olegz
Copy link
Contributor

@olegz olegz commented Dec 6, 2021

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

… 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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 6, 2021
!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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are TypeAccess.DECLARED_FIELDS and TypeAccess.PUBLIC_FIELDS really needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we check via the presence of a bean type in beanFactory that Spring Cloud Function is enabled in this application?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry missed it. That is what I was asking Sebastien earlier about Conditional. Anyway, let me fix that

@sdeleuze sdeleuze added this to the 0.11.0 milestone Dec 6, 2021
@sdeleuze sdeleuze added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 6, 2021
@@ -0,0 +1 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed right?

@sdeleuze sdeleuze merged commit e0bb555 into spring-attic:main Dec 6, 2021
@sdeleuze sdeleuze modified the milestone: 0.11.0 Dec 6, 2021
Comment on lines 32 to +34
org.springframework.core.IndexedBeanHierarchyNativeConfigurationProcessor,\
org.springframework.context.annotation.ScopeNativeConfigurationProcessor
org.springframework.cloud.function.FunctionTypeProcessor
Copy link
Contributor

@oclay1st oclay1st Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olegz, @sdeleuze I think there was a mistake after merging this PR, there is a missing comma after org.springframework.context.annotation.ScopeNativeConfigurationProcessor
I made a PR: #1363
Hope this helps!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement A general enhancement
Development

Successfully merging this pull request may close these issues.

5 participants