java - how to configure websocket handle using class + spring 4.0.0 -


can 1 me please how configure web socket bean , handler using class base rather xml file.

<bean id="websocket" class="co.syntx.example.websocket.handler.websocketendpoint"/>  <websocket:handlers>     <websocket:mapping path="/websocket" handler="websocket"/>     <websocket:handshake-interceptors>     <bean class="co.syntx.example.websocket.handshakeinterceptor"/>     </websocket:handshake-interceptors> </websocket:handlers> 

thanks

do in websocketconfig.java

@configuration @enablewebsocket public class websocketconfig implements websocketconfigurer {       @override     public void registerwebsockethandlers(websockethandlerregistry registry) {         registry.addhandler(new websocketendpoint(), "/websocket")             .addinterceptors(new handshakeinterceptor());     } } 

in above code, new websocketendpoint() websocketendpoint.java websocket handler , new handshakeinterceptor() handshakeinterceptor.java interceptor.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -