From aa94206f1ccac6ae2a4b780ad9aecde964f7d9bc Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 16 Feb 2017 13:42:35 +0300 Subject: juick-xmpp: detailed status api --- .../components/controllers/StatusController.java | 14 +++++----- .../components/controllers/helpers/XMPPStatus.java | 30 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 juick-xmpp/src/main/java/com/juick/components/controllers/helpers/XMPPStatus.java (limited to 'juick-xmpp/src/main/java/com') diff --git a/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java b/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java index 68168c16..31984a7a 100644 --- a/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java +++ b/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java @@ -1,7 +1,7 @@ package com.juick.components.controllers; import com.juick.components.XMPPServer; -import com.juick.Status; +import com.juick.components.controllers.helpers.XMPPStatus; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -17,13 +17,13 @@ public class StatusController { @Inject XMPPServer xmpp; - @RequestMapping(method = RequestMethod.GET, value = "/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Status status() { + @RequestMapping(method = RequestMethod.GET, value = "/status", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public XMPPStatus status() { + XMPPStatus status = new XMPPStatus(); if (xmpp != null) { - String status = String.format("s2s in: %d, s2s out: %d, cached: %d", - xmpp.getInConnections().size(), xmpp.getOutConnections().size(), xmpp.getOutCache().size()); - return Status.getStatus(status); + status.setInbound(xmpp.getInConnections()); + status.setOutbound(xmpp.getOutConnections()); } - return Status.ERROR; + return status; } } diff --git a/juick-xmpp/src/main/java/com/juick/components/controllers/helpers/XMPPStatus.java b/juick-xmpp/src/main/java/com/juick/components/controllers/helpers/XMPPStatus.java new file mode 100644 index 00000000..efa59601 --- /dev/null +++ b/juick-xmpp/src/main/java/com/juick/components/controllers/helpers/XMPPStatus.java @@ -0,0 +1,30 @@ +package com.juick.components.controllers.helpers; + +import com.juick.components.s2s.ConnectionIn; +import com.juick.components.s2s.ConnectionOut; + +import java.util.List; + +/** + * Created by vitalyster on 16.02.2017. + */ +public class XMPPStatus { + private List inbound; + private List outbound; + + public List getInbound() { + return inbound; + } + + public void setInbound(List inbound) { + this.inbound = inbound; + } + + public List getOutbound() { + return outbound; + } + + public void setOutbound(List outbound) { + this.outbound = outbound; + } +} -- cgit v1.2.3