aboutsummaryrefslogtreecommitdiff
path: root/juick-ws
diff options
context:
space:
mode:
Diffstat (limited to 'juick-ws')
-rw-r--r--juick-ws/build.gradle8
-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
3 files changed, 22 insertions, 18 deletions
diff --git a/juick-ws/build.gradle b/juick-ws/build.gradle
index 6a796c02..727a3c7b 100644
--- a/juick-ws/build.gradle
+++ b/juick-ws/build.gradle
@@ -15,15 +15,17 @@ repositories {
mavenCentral()
}
+def slf4jVersion = '1.7.21'
+def springFrameworkVersion = '4.3.4.RELEASE'
+def jacksonVersion = '2.8.4'
+
dependencies {
compile project(':juick-core')
compile project(':deps:com.juick.xmpp')
- compile 'org.slf4j:slf4j-jdk14:1.7.21'
- def springFrameworkVersion = '4.3.4.RELEASE'
+ compile 'org.slf4j:slf4j-api:${slf4jVersion}'
compile "org.springframework:spring-jdbc:${springFrameworkVersion}"
compile "org.springframework:spring-webmvc:${springFrameworkVersion}"
compile "org.springframework:spring-websocket:${springFrameworkVersion}"
- def jacksonVersion = '2.8.4'
compile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jacksonVersion}"
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);
}
});
}