Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jersey-dev] Jersey within Existing Jetty Servlet Filter

Hi all,

Greetings from the Apache Solr community! [1]  We're a large
Jetty-based open source project, and have some interest in adopting
Jersey.  Had a quick "usage" question to run by you guys.

(Btw, sorry if this is the wrong place; please let me know if there's
a separate list or forum for "usage"-type questions that I should use
instead. "jersey-dev" was the only mailing list mentioned on the
project site. [2])

We'd like to start moving our API code over to Jersey a few APIs at a
time.  But, for historical reasons that are hard to reverse, our code
runs almost entirely within a single Jetty servlet filter
("SolrDispatchFIlter").  This filter has all sorts of auth, tracing,
etc. logic mixed in with the "actual" API invocation, which makes it
hard to send some subset of APIs to a different Jersey servlet (which
I gather is the "standard" way of running Jersey.) [2]

So instead I've been looking for a way to instantiate and use Jersey
from within our existing servlet-filter.  Are there any patterns for
doing this?

My initial (wrongheaded) attempt here involved using
"jersey-container-jetty-http" to instantiate a "Server" to send
requests to, but (1) I don't want or need a full-blown Server since
I'm already running within Jetty, and (2) I couldn't figure out how to
convert the HttpServletRequest I receive from Jetty into the 'Request'
object needed by server.handle()

Instantiating a "ApplicationHandler" looks a bit more promising since
(I think) it sheds a lot of the extra functionality in the Server
class, but I still have trouble figuring out how to call into
AppHandler (or other Jersey code) with the HttpServletRequest and
HttpServletResponse that Jetty gives me to work with.

Thanks in advance for any advice or pointers!

Best,

Jason

[1] https://solr.apache.org/
[2] https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/deployment.html#deployment.servlet


Back to the top