-
Notifications
You must be signed in to change notification settings - Fork 210
Add tests for transformer features and support Transformer in native mode #7865
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
Conversation
b8e717d to
7d65a0a
Compare
| // Register transformer classes for reflection so they can be instantiated at runtime | ||
| transformerClasses.forEach(className -> reflectiveClass.produce( | ||
| ReflectiveClassBuildItem.builder(className) | ||
| .methods() |
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.
Nitpick - if Camel does not need reflective access to any methods on the transformer classes, then you can remove .methods(). It may be enough to only enable constructor reflection (enabled by default with ReflectiveClassBuildItem).
| BuildProducer<ReflectiveClassBuildItem> reflectiveClass) { | ||
|
|
||
| IndexView view = combinedIndex.getIndex(); | ||
| DotName dataTypeTransformer = DotName.createSimple("org.apache.camel.spi.DataTypeTransformer"); |
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.
Wonder if instead of searching for @DataTypeTransformer, maybe we just find all subclasses of org.apache.camel.spi.Transformer? That way users would not need to tag any custom classes with @RegisterForReflection.
|
|
||
| Set<String> transformerClasses = view.getAnnotations(dataTypeTransformer) | ||
| .stream() | ||
| .filter(ai -> ai.target().kind() == AnnotationTarget.Kind.CLASS) |
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 also filter transformer classes that are part of the Camel core + components. They get loaded automatically from the META-INF/services files.
7d65a0a to
f7fd82a
Compare
|
Overall it looks good to me.
I think we should in this case, since this change is specific to native support. There's no point in having the build step run for non-native. |
f7fd82a to
bafec5d
Compare
5fcc0d2 to
a9cd7d9
Compare
Closes #5478
Improve test coverage for
transformerfeatures:Add support in native mode with discovery of subclasses of org.apache.camel.spi.Transformer .
Note: I am not sure if I should move the registration code for reflection in
CamelNativeImageProcessoror use something like@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class). Not sure what the best practice is in this case so I kept it inCamel Processor, don't hesitate to comment review on this.