Java Reference
In-Depth Information
NOTE
Because you are using the Jersey-specific @Singleton annotation, there is only one instance of the
service for the entire container. That is not an intrinsic aspect of this example; I'm only doing it as a
convenience to save the added users in the map, instead of having to go to a database. If you didn't
use that annotation, the user instance data would not be saved across requests. Note that in general,
you want RESTful services to be stateless so that they scale (this service could be stateless if you
were actually going to a database), so don't get too used to the idea of this annotation. Plus, it's only
part of the reference implementation, and not the JAX-RS API, so your code here wouldn't be port-
able to something like RESTEasy.
Search WWH ::




Custom Search