aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/CrosspostComponent.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-02-02 00:06:21 +0300
committerGravatar Vitaly Takmazov2016-02-02 00:06:21 +0300
commitf2a2660e753fa11478fd3edadfdff9c000b22cc9 (patch)
tree3204b0a1f1f599250b1602b9411060d7de676a0e /src/main/java/com/juick/CrosspostComponent.java
parent9bd81dc9e69ba58d8fedd4adfb7e80245019eb18 (diff)
minor cleanup
Diffstat (limited to 'src/main/java/com/juick/CrosspostComponent.java')
-rw-r--r--src/main/java/com/juick/CrosspostComponent.java56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/main/java/com/juick/CrosspostComponent.java b/src/main/java/com/juick/CrosspostComponent.java
index 7fd50564..22de81b6 100644
--- a/src/main/java/com/juick/CrosspostComponent.java
+++ b/src/main/java/com/juick/CrosspostComponent.java
@@ -24,13 +24,13 @@ import com.juick.xmpp.Stream;
import com.juick.xmpp.StreamComponent;
import com.juick.xmpp.extensions.JuickMessage;
import com.juick.xmpp.utils.Base64;
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.net.ssl.HttpsURLConnection;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.io.*;
import java.net.Socket;
import java.net.URL;
import java.net.URLEncoder;
@@ -47,11 +47,6 @@ import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-import javax.net.ssl.HttpsURLConnection;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
/**
*
@@ -75,24 +70,21 @@ public class CrosspostComponent implements ServletContextListener, Stream.Strea
public void contextInitialized(final ServletContextEvent sce) {
logger.info("component initialized");
executorService = Executors.newSingleThreadExecutor();
- executorService.submit(new Runnable() {
- @Override
- public void run() {
- try {
- Properties conf = new Properties();
- conf.load(sce.getServletContext().getResourceAsStream("WEB-INF/juick.conf"));
-
- LogManager.getLogManager().readConfiguration(
- sce.getServletContext().getResourceAsStream("WEB-INF/logging.properties"));
- twitter_consumer_key = conf.getProperty("twitter_consumer_key", "");
- twitter_consumer_secret = conf.getProperty("twitter_consumer_secret", "");
-
- setupSql(conf.getProperty("mysql_host"), conf.getProperty("mysql_username"),
- conf.getProperty("mysql_password", ""), conf.getProperty("mysql_database", ""));
- setupXmppComponent(conf.getProperty("xmpp_password", ""));
- } catch (Exception e) {
- logger.log(Level.SEVERE, e.getMessage(), e);
- }
+ executorService.submit((Runnable) () -> {
+ try {
+ Properties conf = new Properties();
+ conf.load(sce.getServletContext().getResourceAsStream("WEB-INF/juick.conf"));
+
+ LogManager.getLogManager().readConfiguration(
+ sce.getServletContext().getResourceAsStream("WEB-INF/logging.properties"));
+ twitter_consumer_key = conf.getProperty("twitter_consumer_key", "");
+ twitter_consumer_secret = conf.getProperty("twitter_consumer_secret", "");
+
+ setupSql(conf.getProperty("mysql_host"), conf.getProperty("mysql_username"),
+ conf.getProperty("mysql_password", ""), conf.getProperty("mysql_database", ""));
+ setupXmppComponent(conf.getProperty("xmpp_password", ""));
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
}
});
}
@@ -129,9 +121,7 @@ public class CrosspostComponent implements ServletContextListener, Stream.Strea
sql = DriverManager.getConnection(
String.format("jdbc:mysql://%s/%s?autoReconnect=true&user=%s&password=%s",
host, database, username, password));
- } catch (SQLException e) {
- logger.log(Level.SEVERE, e.getMessage(), e);
- } catch (ClassNotFoundException e) {
+ } catch (SQLException | ClassNotFoundException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
}