From 6604dc96558028c0095f33eca1852de5e61f8466 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Fri, 11 Nov 2016 01:29:01 +0700 Subject: common data configuration is added --- .../components/configuration/XMPPConfiguration.java | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java') diff --git a/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java b/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java index 9e7e6cad..c4bdd117 100644 --- a/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java +++ b/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java @@ -8,7 +8,6 @@ import com.mitchellbosecke.pebble.loader.Loader; import com.mitchellbosecke.pebble.loader.ServletLoader; import com.mitchellbosecke.pebble.spring4.PebbleViewResolver; import com.mitchellbosecke.pebble.spring4.extension.SpringExtension; -import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -33,25 +32,18 @@ import java.util.concurrent.Executors; */ @Configuration @ComponentScan(basePackages = {"com.juick"}) -@PropertySource(value = "classpath:juick.conf", ignoreResourceNotFound = true) +@PropertySource(value = {"classpath:juick.conf", "file:${user.home}/juick.conf"}) public class XMPPConfiguration extends WebMvcConfigurationSupport { @Inject - Environment env; + private Environment env; @Inject - ExecutorService service; + private JdbcTemplate jdbc; - @Bean - JdbcTemplate jdbc() { - BasicDataSource dataSource = new BasicDataSource(); - dataSource.setDriverClassName(env.getProperty("datasource_driver", "com.mysql.jdbc.Driver")); - dataSource.setUrl(env.getProperty("datasource_url")); - return new JdbcTemplate(dataSource); - } @Inject private ServletContext servletContext; @Bean - public Loader templateLoader(){ + public Loader templateLoader() { return new ServletLoader(servletContext); } @@ -76,10 +68,12 @@ public class XMPPConfiguration extends WebMvcConfigurationSupport { viewResolver.setPebbleEngine(pebbleEngine()); return viewResolver; } + @Bean public XMPPServer xmpp() { - return new XMPPServer(env, service, jdbc()); + return new XMPPServer(env, service(), jdbc); } + @Bean public ExecutorService service() { return Executors.newCachedThreadPool(); -- cgit v1.2.3