added static property support to GUI and fix setting gui endpoint
This commit is contained in:
parent
2a5a243759
commit
606de67aa2
3 changed files with 57 additions and 4 deletions
|
@ -42,6 +42,9 @@ public class RAPConfiguration implements ApplicationConfiguration {
|
|||
public void configure(final Application application) {
|
||||
try {
|
||||
|
||||
final String guiEntrypoint = StaticApplicationPropertyResolver
|
||||
.getProperty("sebserver.gui.entrypoint", "/gui");
|
||||
|
||||
// TODO get file path from properties
|
||||
//application.addStyleSheet(RWT.DEFAULT_THEME_ID, "static/css/sebserver.css");
|
||||
application.addStyleSheet(DEFAULT_THEME_NAME, "resource/theme/default.css");
|
||||
|
@ -54,7 +57,7 @@ public class RAPConfiguration implements ApplicationConfiguration {
|
|||
properties.put(WebClient.BODY_HTML, "<big>Loading Application<big>");
|
||||
properties.put(WebClient.THEME_ID, DEFAULT_THEME_NAME);
|
||||
// properties.put(WebClient.FAVICON, "icons/favicon.png");
|
||||
application.addEntryPoint("/gui", new RAPSpringEntryPointFactory(), properties);
|
||||
application.addEntryPoint(guiEntrypoint, new RAPSpringEntryPointFactory(), properties);
|
||||
|
||||
} catch (final RuntimeException re) {
|
||||
throw re;
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.eclipse.rap.rwt.engine.RWTServlet;
|
||||
import org.eclipse.rap.rwt.engine.RWTServletContextListener;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -22,8 +24,7 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
|
||||
@Configuration
|
||||
@GuiProfile
|
||||
|
@ -37,8 +38,14 @@ public class RAPSpringConfig {
|
|||
@Value("${sebserver.gui.external.messages:messages}")
|
||||
private String externalMessagesPath;
|
||||
|
||||
@Bean
|
||||
public StaticApplicationPropertyResolver staticApplicationPropertyResolver() {
|
||||
return new StaticApplicationPropertyResolver();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletContextInitializer initializer() {
|
||||
staticApplicationPropertyResolver();
|
||||
return new RAPServletContextInitializer();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2020 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
public class StaticApplicationPropertyResolver implements ApplicationContextAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(StaticApplicationPropertyResolver.class);
|
||||
|
||||
private static ApplicationContext CONTEXT;
|
||||
|
||||
public StaticApplicationPropertyResolver() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
|
||||
CONTEXT = applicationContext;
|
||||
}
|
||||
|
||||
public static String getProperty(final String name, final String defaultValue) {
|
||||
try {
|
||||
final Environment env = CONTEXT.getBean(Environment.class);
|
||||
return env.getProperty(name, defaultValue);
|
||||
} catch (final Exception e) {
|
||||
log.warn("Failed to get property: {} from static context. Return default value: {}", name, defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue