JAX-RS implementation
mikesir87 opened this issue · 4 comments
I see that there's a Jersey2 implementation, but it would be nice to have an implementation that does not have a dependency directly on Jersey, but only the javax.ws.rs-api
artifact. (Use case - building a Java-EE application that's sticking to the API spec, not implementations)
I'd be happy to help contribute a PR, but wanted to see if there was anything I needed to know first. In addition, should the Jersey2 module be refactored to build on this, as I assume this would have the @Provider
-based ExceptionHandler
.
That's a great idea, and we'd love to have you contribute a PR. Sounds like you'd need to create a new backstopper-jaxrs
(or some other appropriate name) module that would mostly be a copy/paste of the Jersey2 module, minus the Jersey specific bits.
Whether the Jersey2 module builds on it or not depends on the fallout of what you discover when you build it, but ideally it would just pull in the new module as a dependency and add a few small Jersey2-specific things.
My thoughts based on a quick look:
Jersey2ApiExceptionHandler
andJersey2UnhandledExceptionHandler
are already Jersey-dependency-free (I think) and should work as-is with just thejavax.ws.rs-api
artifact. So you could copy/paste that to the new module and rename it appropriately.- We wouldn't want to break backwards compatibility by removing the Jersey2 classes entirely, but hopefully the Jersey2 versions could simply become bare extensions of the new module's classes with nothing extra inside.
Jersey2WebApplicationExceptionHandlerListener
does have a few Jersey dependency references in it (I think just theParamException
bits?), but the rest should be reusable for the new module.- Ideally the Jersey2 version would then just become an extension of the new module's class, overriding
shouldHandleException
to account for the Jersey2 specific use cases and delegating to thesuper
method for everything else.
- Ideally the Jersey2 version would then just become an extension of the new module's class, overriding
- I have no idea if anything in
Jersey2BackstopperConfigHelper
is relevant to a non-Jersey2 environment. I'll leave that for you to decide.
The sample-jersey2
sample module has some comprehensive component/functional style tests, so ultimately as long as the sample-jersey2
builds and the tests pass you can feel confident that your refactoring hasn't broken anything.
Let me know if I can help in any way!
Alrighty! PR incoming... thanks for the pointers and for the help. And yes... the test cases were a great help!
@mikesir87 - version 0.11.0 has been released and should contain your new module. Thank you for the contribution!
Excellent! I'll start integrating it once I finish up a few other tasks. Will let you know if I run into anything else/have any suggestions. Thanks for making it easy!