diff options
Diffstat (limited to 'juick-crosspost/src/main/java/com/juick/components')
2 files changed, 15 insertions, 16 deletions
diff --git a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostAppConfiguration.java b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostAppConfiguration.java index eae12e6c..76a909ad 100644 --- a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostAppConfiguration.java +++ b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostAppConfiguration.java @@ -17,6 +17,8 @@ package com.juick.components.configuration; +import com.juick.server.component.JuickServerComponent; +import com.juick.server.component.JuickServerReconnectManager; import com.juick.server.configuration.BaseWebConfiguration; import com.juick.service.Crosspost; import org.springframework.beans.factory.annotation.Value; @@ -29,8 +31,6 @@ import org.springframework.http.client.InterceptingClientHttpRequestFactory; import org.springframework.http.client.support.BasicAuthorizationInterceptor; import org.springframework.web.client.RestTemplate; import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.socket.client.WebSocketConnectionManager; -import org.springframework.web.socket.client.standard.StandardWebSocketClient; import java.util.Collections; import java.util.List; @@ -47,7 +47,14 @@ public class CrosspostAppConfiguration extends BaseWebConfiguration { private String apiUser; @Value("${api_password:secret}") private String apiSecret; - + @Bean + public JuickServerComponent juickServerComponent() { + return new JuickServerComponent(); + } + @Bean + public JuickServerReconnectManager juickServerReconnectManager() { + return new JuickServerReconnectManager(); + } @Bean public RestTemplate rest() { RestTemplate rest = new RestTemplate(); @@ -57,22 +64,10 @@ public class CrosspostAppConfiguration extends BaseWebConfiguration { rest.setRequestFactory(new InterceptingClientHttpRequestFactory(rest.getRequestFactory(), interceptors)); return rest; } - private static final String WS_URI = "wss://ws.juick.com/"; @Bean public Crosspost crosspost() { return new Crosspost(); } - @Bean - public WebSocketConnectionManager connectionManager() { - WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), crosspost(), WS_URI); - manager.setAutoStartup(true); - return manager; - } - - @Bean - public StandardWebSocketClient client() { - return new StandardWebSocketClient(); - } } diff --git a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java index 6a95c1f0..88280480 100644 --- a/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java +++ b/juick-crosspost/src/main/java/com/juick/components/configuration/CrosspostInitializer.java @@ -17,6 +17,7 @@ package com.juick.components.configuration; +import com.juick.server.configuration.JuickServerComponentConfiguration; import org.apache.commons.codec.CharEncoding; import org.springframework.web.filter.CharacterEncodingFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; @@ -30,7 +31,10 @@ public class CrosspostInitializer extends AbstractAnnotationConfigDispatcherServ @Override protected Class<?>[] getRootConfigClasses() { - return new Class<?>[]{ CrosspostAppConfiguration.class }; + return new Class<?>[]{ + CrosspostAppConfiguration.class, + JuickServerComponentConfiguration.class + }; } @Override |