+1
On Tue, Feb 26, 2013 at 1:58 PM, Danny Coward <danny.coward_at_oracle.com>wrote:
> OK glad Joe likes it.
>
>
> Specifically, add to ServerEndpointConfigurator
>
> /** (something like) This method is called by the container when it
> needs a new
> ** instance of the endpoint this configurator configures. Developers
> ** may override this method to control instantiation of
> ** endpoint instances in order to customize the initialization
> ** of the endpoint instance, or manage them in some other way.
> ** If the developer overrides this method, services like
> ** dependency injection that are otherwise supported
> ** may not be available.
> */
> public Object createEndpoint() throws InstantiationException;
>
> Works equally well for programmatic endpoints and annotated endpoints,
> and fits with the existing configuration scheme.
>
>
> The name createEndpoint() suggests a new object is created every time.
> Maybe change it?
>
> I'd like to see something along the following lines in the Javadoc:
>
> The default implementation will return a new object on every call. Other
> implementations may return the same object for multiple calls or have some
> other strategy for determing if object a reused or a new object created.
>
> That's a good point and we will need to put in something like this. But I
> think in addition we need to cover *when* the container calls the method
> (whether the implementation is developer provided or container provided) in
> addition to what the default implementation returns when it is called.
>
> I'm thinking the we should define that the container calls this method for
> every new client connection and the default implementation of the method
> provided by the container returns a new instance each time it is called.
> Those folks wanting a singleton model would return the same, single
> instance each time.
>
> That would cover both the modes we have ever talked about in the expert
> group.
>
> The only other possible deployment mode I can think of is one where a new
> instance of the endpoint is created every time a new event or message is
> received (from any client). A sort of stateless websocket. This would
> require the container to call the factory method on any event on any
> connection to the logical endpoint.
>
> However, I don't think that deployment mode is useful for websocket
> endpoints: the websocket endpoint has a defined lifecycle per client, any
> endpoint of interest will have some state across its lifecycle. Asking
> developers to manage that state across a new instance per interaction
> doesn't seem like a good model for websocket programming.
>
> So: I;d propose: the container calls it on every new client connection,
> the default implementation creates a new instance each time.
>
> OK ?
>
> - Danny
>
>
>
> Mark
>
>
>
> --
> <http://www.oracle.com> * Danny Coward *
> Java EE
> Oracle Corporation
>