aboutsummaryrefslogtreecommitdiff
path: root/juick-server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server')
-rw-r--r--juick-server/src/main/java/com/juick/server/ServerManager.java2
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java2
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPServer.java1
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Index.java12
-rw-r--r--juick-server/src/main/java/com/juick/server/configuration/XMPPConfig.java27
-rw-r--r--juick-server/src/main/java/com/juick/server/xmpp/XMPPStatusPage.java30
-rw-r--r--juick-server/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java1
7 files changed, 57 insertions, 18 deletions
diff --git a/juick-server/src/main/java/com/juick/server/ServerManager.java b/juick-server/src/main/java/com/juick/server/ServerManager.java
index a4fd68ff..f762b0e7 100644
--- a/juick-server/src/main/java/com/juick/server/ServerManager.java
+++ b/juick-server/src/main/java/com/juick/server/ServerManager.java
@@ -55,8 +55,6 @@ public class ServerManager implements NotificationListener {
private UserService userService;
@Value("${service_user:juick}")
private String serviceUser;
- @Inject
- private XMPPConnection router;
private void onJuickPM(final int uid_to, final com.juick.Message jmsg) {
try {
diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
index 856b1367..692ed3fe 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -83,8 +83,6 @@ import java.util.concurrent.ExecutorService;
/**
* @author ugnich
*/
-@Component
-@DependsOn("XMPPRouter")
public class XMPPConnection implements StanzaListener, NotificationListener {
private static final Logger logger = LoggerFactory.getLogger("com.juick.server.xmpp");
diff --git a/juick-server/src/main/java/com/juick/server/XMPPServer.java b/juick-server/src/main/java/com/juick/server/XMPPServer.java
index f2e41750..f9d0169e 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPServer.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPServer.java
@@ -58,7 +58,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author ugnich
*/
-@Component
public class XMPPServer implements ConnectionListener {
private static final Logger logger = LoggerFactory.getLogger("com.juick.server.xmpp");
diff --git a/juick-server/src/main/java/com/juick/server/api/Index.java b/juick-server/src/main/java/com/juick/server/api/Index.java
index 0faf270f..947ac920 100644
--- a/juick-server/src/main/java/com/juick/server/api/Index.java
+++ b/juick-server/src/main/java/com/juick/server/api/Index.java
@@ -43,8 +43,6 @@ import java.util.stream.Collectors;
public class Index {
@Inject
private WebsocketManager wsHandler;
- @Inject
- private XMPPServer xmpp;
@RequestMapping(value = { "/api/", "/ws/" }, method = RequestMethod.GET, headers = "Connection!=Upgrade")
public ResponseEntity<Void> description() {
@@ -56,14 +54,4 @@ public class Index {
public Status status() {
return Status.getStatus(String.valueOf(wsHandler.getClients().size()));
}
- @RequestMapping(method = RequestMethod.GET, value = "/api/xmpp-status", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- public XMPPStatus xmppStatus() {
- XMPPStatus status = new XMPPStatus();
- if (xmpp != null) {
- status.setInbound(xmpp.getInConnections().stream().map(c -> c.from).flatMap(j -> j.stream().map(Jid::getDomain)).collect(Collectors.toList()));
- status.setOutbound(xmpp.getOutConnections().keySet().stream()
- .map(c -> c.to).map(Jid::getDomain).collect(Collectors.toList()));
- }
- return status;
- }
}
diff --git a/juick-server/src/main/java/com/juick/server/configuration/XMPPConfig.java b/juick-server/src/main/java/com/juick/server/configuration/XMPPConfig.java
new file mode 100644
index 00000000..e1115c7e
--- /dev/null
+++ b/juick-server/src/main/java/com/juick/server/configuration/XMPPConfig.java
@@ -0,0 +1,27 @@
+package com.juick.server.configuration;
+
+import com.juick.server.XMPPConnection;
+import com.juick.server.XMPPServer;
+import com.juick.server.xmpp.router.XMPPRouter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.DependsOn;
+
+@Configuration
+@ConditionalOnProperty("xmppbot_jid")
+public class XMPPConfig {
+ @Bean
+ public XMPPServer xmppServer() {
+ return new XMPPServer();
+ }
+ @Bean
+ public XMPPRouter xmppRouter() {
+ return new XMPPRouter();
+ }
+ @Bean
+ @DependsOn("xmppRouter")
+ public XMPPConnection xmppConnection() {
+ return new XMPPConnection();
+ }
+}
diff --git a/juick-server/src/main/java/com/juick/server/xmpp/XMPPStatusPage.java b/juick-server/src/main/java/com/juick/server/xmpp/XMPPStatusPage.java
new file mode 100644
index 00000000..90c8fe59
--- /dev/null
+++ b/juick-server/src/main/java/com/juick/server/xmpp/XMPPStatusPage.java
@@ -0,0 +1,30 @@
+package com.juick.server.xmpp;
+
+import com.juick.server.XMPPServer;
+import com.juick.server.xmpp.helpers.XMPPStatus;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+import rocks.xmpp.addr.Jid;
+
+import javax.inject.Inject;
+import java.util.stream.Collectors;
+
+@RestController
+@ConditionalOnProperty("xmppbot_jid")
+public class XMPPStatusPage {
+ @Inject
+ private XMPPServer xmpp;
+ @RequestMapping(method = RequestMethod.GET, value = "/api/xmpp-status", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public XMPPStatus xmppStatus() {
+ XMPPStatus status = new XMPPStatus();
+ if (xmpp != null) {
+ status.setInbound(xmpp.getInConnections().stream().map(c -> c.from).flatMap(j -> j.stream().map(Jid::getDomain)).collect(Collectors.toList()));
+ status.setOutbound(xmpp.getOutConnections().keySet().stream()
+ .map(c -> c.to).map(Jid::getDomain).collect(Collectors.toList()));
+ }
+ return status;
+ }
+}
diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java b/juick-server/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java
index 4464262c..6d67fa9c 100644
--- a/juick-server/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java
+++ b/juick-server/src/main/java/com/juick/server/xmpp/router/XMPPRouter.java
@@ -39,7 +39,6 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
-@Component
public class XMPPRouter implements StreamHandler {
private static final Logger logger = LoggerFactory.getLogger("com.juick.server.xmpp");