aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-11 01:29:01 +0700
committerGravatar Vitaly Takmazov2016-11-11 17:27:58 +0300
commit6604dc96558028c0095f33eca1852de5e61f8466 (patch)
tree5da1118a468d7142250112ee83f81b5849accdf0 /juick-xmpp/src
parent9077e9f21d785a6507aeb79d04faca2107aa80e4 (diff)
common data configuration is added
Diffstat (limited to 'juick-xmpp/src')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java20
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/configuration/XMPPInitializer.java11
2 files changed, 14 insertions, 17 deletions
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();
diff --git a/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPInitializer.java b/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPInitializer.java
index 604516c4..3942f889 100644
--- a/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPInitializer.java
+++ b/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPInitializer.java
@@ -1,4 +1,6 @@
package com.juick.components.configuration;
+
+import com.juick.configuration.DataConfiguration;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
@@ -10,24 +12,25 @@ import javax.servlet.Filter;
public class XMPPInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
- return new Class[] {XMPPConfiguration.class};
+ return new Class[]{DataConfiguration.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
- return null;
+ return new Class[]{XMPPConfiguration.class};
}
@Override
protected String[] getServletMappings() {
- return new String[] {
+ return new String[]{
"/"
};
}
+
@Override
protected Filter[] getServletFilters() {
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
- return new Filter[] { characterEncodingFilter};
+ return new Filter[]{characterEncodingFilter};
}
}