What is this?

Traditionally JAX-WS has never taken advantage of object state, just like servlet. That is, the container creates only one instance of your service class, and then have it serve all the requests concurrently. This makes it impossible to set values to instance fields, as you'll experience concurrency problem as soon as multiple threads hit your service.

So all too often the service code starts to look more like C code, not Java code, and I didn't like this at all. Since I started helping the JAX-WS RI, I've been trying to fix this. Yesterday, I finally managed to write one.

On HTTP, session is often used to store state. This technique is still useful for web services over HTTP. JAX-WS lets you do this today, but as you can see in Rama's example, this is not pretty at all. Especially the server side, which I quote below for your reference:

The @HttpSessionScope annotation tells the JAX-WS RI to create one instance of Hello per each HTTP session. No need to mess with WebServiceContext, nor with HttpSession manually. It's all nicely typed and concise.

How it's implemented?

This extension is based on a publicly available extension point in the JAX-WS RI 2.1 called InstanceResolver. This provides a pluggability point where 3rd party could control how the JAX-WS RI dispatches incoming requests to service instances, and I only needed to write a little more code to implement this logic.

Then I define HttpSessionScope annotation with JAX-WS RI's meta annotation InstanceResolverAnnotation, to connect all those things together.