aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/ws/configuration
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-28 16:47:52 +0300
committerGravatar Vitaly Takmazov2016-06-28 16:47:52 +0300
commite8621033c919f0920a52463c01293349752aedec (patch)
treed492f8c2837efdad6978f317227e701649b928e1 /src/main/java/com/juick/ws/configuration
parent0f907b3973e851970882a00da123f6b7a6a359fb (diff)
destroy xmpp service
Diffstat (limited to 'src/main/java/com/juick/ws/configuration')
-rw-r--r--src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java b/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java
index 63ff12cb..27bfcf36 100644
--- a/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java
+++ b/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java
@@ -2,6 +2,7 @@ package com.juick.ws.configuration;
import com.juick.ws.WebsocketComponent;
import com.juick.ws.XMPPConnection;
+import org.springframework.beans.factory.DisposableBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -17,6 +18,8 @@ import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import javax.inject.Inject;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
/**
* Created by vitalyster on 28.06.2016.
@@ -41,8 +44,25 @@ public class WebsocketConfiguration extends WebMvcConfigurerAdapter implements W
dataSource.setUrl(env.getProperty("datasource_url"));
return new JdbcTemplate(dataSource);
}
+ @Bean
+ ExecutorService xmppThreadService() {
+ return Executors.newSingleThreadExecutor();
+ }
+ @Bean
+ DestroyBean destroyBean() {
+ return new DestroyBean();
+ }
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(wsHandler(), "/**");
}
+ class DestroyBean implements DisposableBean {
+
+ @Inject
+ ExecutorService xmppThreadService;
+ @Override
+ public void destroy() throws Exception {
+ xmppThreadService.shutdownNow();
+ }
+ }
}