Skip to content
This repository has been archived by the owner on Jul 19, 2020. It is now read-only.

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

Closed
mscharhag opened this issue May 26, 2018 · 3 comments
Closed

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

mscharhag opened this issue May 26, 2018 · 3 comments
Assignees
Milestone

Comments

@mscharhag
Copy link

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

chkal commented May 28, 2018

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 chkal self-assigned this May 28, 2018
@chkal chkal added this to the 1.0-pfd milestone Jul 8, 2018
@chkal
Copy link
Contributor

chkal commented Aug 26, 2018

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.

@chkal
Copy link
Contributor

chkal commented Jul 19, 2020

Moved to jakartaee/mvc#35

@chkal chkal closed this as completed Jul 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants