From 9b5db8da41d5c4c5f50012c0055b4008191cdb8f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 16 Oct 2017 01:04:24 +0300 Subject: ws: fix xmpp initialization --- juick-ws/src/main/java/com/juick/ws/XMPPConnection.java | 2 ++ .../java/com/juick/ws/configuration/WebsocketConfiguration.java | 9 ++++++++- .../java/com/juick/ws/configuration/WebsocketInitializer.java | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'juick-ws/src') diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java index 84158445..d30f8f03 100644 --- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java +++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java @@ -26,6 +26,7 @@ import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import org.springframework.util.Assert; import org.springframework.web.socket.TextMessage; import rocks.xmpp.core.XmppException; @@ -50,6 +51,7 @@ import java.util.stream.Collectors; /** * @author ugnich */ +@Component public class XMPPConnection implements AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(XMPPConnection.class); diff --git a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java index d1a6296a..c99d7a6d 100644 --- a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java +++ b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java @@ -20,6 +20,7 @@ package com.juick.ws.configuration; import com.juick.server.configuration.BaseWebConfiguration; import com.juick.server.protocol.JuickProtocol; import com.juick.ws.WebsocketComponent; +import com.juick.ws.XMPPConnection; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -31,6 +32,9 @@ import org.springframework.web.socket.config.annotation.WebSocketConfigurer; import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean; +import javax.annotation.Resource; +import javax.inject.Inject; + /** * Created by aalexeev on 11/24/16. */ @@ -40,7 +44,10 @@ import org.springframework.web.socket.server.standard.ServletServerContainerFact @EnableWebSocket @PropertySource("classpath:juick.conf") class WebsocketConfiguration extends BaseWebConfiguration implements WebSocketConfigurer { - + @Bean + public XMPPConnection xmpp() { + return new XMPPConnection(); + } @Bean public WebsocketComponent wsHandler() { return new WebsocketComponent(); diff --git a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java index c79ea924..aca3cd47 100644 --- a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java +++ b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java @@ -30,12 +30,12 @@ public class WebsocketInitializer extends AbstractAnnotationConfigDispatcherServ @Override protected Class[] getRootConfigClasses() { - return new Class[]{ }; + return new Class[]{ WebsocketConfiguration.class }; } @Override protected Class[] getServletConfigClasses() { - return new Class[]{ WebsocketConfiguration.class }; + return null; } @Override -- cgit v1.2.3