Issue Details (XML | Word | Printable)

Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: dannycoward
Reporter: dannycoward
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

Consider changing number of endpoint instances

Created: 17/Oct/12 07:25 PM   Updated: 10/Nov/12 12:05 AM  Due: 09/Nov/12   Resolved: 10/Nov/12 12:05 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Participants: dannycoward

 Description  « Hide

Currently the spec defines there is one endpoint instance per URI per VM. So the endpoint instance is application scoped.

Consider using one instance of an endpoint per client. This simplifies the threading model, but removes the ability of the developer to use the endpoint to share state that is common to multiple requests.

The developer needs to be able to hold application-wide state AND session state, so this is related to the issue of having a place to associate user data with the session.

The JAX-RS spec defines its endpoint instances to be request scoped by default, but this can be overridden so that they are application scoped to.

If we make the endpoint a CDI managed bean, then we can allow different modes.

dannycoward added a comment - 10/Nov/12 12:05 AM

I agree with Scott that this is a good change: to require a new instance of the Endpoint per session. It greatly simplifies the developer model in regard to having to deal with multiple threads. Ditto for the POJOs. So I propose we make this change in the next draft.

The consequences for this change are:-

1) we need to change the server publish method to take the endpoint class rather than one instance:
ServerContainer.publishServer(Endpoint e, ServerEndpointConfiguration sec) -> ServerContainer.publishServer(Class<? extends Endpoint>, ServerEndpointConfiguration sec)

2) client registration: no change - one client instance connects to one URL.

3) drop the Session parameter from Endpoint.onError, Endpoint.onClose as they are no longer necessary: the Endpoint instance gets the reference to its (single) Session instance just on the onOpen method.