jsr356-experts@websocket-spec.java.net

[jsr356-experts] Bootstrapping Web Socket Applications in different places

From: Danny Coward <danny.coward_at_oracle.com>
Date: Wed, 07 Nov 2012 17:59:06 -0800

Hello experts,

Close students of the EDR spec will see that this is how the application
is bootstrapped:-

A) In the web container, POJOs and programmatic endpoints are packaged
in the WAR
i) The implementation scans the WAR for annotated POJOs and deploys them
when the WAR is deployed
ii) For programmatic endpoints, the application developer has to
bootstrap the application 'by hand': by configuring an entry point (like
ServletContainerInitializer), and using the API
ContainerProvider.getServerContainer().publishServer(endpoint,
endpointconfiguration).

B) In the standalone cases: standalone server, and standalone client,
the developer has to bootstrap the application in main() using
ContainerProvider.getServerContainer() or
ContainerProvider.getClientContainer() to get the appropriate reference
to the web socket container, from which he can publishServer() or
connectToServer().

I'd propose a couple things to improve this, both as a convenience for
developers, and to unhook the API-implementation dependency implied by
the ContainerProvider API class:-

1) Require the websocket enabled web container scan for programmatic
endpoints in the WAR file and deploy them on startup. This would require
an API change to allow the Endpoint to supply its own Configuration
object: specifically add public EndpointConfiguration
getEndpointConfiguration() to Endpoint.
2) Remove the ContainerProvider API and use the Java SE standard
ServiceLoader mechanism instead:
http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html

As usual I'd welcome your thoughts and suggestions on this approach.

Cheers,

- Danny


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