aboutsummaryrefslogtreecommitdiff
path: root/juick-api
diff options
context:
space:
mode:
Diffstat (limited to 'juick-api')
-rw-r--r--juick-api/src/main/java/com/juick/api/Main.java31
1 files changed, 23 insertions, 8 deletions
diff --git a/juick-api/src/main/java/com/juick/api/Main.java b/juick-api/src/main/java/com/juick/api/Main.java
index 6d7deeac..669dc11d 100644
--- a/juick-api/src/main/java/com/juick/api/Main.java
+++ b/juick-api/src/main/java/com/juick/api/Main.java
@@ -55,8 +55,8 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+
/**
- *
* @author Ugnich Anton
*/
@WebServlet(name = "Main", urlPatterns = {"/"})
@@ -103,6 +103,19 @@ public class Main extends HttpServlet {
}
}
+ @Override
+ public void destroy() {
+ try {
+ if (xmpp != null)
+ xmpp.close();
+
+ log("ExternalComponent on juick-api destroyed");
+ } catch (Exception e) {
+ log("Exception occurs on juick-api destroy", e);
+ }
+
+ }
+
public void setupXmppComponent(final String host, final int port, final String jid, final String password) {
XmppSessionConfiguration configuration = XmppSessionConfiguration.builder()
.extensions(Extension.of(com.juick.Message.class))
@@ -115,12 +128,13 @@ public class Main extends HttpServlet {
}
}
- /**
+ /**
* Handles the HTTP <code>GET</code> method.
- * @param request servlet request
+ *
+ * @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
+ * @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
@@ -182,12 +196,13 @@ public class Main extends HttpServlet {
}
}
- /**
+ /**
* Handles the HTTP <code>POST</code> method.
- * @param request servlet request
+ *
+ * @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
+ * @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
@@ -272,7 +287,7 @@ public class Main extends HttpServlet {
}
String paramImg = request.getParameter("img");
- if (attachmentFName == null && paramImg != null && paramImg.length() > 10 ) {
+ if (attachmentFName == null && paramImg != null && paramImg.length() > 10) {
try {
URL imgUrl = new URL(paramImg);
attachmentFName = Utils.downloadImage(imgUrl);