diff options
author | Vitaly Takmazov | 2018-03-15 12:04:43 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-03-15 12:04:43 +0300 |
commit | 70f481e2fe39a9029b1896d7b351293fd5de4ef8 (patch) | |
tree | 96c2fffec50231a078986012ffd7308db88ad039 /juick-www/src/main/java/com/juick/www/WebApp.java | |
parent | b2f3afebc7de684d1d49042f5f79a9cbf9c1f2f2 (diff) |
www: WebApp refactoring
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/WebApp.java')
-rw-r--r-- | juick-www/src/main/java/com/juick/www/WebApp.java | 27 |
1 files changed, 17 insertions, 10 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; - } } |