protected void registerWebSocketEndpoint ( Binding < ? > binding ) { //}, ServerEndpoint serverEndpoint) { Object instance = binding . getProvider ( ) . get ( ) ; Class < ? > instanceClass = instance . getClass ( ) ; ServerEndpoint serverEndpoint = instanceClass . getAnnotation ( ServerEndpoint . class ) ; if ( serverEndpoint != null ) { try { // register with the servlet container such that the Guice created singleton instance // is the instance that is used (and not an instance created per request etc) log . debug ( "registering ServerEndpoint [{}] with servlet container" , instanceClass ) ; BasicWebSocketConfigurator configurator = new BasicWebSocketConfigurator ( instance ) ; serverContainer . addEndpoint ( new BasicWebSocketEndpointConfig ( instanceClass , serverEndpoint , configurator ) ) ; } catch ( Exception e ) { log . error ( "Error registering WebSocket Singleton " + instance + " with the servlet container" , e ) ; } } }
Check if the binding is a WebSocket endpoint . If it is then register the webSocket server endpoint with the servlet container .