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 --- .../configuration/NotificationsConfiguration.java | 13 +++++++------ .../components/configuration/NotificationsInitializer.java | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'juick-notifications/src/main/java/com/juick') diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsConfiguration.java b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsConfiguration.java index 0c7a857c..d42549ef 100644 --- a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsConfiguration.java +++ b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsConfiguration.java @@ -33,22 +33,20 @@ 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 NotificationsConfiguration extends WebMvcConfigurationSupport { @Inject Environment env; @Inject - ExecutorService service; + private ServletContext servletContext; @Bean RestTemplate rest() { return new RestTemplate(); } - @Inject - private ServletContext servletContext; @Bean - public Loader templateLoader(){ + public Loader templateLoader() { return new ServletLoader(servletContext); } @@ -73,10 +71,12 @@ public class NotificationsConfiguration extends WebMvcConfigurationSupport { viewResolver.setPebbleEngine(pebbleEngine()); return viewResolver; } + @Bean public Notifications push() { - return new Notifications(env, service); + return new Notifications(env, service()); } + @Bean public ExecutorService service() { return Executors.newCachedThreadPool(); @@ -88,6 +88,7 @@ public class NotificationsConfiguration extends WebMvcConfigurationSupport { mapping.setUseSuffixPatternMatch(false); return mapping; } + @Override protected void addResourceHandlers(ResourceHandlerRegistry registry) { registry.setOrder(0); diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java index 1449a4f8..417cc7fa 100644 --- a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.java +++ b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsInitializer.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,23 @@ import javax.servlet.Filter; public class NotificationsInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class[] getRootConfigClasses() { - return new Class[] {NotificationsConfiguration.class}; + return new Class[]{DataConfiguration.class}; } @Override protected Class[] getServletConfigClasses() { - return null; + return new Class[]{NotificationsConfiguration.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}; } } -- cgit v1.2.3