From b75b5a3d1a3bf001923d49923dcebee95ba2327e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 29 Jun 2017 17:09:49 +0300 Subject: notifications and configurations refactoring --- juick-www/build.gradle | 4 ---- .../com/juick/www/configuration/WwwAppConfiguration.java | 14 +++----------- .../java/com/juick/www/configuration/WwwInitializer.java | 2 ++ .../juick/www/configuration/WwwServletConfiguration.java | 9 --------- juick-www/src/test/java/com/juick/www/WebAppTests.java | 3 ++- 5 files changed, 7 insertions(+), 25 deletions(-) (limited to 'juick-www') diff --git a/juick-www/build.gradle b/juick-www/build.gradle index 4c26f754..3a2508a2 100644 --- a/juick-www/build.gradle +++ b/juick-www/build.gradle @@ -23,11 +23,7 @@ dependencies { compile 'com.github.scribejava:scribejava-apis:4.1.1' compile 'com.github.ooxi:serialized-php-parser:0.5.0' compile 'com.sun.mail:javax.mail:1.5.6' - compile "org.springframework:spring-webmvc:${rootProject.springFrameworkVersion}" - compile "org.springframework:spring-context-support:${rootProject.springFrameworkVersion}" compile 'com.mitchellbosecke:pebble-spring4:2.3.0' - providedCompile 'javax.servlet:javax.servlet-api:3.1.0' - providedRuntime 'mysql:mysql-connector-java:5.1.40' testCompile project(path: ':juick-server-jdbc', configuration: 'testArtifacts') // htmlunit 2.25 isn't compatible with spring-test 4.3.6 diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java index 2e5a4f89..8dc8093e 100644 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java +++ b/juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java @@ -33,12 +33,14 @@ public class WwwAppConfiguration { private UserService userService; @Inject private TagService tagService; + @Inject + private ObjectMapper jsonMapper; @Bean public WebApp webApp() throws IOException { WebApp app = new WebApp(); String manifestString = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("manifest.json"), StandardCharsets.UTF_8); - HashMap manifest = jsonMapper().readValue(manifestString, + HashMap manifest = jsonMapper.readValue(manifestString, new TypeReference>() {}); app.setScriptsUrl(manifest.get("scripts.js")); app.setStyleUrl(manifest.get("style.css")); @@ -58,14 +60,4 @@ public class WwwAppConfiguration { return new HelpService("help"); } - @Bean - public ObjectMapper jsonMapper() { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); - mapper.registerModule(new Jdk8Module()); - return mapper; - } - } diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java b/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java index 199fbf85..bc5851db 100644 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java +++ b/juick-www/src/main/java/com/juick/www/configuration/WwwInitializer.java @@ -2,6 +2,7 @@ package com.juick.www.configuration; import com.juick.configuration.DataConfiguration; import com.juick.configuration.SearchConfiguration; +import com.juick.server.configuration.BaseWebConfiguration; import org.apache.commons.codec.CharEncoding; import org.springframework.web.filter.CharacterEncodingFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; @@ -18,6 +19,7 @@ public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletIni @Override protected Class[] getRootConfigClasses() { return new Class[]{ + BaseWebConfiguration.class, WwwAppConfiguration.class, DataConfiguration.class, SearchConfiguration.class, diff --git a/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java index ae51f1cd..d7e5c72e 100644 --- a/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java +++ b/juick-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java @@ -31,8 +31,6 @@ import java.util.concurrent.TimeUnit; @ComponentScan(basePackages = {"com.juick.www.controllers"}) @PropertySource("classpath:juick.conf") public class WwwServletConfiguration extends WebMvcConfigurationSupport { - @Inject - private Environment env; @Override protected void addResourceHandlers(ResourceHandlerRegistry registry) { @@ -61,13 +59,6 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport { return result; } - @Bean - public MultipartResolver multipartResolver() { - CommonsMultipartResolver resolver = new CommonsMultipartResolver(); - resolver.setMaxUploadSize(10000000); - return resolver; - } - @Inject private ServletContext servletContext; diff --git a/juick-www/src/test/java/com/juick/www/WebAppTests.java b/juick-www/src/test/java/com/juick/www/WebAppTests.java index 773a6d9a..fb9db34c 100644 --- a/juick-www/src/test/java/com/juick/www/WebAppTests.java +++ b/juick-www/src/test/java/com/juick/www/WebAppTests.java @@ -6,6 +6,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.juick.Message; import com.juick.User; import com.juick.configuration.MockDataConfiguration; +import com.juick.server.configuration.BaseWebConfiguration; import com.juick.service.MessagesService; import com.juick.service.UserService; import com.juick.tests.util.MockUtils; @@ -41,7 +42,7 @@ import static org.mockito.Mockito.when; public class WebAppTests { @Configuration @Import(value = { - WwwServletConfiguration.class, WwwAppConfiguration.class, SapeConfiguration.class, + BaseWebConfiguration.class, WwwServletConfiguration.class, WwwAppConfiguration.class, SapeConfiguration.class, MockDataConfiguration.class }) static class Config {} -- cgit v1.2.3