private void registerWebSockets ( Injector injector ) { Map < Key < ? > , Binding < ? > > allBindings = injector . getAllBindings ( ) ; // loop all the Guice bindings looking for @ServerEndpoint singletons for ( Map . Entry < Key < ? > , Binding < ? > > entry : allBindings . entrySet ( ) ) { final Binding < ? > binding = entry . getValue ( ) ; binding . acceptScopingVisitor ( new DefaultBindingScopingVisitor ( ) { @ Override public Object visitEagerSingleton ( ) { // also a eager singleton so register it registerWebSocketEndpoint ( binding ) ; return null ; } } ) ; } }
Find any Guice eager singletons that are WebSocket endpoints and register them with the servlet container .