aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-11-01 17:03:16 +0300
committerGravatar Vitaly Takmazov2017-11-01 17:03:16 +0300
commitcb3069187881fff788dd1155c95d65b406494cf4 (patch)
tree4f2e5e350aad24e5403ae6ec4f990e645645d656 /juick-api/src/main/java/com/juick
parenta224f31fe050fe1eeb4435677caa27d523897704 (diff)
api: reload web context on ws reconnection
Diffstat (limited to 'juick-api/src/main/java/com/juick')
-rw-r--r--juick-api/src/main/java/com/juick/api/ApiServer.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/juick-api/src/main/java/com/juick/api/ApiServer.java b/juick-api/src/main/java/com/juick/api/ApiServer.java
index 110d8e2f..d7862952 100644
--- a/juick-api/src/main/java/com/juick/api/ApiServer.java
+++ b/juick-api/src/main/java/com/juick/api/ApiServer.java
@@ -24,6 +24,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ApplicationListener;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.socket.client.WebSocketConnectionManager;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import rocks.xmpp.addr.Jid;
@@ -38,6 +41,7 @@ import rocks.xmpp.extensions.oob.model.x.OobX;
import javax.annotation.Nonnull;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import javax.servlet.ServletContext;
import java.net.URI;
import java.net.URISyntaxException;
@@ -60,11 +64,7 @@ public class ApiServer implements ApplicationListener<DisconnectedEvent>, AutoCl
@Value("${xmpp_disabled:false}")
private boolean isXmppDisabled;
@Inject
- private WebSocketConnectionManager webSocketConnectionManager;
- @Inject
- private StandardWebSocketClient client;
- @Inject
- private DefaultListableBeanFactory beanFactory;
+ private ServletContext servletContext;
@PostConstruct
public void init() {
@@ -122,8 +122,8 @@ public class ApiServer implements ApplicationListener<DisconnectedEvent>, AutoCl
@Override
public void onApplicationEvent(@Nonnull DisconnectedEvent event) {
- logger.info("reconnecting websocket...");
- beanFactory.destroySingleton("client");
- beanFactory.destroySingleton("webSocketConnectionManager");
+ logger.info("reloading app...");
+ WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
+ ((AbstractApplicationContext) context).refresh();
}
}