users@jersey.java.net

Re: [Jersey] Thread access to _at_Context objects?

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Sun, 1 Nov 2009 23:12:31 -0800

On Sun, Nov 1, 2009 at 10:00 PM, Chris Hubick <chris_at_hubick.com> wrote:
...
> In my opinion, having code and data structures utilizing a broadly
> understood and standard API is preferable to a custom API from a
> maintenance perspective.  Adding synchronization in the places it's

Yes, if that API supports such use case. JAX-RS as well as Servlet API
is quite explicitly defined as thread-per-request model. Any
extensions that will utilize additional threads will have to deal with
additional requirements. Not implementations of APIs that are
explicitly not designed to cover such use cases.

> needed, although ugly, also generally results in less code overall than
> writing custom data structures.  More importantly, I can't "pull out"
> access to things like SecurityContext.isUserInRole(String).
>
> One of my major draws to Java was it's thread-safe library, it makes me
> sad to see this design tenet fall ever further to the wayside.

I am not sure I see your point. To me it sounds like you are asking
support for a non-supported use case. For supported use cases,
additional synchronization would be additional overhead without any
benefits; both regarding runtime overhead, and more importantly,
making implementation itself more complicated and more work to
maintain (in addition to initial implementation).
While that would be possible, the question really is: why bother?

-+ Tatu +-