From 943b0e3875de3b99480115b6c28d7b113692c5cb Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 22 Dec 2015 15:47:03 +0300 Subject: refactoring --- src/main/java/com/juick/CrosspostComponent.java | 9 ++++++--- src/main/java/com/juick/PushComponent.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/juick/CrosspostComponent.java b/src/main/java/com/juick/CrosspostComponent.java index 73791c5e..4c6a5002 100644 --- a/src/main/java/com/juick/CrosspostComponent.java +++ b/src/main/java/com/juick/CrosspostComponent.java @@ -82,7 +82,8 @@ public class CrosspostComponent implements ServletContextListener, Stream.Strea twitter_consumer_key = conf.getProperty("twitter_consumer_key", ""); twitter_consumer_secret = conf.getProperty("twitter_consumer_secret", ""); - setupSql(conf.getProperty("mysql_username", ""), conf.getProperty("mysql_password", "")); + 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); @@ -97,9 +98,11 @@ public class CrosspostComponent implements ServletContextListener, Stream.Strea logger.info("component destroyed"); } - public void setupSql(String username, String password) { + public void setupSql(String host, String username, String password, String database) { try { - sql = DriverManager.getConnection("jdbc:mysql://localhost/juick?autoReconnect=true&user=" + username + "&password=" + password); + 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); } diff --git a/src/main/java/com/juick/PushComponent.java b/src/main/java/com/juick/PushComponent.java index 9de598f3..f2c1ee74 100644 --- a/src/main/java/com/juick/PushComponent.java +++ b/src/main/java/com/juick/PushComponent.java @@ -76,7 +76,7 @@ public class PushComponent implements ServletContextListener, Stream.StreamListe public void run() { Properties conf = new Properties(); try { - conf.load(sce.getServletContext().getResourceAsStream("WEB-INF/push.conf")); + conf.load(sce.getServletContext().getResourceAsStream("WEB-INF/juick.conf")); GCMSender = new Sender(conf.getProperty("gcm_key")); setupSql(conf.getProperty("mysql_host"), conf.getProperty("mysql_username"), -- cgit v1.2.3