Deploying WebSocket annotated & programmatic server endpoints together

One of my previous blog post discussed Programmatic WebSocket endpoints and their deployment methodology using the javax.server.ServerApplicationConfig class.

When annotated and programmatic endpoints co-exist…

you have to make use of the a custom implementation of ServerApplicationConfig and explicitly return set of all annotated endpoints from the getAnnotatedEndpointClasses method

Please note that: using this method, you can choose to restrict the endpoints (annotated and programmatic) being deployed i.e. not all the detected endpoints need to be (will be) deployed

This is how it works..

If the WebSocket container finds subclass of ServerApplicationConfig, it uses the same to deploy both programmatic and annotated endpoints. The result of the WAR scanning process (by the Servlet container) is passed on the methods of this class

  • For getEndpointConfigs, the set (java.util.Set) of detected programmatic endpoints are passed as the method parameter
  • For getAnnotatedEndpointClasses method, the set (java.util.Set) of detected annotated endpoints are passed as the method parameter

Summary of deployment scenarios

Annotated Endpoint Programmatic Endpoint Behavior
Yes No Automatic detection of annotated endpoint. No custom code needed
No Yes Custom implementation of ServerApplicationConfig is compulsory. Programmatic endpoints are not auto-detected and deployed
Yes Yes Custom implementation of ServerApplicationConfig is compulsory. Need to explicitly return set of all annotated endpoints from the `getAnnotatedEndpointClasses` method

Cheers!

About Abhishek

Currently working as a Senior Product Manager in the Oracle Cloud Application Development team with a focus on Oracle Cloud PaaS portfolio. When not hovering in the clouds, I stay grounded with Java EE
This entry was posted in Java EE and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s