aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com/juick/ws
diff options
context:
space:
mode:
Diffstat (limited to 'juick-ws/src/main/java/com/juick/ws')
-rw-r--r--juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java11
-rw-r--r--juick-ws/src/main/java/com/juick/ws/XMPPConnection.java21
2 files changed, 17 insertions, 15 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
index 4a9373b3..5860426a 100644
--- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
+++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
@@ -5,6 +5,8 @@ import com.juick.server.MessagesQueries;
import com.juick.server.UserQueries;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@@ -18,8 +20,6 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* Created by vitalyster on 28.06.2016.
@@ -29,7 +29,8 @@ public class WebsocketComponent extends TextWebSocketHandler {
@Inject
JdbcTemplate jdbc;
- private static final Logger logger = Logger.getLogger(WebsocketComponent.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(WebsocketComponent.class);
+
final List<SocketSubscribed> clients = Collections.synchronizedList(new ArrayList<SocketSubscribed>());
@Override
@@ -55,7 +56,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
logger.info(String.format("wrong hash for %d from %s", visitor.getUID(), hXRealIP));
session.close(new CloseStatus(403, "Forbidden"));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
}
break;
@@ -90,7 +91,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
try {
session.close(new CloseStatus(403, "Forbidden"));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
}
}
diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
index 0f2f75f6..8dffd388 100644
--- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
+++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
@@ -9,6 +9,8 @@ import com.juick.xmpp.Stream;
import com.juick.xmpp.StreamComponent;
import com.juick.xmpp.extensions.JuickMessage;
import org.apache.commons.lang3.math.NumberUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@@ -19,8 +21,6 @@ import java.io.IOException;
import java.net.Socket;
import java.util.List;
import java.util.concurrent.ExecutorService;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
/**
@@ -29,7 +29,8 @@ import java.util.stream.Collectors;
*/
@Component
public class XMPPConnection implements Stream.StreamListener, Message.MessageListener {
- private static final Logger logger = Logger.getLogger(XMPPConnection.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(XMPPConnection.class);
+
@Inject
JdbcTemplate sql;
ExecutorService service;
@@ -52,7 +53,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
xmpp.addListener((Message.MessageListener) this);
service.submit(() -> xmpp.startParsing());
} catch (IOException e) {
- logger.log(Level.SEVERE, "XMPPConnection error", e);
+ logger.error("XMPPConnection error", e);
}
}
@@ -64,7 +65,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
@Override
public void onStreamFail(Exception ex) {
- logger.log(Level.SEVERE, "XMPP stream failed", ex);
+ logger.error("XMPP stream failed", ex);
}
@Override
@@ -99,7 +100,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending pm to " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
}
@@ -118,7 +119,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending message to " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
wsHandler.clients.stream().filter(c ->
@@ -128,7 +129,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending message to legacy client " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
}
@@ -148,7 +149,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending reply to " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
wsHandler.clients.stream().filter(c ->
@@ -158,7 +159,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending reply to legacy client " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
}