-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple Spring DI support #563
Conversation
c4426de
to
2119ada
Compare
I can't see the logs of CI process unfortunately. |
private static final DotName VALUE_ANNOTATION | ||
= DotName.createSimple("org.springframework.beans.factory.annotation.Value"); | ||
|
||
private static final DotName CDI_SINGLETON_ANNOTATION = DotName.createSimple(Singleton.class.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use org.jboss.protean.arc.processor.ScopeInfo#getDotName()
and org.jboss.protean.arc.processor.DotNames.INJECT
and friends instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I can see this:
|
Very helpful, thanks! |
@mkouba Would be so kind as to paste the logs of the failed test? Thanks a lot and sorry for the inconvenience! |
@geoand No problem. The log should be visible here: https://dev.azure.com/protean-ci/Shamrock/_build/results?buildId=1267 (click on "1 errors / 0 warnings" link in the azure check detail)
|
Thanks! |
@@ -39,7 +39,7 @@ | |||
|
|||
static InjectionPointInfo fromField(FieldInfo field, BeanDeployment beanDeployment) { | |||
Set<AnnotationInstance> qualifiers = new HashSet<>(); | |||
for (AnnotationInstance annotation : field.annotations()) { | |||
for (AnnotationInstance annotation : beanDeployment.getAnnotations(field)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should update fromMethod()
as well, in order to support setter/constructor injection. I'd guess it is also supported by Spring DI, or?
In fact, AnnotationsTransformer
method params support is not that good. We should improve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken AnnotationTransformer
doesn't currently support method parameters at all. Would you like me to address that with this PR?
And to answer you other question, yes Spring DI does allow annotations like (@Qualifier
) on method params (and obviously this PR doesn't handle them)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the transformation of annotations method params should be disabled and only enabled by a config property than extension would set?
If you think we should have method param annotation handling, I will gladly add it with PR and update the Spring processor to handle such annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I played around a little more with this and it turned out that adding support for method param qualifiers was fairly easy - so it was added in my latest commit
54e5317
to
8043c76
Compare
Support is provided my mapping Spring DI annotations to their CDI counterparts leveraging the annotation transformation mechanism that Arc provides
8043c76
to
b842d28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extension should also be added to the bom, to make it easier for end users to consumer. Other than these issues I think it looks good, but I would like @mkouba to have the final say.
integration-tests/spring-di/pom.xml
Outdated
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>5.1.4.RELEASE</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be managed in the build parent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
private String determineName(AnnotationValue annotationValue) { | ||
final String className = annotationValue.getClass().getName(); | ||
if (className.contains("ArrayValue")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use AnnotationValue.kind()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Should I perhaps create an issue for this and link it to this PR? |
Support is provided my mapping Spring DI annotations to their CDI
counterparts leveraging the annotation transformation mechanism that
Arc provides