diff options
author | Vitaly Takmazov | 2016-11-08 16:11:53 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-08 16:11:53 +0300 |
commit | 40c1a196d019fbaf3dd8f0d8f6d1bdc8225bb7a0 (patch) | |
tree | e1a16a993a3f81a2f326bf6471d16570bf15c238 /juick-xmpp/src/main/java/com/juick/components/controllers | |
parent | 4314d834724bbb5c671e7300b7de865fe53c51fb (diff) |
juick-xmpp: statsfile -> status
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick/components/controllers')
-rw-r--r-- | juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java | 31 |
1 files changed, 31 insertions, 0 deletions
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 new file mode 100644 index 00000000..9617ab56 --- /dev/null +++ b/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java @@ -0,0 +1,31 @@ +package com.juick.components.controllers; + +import com.juick.components.XMPPServer; +import com.juick.server.helpers.Status; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.inject.Inject; + +/** + * Created by vitalyster on 24.10.2016. + */ +@Controller +@ResponseBody +public class StatusController { + @Inject + XMPPServer xmpp; + + @RequestMapping(method = RequestMethod.GET, value = "/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + public Status status() { + 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 new Status(status); + } + return new Status("Error"); + } +} |