jsr356-experts@websocket-spec.java.net

[jsr356-experts] connectToServer

From: Danny Coward <danny.coward_at_oracle.com>
Date: Wed, 27 Feb 2013 16:47:39 -0800

My apologies to Scott to have left it so late to respond to this change.
In part I was waiting until we had cleaned up the
*Configuration/Configurator API, which I think we have now, as of v013.
Here is today's API:-

WebSocketContainer {
   Session connectToServer(Class<?> annotatedEndpointClass, URI path)
throws DeploymentException, IOException;
   Session connectToServer(Class<? extends Endpoint> endpointClass,
ClientEndpointConfiguration cec, URI path) throws DeploymentException,
IOException;
}

I think since this came up, we have embraced the CDI instantiation when
this API is in a Java EE container. This obviously brings the benefits
of being able to inject EJBs and CDI managed beans into websocket
endpoints, the bread and butter for Java EE developers, and which forces
a model where the implementation is doing the instantiation.

We have also added the concept of allowing Configurators to control
endpoint instance creation on the server side.

So if we still feel this is a relevant use case, my thought is we could
add the analogous factory method to the ClientEndpointConfigurator.

Or we could simply add the deploy by endpoint instance methods Scott has
proposed. (we still need the deploy by class/config for the EE folks).

What is the group feeling ?

- Danny







On 1/14/13 8:32 AM, Scott Ferguson wrote:
> The new connectToServer is difficult to use.
>
> Instead of a Class parameter, it should be an object. The container
> shouldn't need to instantiate the object, and the Class model makes it
> difficult to connect between the client application and the client
> endpoint. (Because any shared state/object needs to be passed through
> a custom ClientEndpointConfiguration.)
>
> The API should be simplified to:
>
> WebSocketContainer {
> Session connectToServer(Object endpoint, URI path);
>
> Session connectToServer(Object endpoint, URI path,
> ClientEndpointConfiguration cec);
> }
>
> If the "endpoint" object is already of type Endpoint, it's used
> directly. Otherwise, a skeleton/proxy is created, i.e. annotation stuff.
>
> There's no need for separate methods for Endpoint vs annotation.
>
> -- Scott
>


-- 
<http://www.oracle.com> 	*Danny Coward *
Java EE
Oracle Corporation