diff options
Diffstat (limited to 'src/main/java/com/juick/CrosspostComponent.java')
-rw-r--r-- | src/main/java/com/juick/CrosspostComponent.java | 56 |
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); } } |