aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-rw-r--r--juick-www/src/main/java/com/juick/www/WebApp.java27
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WwwAppConfiguration.java20
2 files changed, 17 insertions, 30 deletions
diff --git a/juick-www/src/main/java/com/juick/www/WebApp.java b/juick-www/src/main/java/com/juick/www/WebApp.java
index c3437c0b..f254b5fa 100644
--- a/juick-www/src/main/java/com/juick/www/WebApp.java
+++ b/juick-www/src/main/java/com/juick/www/WebApp.java
@@ -16,13 +16,17 @@
*/
package com.juick.www;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.Message;
import com.juick.Tag;
import com.juick.service.TagService;
+import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.XmppException;
import rocks.xmpp.core.session.Extension;
@@ -32,8 +36,11 @@ import rocks.xmpp.extensions.component.accept.ExternalComponent;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.stream.Stream;
@@ -41,6 +48,7 @@ import java.util.stream.Stream;
*
* @author Ugnich Anton
*/
+@Component
public class WebApp implements DisposableBean {
private static Logger logger = LoggerFactory.getLogger(WebApp.class);
@@ -48,7 +56,8 @@ public class WebApp implements DisposableBean {
@Inject
private TagService tagService;
-
+ @Inject
+ private ObjectMapper jsonMapper;
@Value("${xmpp_host:localhost}")
private String xmppHost;
@Value("${xmpp_password:secret}")
@@ -64,7 +73,13 @@ public class WebApp implements DisposableBean {
private String styleUrl;
@PostConstruct
- public void init() {
+ public void init() throws IOException {
+ String manifestString = IOUtils.toString(getClass().getClassLoader().
+ getResourceAsStream("manifest.json"), StandardCharsets.UTF_8);
+ HashMap<String, String> manifest = jsonMapper.readValue(manifestString,
+ new TypeReference<HashMap<String, String>>() {});
+ scriptsUrl = manifest.get("scripts.js");
+ styleUrl = manifest.get("style.css");
if (!isXmppDisabled) {
setupXmppComponent(Jid.of(xmppJid),
xmppPassword, xmppPort);
@@ -128,12 +143,4 @@ public class WebApp implements DisposableBean {
public String getScriptsUrl() {
return scriptsUrl;
}
-
- public void setScriptsUrl(String scriptsUrl) {
- this.scriptsUrl = scriptsUrl;
- }
-
- public void setStyleUrl(String styleUrl) {
- this.styleUrl = styleUrl;
- }
}
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 c30f5a92..e04538e8 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
@@ -17,14 +17,10 @@
package com.juick.www.configuration;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.service.CloudflareCache;
import com.juick.service.TagService;
import com.juick.service.UserService;
import com.juick.www.HelpService;
-import com.juick.www.WebApp;
-import org.apache.commons.io.IOUtils;
import org.commonmark.ext.autolink.AutolinkExtension;
import org.commonmark.node.Link;
import org.commonmark.parser.Parser;
@@ -36,10 +32,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import javax.inject.Inject;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
import java.util.Collections;
-import java.util.HashMap;
/**
* Created by aalexeev on 11/22/16.
@@ -52,19 +45,6 @@ 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<String, String> manifest = jsonMapper.readValue(manifestString,
- new TypeReference<HashMap<String, String>>() {});
- app.setScriptsUrl(manifest.get("scripts.js"));
- app.setStyleUrl(manifest.get("style.css"));
- return app;
- }
@Bean
public CaffeineCacheManager cacheManager() {
return new CaffeineCacheManager("help");