-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support specify serializer for 3rd classes #18
Conversation
@zhfeng Seems |
@chaokunyang Hmm, I don't understand here. What is the class not visisted? |
I congifured @FurySerialization(targetClass = ThirdPartyBar.class, serializer = ThridPartyBarSerializer.class)
public class ThirdPartyFooConfig {
} |
Maybe you can take a look at RegisterForReflection in Quarkus which is very similar with what you want to achive. |
It's not about the annotation itself, it's about how to make the class annotated by this annotation got identified by Quarkus |
deployment/src/main/java/io/quarkiverse/fury/deployment/FurySerializerBuildItem.java
Show resolved
Hide resolved
deployment/src/main/java/io/quarkiverse/fury/deployment/FuryProcessor.java
Outdated
Show resolved
Hide resolved
* Specify which classes the provided serialized is used for. | ||
* If not specified, the current annotated class is used. | ||
*/ | ||
Class<?> targetClass() default CurrentAnnotatedTypeStub.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.
Maybe better use
Class<?>[] targetClass() default {};
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.
Search on stackoverflow, https://stackoverflow.com/questions/24681223/annotation-default-null-value
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.
Updated to this in the new commit. Actually it was my earliest implementation, I thought it may introduce confusion with classId
since we can't configure multiple class id but we can configure multiple classes. I added a classId
check in the new commit. If multiple classes are specified, no class id are allowed in the annotation config
44378ae
to
8e551cd
Compare
deployment/src/main/java/io/quarkiverse/fury/deployment/FurySerializerBuildItem.java
Outdated
Show resolved
Hide resolved
int classed = annotation.classId(); | ||
Class<? extends Serializer> serializer = annotation.serializer(); | ||
if (classes.length > 1) { | ||
Preconditions.checkArgument(classed == -1, |
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 serializer
need to check as well since I suppose serializer
should only to a specfic target 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.
Not exactly, multiple classes can share same serializer. This is common, users may write a serializer for an abstract parent class, which can be used for all subclasses serialization
Support specify serializer for 3rd classes: