Skip to content
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

Is there a reason why @MvcBinding cannot be used at class level? #35

Open
chkal opened this issue Jul 19, 2020 · 2 comments
Open

Is there a reason why @MvcBinding cannot be used at class level? #35

chkal opened this issue Jul 19, 2020 · 2 comments

Comments

@chkal
Copy link
Contributor

chkal commented Jul 19, 2020

Issue by mscharhag
Saturday May 26, 2018 at 15:08 GMT
Originally opened as mvc-spec/mvc-spec#161


Hello,

I am wondering why @MvcBinding can only be used on fields, methods and parameters. (Probably because JAX-RS binding annotations can only be used on this types?)

Annotating all fields of a JAX-RS bean parameter with @MvcBinding looks way more common to me than annotating some fields and some not. Wouldn't it be convenient if a class could be annotated with @MvcBinding instead of annotating each field separately?

Maybe I am missing something here?

@chkal
Copy link
Contributor Author

chkal commented Jul 19, 2020

Comment by chkal
Monday May 28, 2018 at 16:00 GMT


Thanks a lot for bringing this up. I agree that using @MvcBinding on all fields of a @BeanParam class is a very common case. So allowing @MvcBinding on classes could be a good option.

However, you are correct that @MvcBinding is closely integrated with the JAX-RS binding mechanism, which (AFAIK) does not support binding metadata on the class level. But this could be something to bring up to the JAX-RS EG. Maybe some JAX-RS implementations even support it?

@mvc-spec/expert-group Any other thoughts on this?

@chkal
Copy link
Contributor Author

chkal commented Jul 19, 2020

Comment by chkal
Sunday Aug 26, 2018 at 09:10 GMT


Although I agree that allowing @MvcBinding on classes would be a great way to simplify creating classes used with @BeanParam, I currently don't see any way we can implement this in the RI. JAX-RS only provides annotations directly placed on method parameters and fields. So there seems to be no way for us to get annotations placed on classes in the @BeanParam case.

Therefore, I'll change the milestone to Future for now. We should bring up this topic to the JAX-RS EG. Maybe future JAX-RS versions could provide this information in a portable way. And if we find some other way to implement it in the RI, we can provide this functionality in the RI on top of what MVC 1.0 requires and make it a requirement it in a later version of the spec. I created mvc-spec/ozark#196 to track this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant