aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java/com/juick/components/configuration
diff options
context:
space:
mode:
Diffstat (limited to 'juick-xmpp/src/main/java/com/juick/components/configuration')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/configuration/XmppAppConfiguration.java38
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/configuration/XmppInitializer.java (renamed from juick-xmpp/src/main/java/com/juick/components/configuration/XMPPInitializer.java)17
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/configuration/XmppMvcConfiguration.java (renamed from juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java)43
3 files changed, 53 insertions, 45 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/configuration/XmppAppConfiguration.java b/juick-xmpp/src/main/java/com/juick/components/configuration/XmppAppConfiguration.java
new file mode 100644
index 00000000..eb3dd726
--- /dev/null
+++ b/juick-xmpp/src/main/java/com/juick/components/configuration/XmppAppConfiguration.java
@@ -0,0 +1,38 @@
+package com.juick.components.configuration;
+
+/**
+ * Created by aalexeev on 11/12/16.
+ */
+
+import com.juick.components.XMPPServer;
+import com.juick.configuration.DataConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.env.Environment;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.inject.Inject;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Configuration
+@PropertySource("classpath:juick.conf")
+@Import(DataConfiguration.class)
+public class XmppAppConfiguration {
+ @Inject
+ private Environment env;
+ @Inject
+ private JdbcTemplate jdbc;
+
+ @Bean
+ public XMPPServer xmpp() {
+ 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 3942f889..89dd69e1 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
@@ -9,28 +9,33 @@ import javax.servlet.Filter;
/**
* Created by vt on 09/02/16.
*/
-public class XMPPInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
+public class XmppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
+
@Override
protected Class<?>[] getRootConfigClasses() {
- return new Class[]{DataConfiguration.class};
+ return new Class<?>[]{XmppAppConfiguration.class, DataConfiguration.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
- return new Class[]{XMPPConfiguration.class};
+ return new Class<?>[]{XmppMvcConfiguration.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};
}
+
+ @Override
+ protected String getServletName() {
+ return "Xmpp dispatcher servlet";
+ }
}
diff --git a/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java b/juick-xmpp/src/main/java/com/juick/components/configuration/XmppMvcConfiguration.java
index 13ac2a9d..4a0e8ced 100644
--- a/juick-xmpp/src/main/java/com/juick/components/configuration/XMPPConfiguration.java
+++ b/juick-xmpp/src/main/java/com/juick/components/configuration/XmppMvcConfiguration.java
@@ -2,60 +2,35 @@ package com.juick.components.configuration;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
-import com.juick.components.XMPPServer;
import com.mitchellbosecke.pebble.PebbleEngine;
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.springframework.beans.factory.config.PlaceholderConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
-import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
-import org.springframework.core.env.Environment;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
-import javax.inject.Inject;
-import javax.servlet.ServletContext;
import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
/**
* Created by vitalyster on 28.06.2016.
*/
@Configuration
-@ComponentScan(basePackages = {"com.juick"})
-@PropertySource(value = {"classpath:juick.conf", "file:${user.home}/juick.conf"})
-public class XMPPConfiguration extends WebMvcConfigurationSupport {
- @Inject
- private Environment env;
- @Inject
- private JdbcTemplate jdbc;
-
- @Inject
- private ServletContext servletContext;
-
- @Bean
- public static PlaceholderConfigurerSupport propertySourcesPlaceholderConfigurer() {
- PlaceholderConfigurerSupport configurer = new PropertySourcesPlaceholderConfigurer();
-
- configurer.setFileEncoding("utf-8");
- configurer.setOrder(1);
- return configurer;
- }
+@ComponentScan(basePackages = {"com.juick.components.controllers"})
+@PropertySource("classpath:juick.conf")
+public class XmppMvcConfiguration extends WebMvcConfigurationSupport {
@Bean
public Loader templateLoader() {
- return new ServletLoader(servletContext);
+ return new ServletLoader(getServletContext());
}
@Bean
@@ -80,16 +55,6 @@ public class XMPPConfiguration extends WebMvcConfigurationSupport {
return viewResolver;
}
- @Bean
- public XMPPServer xmpp() {
- return new XMPPServer(env, service(), jdbc);
- }
-
- @Bean
- public ExecutorService service() {
- return Executors.newCachedThreadPool();
- }
-
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.setOrder(0);