Feign: Add Support for @BeanParam to feign-jaxrs

Created on 8 Oct 2015  Â·  15Comments  Â·  Source: OpenFeign/feign

@BeanParam is useful for taking a request like client().objects().list(0, 10, "My Objects", null) and allowing for a more fluent client like client().objects().list(new ListRequest().query("My Objects")).

documentation help wanted needs info

Most helpful comment

Keeping feign light is great thing to permanently strive for. That said, as a heavy user of JAX-RS(100s of resources), adding support for @BeanParam will put Feign in a place where 90-95% of use cases are satisfied.

+1 for core support of @BeanParam

All 15 comments

Sounds a little fancy for core. Want to start with a custom encoder to see
how it ends up looking? Ex. I see this as a filter before the real encoder.
Ex new BeansEncoder(new GsonEncoder())

Interesting, I will see if I can replace the transform bit with an encoder.

234 was illuminating. Perhaps an wiki page on extension considerations and design decisions would be helpful?

Encoder will not work as far as I can tell. It doesn't come into play at all if you are only using query parameters and even then, I am not sure how it would provide additional template substitutions. The next possible option is a custom InvocationHandlerFactory. However, this will mean that you cannot simply use the JAXB contract, but instead will also need to install the custom factory to get access to "extended" JAXB support, which seems a bit clunky from an API standpoint.

I feel strongly that contracts should be more extensible / decoratable and afforded additional control over template value resolution. Even if we can't get some sort of transform or template resolver, it would be advantageous for "extensions" to be able to stash information in the contract for use by encoders or invocation handlers.

To set expectations, feign-core will not include all features we can
envision, and the least likely to be included are reflective or otherwise
magical ones.

The surface area of maintenance is extremely important to the health of
those use feign, if nothing else by allowing me to easily maintain bugs in
features and release fixes to code other people added.

Projects like spring-cloud-netflix are free to augment feign to support
different contracts. Feign-core has highly reused components, and even some
of these may need to be sunsetted.

In other words, if you can't get your needs met without using
spring-cloud-netflix or an invocation handler, that doesn't mean core needs
to change. That only means you have 50 more lines in your source code which
then don't affect other users. If someone else encounters this issue (which
was logged years after feign started), they might say "me too!" Maybe there
would be a time where beans gets added to core, but that isn't today.

I would like to help you though, as particularly I fear you may not have
seen all the ways this could work. Rather than discussing with words, can
you create a failing test of what you'd expect Beans to do? When you said
this only works with query params it made me consider you may be missing
something. Let me help!

When you speak of "core", do you mean the project as a whole or feign-core?

It sounds like you are pushing for a completely separate project. Which is
fine, feel free to close this feature request.

spring-cloud-netflix is not an option for us.

I'll write more tests and attach them here shortly.

On Thu, Oct 8, 2015 at 7:17 PM Adrian Cole [email protected] wrote:

To set expectations, feign-core will not include all features we can
envision, and the least likely to be included are reflective or otherwise
magical ones.

The surface area of maintenance is extremely important to the health of
those use feign, if nothing else by allowing me to easily maintain bugs in
features and release fixes to code other people added.

Projects like spring-cloud-netflix are free to augment feign to support
different contracts. Feign-core has highly reused components, and even some
of these may need to be sunsetted.

In other words, if you can't get your needs met without using
spring-cloud-netflix or an invocation handler, that doesn't mean core needs
to change. That only means you have 50 more lines in your source code which
then don't affect other users. If someone else encounters this issue (which
was logged years after feign started), they might say "me too!" Maybe there
would be a time where beans gets added to core, but that isn't today.

I would like to help you though, as particularly I fear you may not have
seen all the ways this could work. Rather than discussing with words, can
you create a failing test of what you'd expect Beans to do? When you said
this only works with query params it made me consider you may be missing
something. Let me help!

—
Reply to this email directly or view it on GitHub
https://github.com/Netflix/feign/issues/278#issuecomment-146730320.

I mean that the integrations in this repo are highly reused and there are
other features of high interest I prefer we do before adding ones only
requested once.

By adding your test here I might be able to help simplify how to achieve
your goal, even it that means changes to feign core. That's why I'd like to
see them.

I have shared a very basic implementation at Qualys/feign-jaxrs

Nice work! and thanks for sharing

Keeping feign light is great thing to permanently strive for. That said, as a heavy user of JAX-RS(100s of resources), adding support for @BeanParam will put Feign in a place where 90-95% of use cases are satisfied.

+1 for core support of @BeanParam

Folks can feel free to collaborate on Qualys/feign-jaxrs, and even release it! I'm personally stretched too thin right now to support merging this sort of thing in and maintaining it.

PS here's a pull request adding a HACKING file, which explains where I'm coming from (even if it isn't a universally popular POV). I'd rather facilitate this vs add it to the main (monolithic) repo at the moment.

342

Additional discussion about supporting @BeanParam here: https://github.com/OpenFeign/feign/pull/567

Looking over https://github.com/Qualys/feign-jaxrs, it looks like a good option for those looking for this support. If you like, I can see if there is a way we can start maintaining a list of these projects here so those who come to Feign looking for this type of stuff and find them. Thoughts?

Was this page helpful?
0 / 5 - 0 ratings