aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-03 12:47:29 +0300
committerGravatar Vitaly Takmazov2018-04-03 12:47:29 +0300
commitd2af7ac0bbdde07e0f0f8b68c56f370ed3c06fe6 (patch)
tree9a8673c44f97e98b60b48c0c956b87ddc835e90b /juick-www/src/main/java/com
parented3af3b4a2722d352f5e9cfaf54fb44fa6af8295 (diff)
boot: reuse single xmpp connection when possible
Diffstat (limited to 'juick-www/src/main/java/com')
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/EmbeddedXMPPConfig.java11
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/XMPPConfiguration.java2
2 files changed, 13 insertions, 0 deletions
diff --git a/juick-www/src/main/java/com/juick/www/configuration/EmbeddedXMPPConfig.java b/juick-www/src/main/java/com/juick/www/configuration/EmbeddedXMPPConfig.java
index 35377dcd..a54b76a1 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/EmbeddedXMPPConfig.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/EmbeddedXMPPConfig.java
@@ -1,11 +1,22 @@
package com.juick.www.configuration;
+import com.juick.server.XMPPConnection;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
+import rocks.xmpp.extensions.component.accept.ExternalComponent;
+
+import javax.inject.Inject;
@Configuration
@ConditionalOnClass(name = "com.juick.server.xmpp.router.XMPPRouter")
@ComponentScan(basePackages = "com.juick.server")
public class EmbeddedXMPPConfig {
+ @Inject
+ private XMPPConnection xmppConnection;
+ @Bean
+ public ExternalComponent xmpp() {
+ return xmppConnection.getRouter();
+ }
}
diff --git a/juick-www/src/main/java/com/juick/www/configuration/XMPPConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/XMPPConfiguration.java
index 0fc86e2a..c8efc9e9 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/XMPPConfiguration.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/XMPPConfiguration.java
@@ -4,6 +4,7 @@ import com.juick.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import rocks.xmpp.core.XmppException;
@@ -26,6 +27,7 @@ public class XMPPConfiguration {
@Value("${xmpp_disabled:false}")
private boolean isXmppDisabled;
@Bean
+ @ConditionalOnMissingBean(type = "rocks.xmpp.extensions.component.accept.ExternalComponent")
public ExternalComponent xmpp() {
XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
.extensions(Extension.of(Message.class))