diff options
| author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2026-06-12 10:55:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-12 10:55:41 +0200 |
| commit | 326c1cd1a7340932b027266927dda1bb60555032 (patch) | |
| tree | f790fcf70c264abc38a794b0b863bace9543bf8a /pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java | |
| parent | 4e9263067734225a43b91aec3b38bede71038303 (diff) | |
| download | pdf-as-4-326c1cd1a7340932b027266927dda1bb60555032.tar.gz pdf-as-4-326c1cd1a7340932b027266927dda1bb60555032.tar.bz2 pdf-as-4-326c1cd1a7340932b027266927dda1bb60555032.zip | |
include springboot admin client (default to disabled) (#96)
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java')
| -rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java index 14b68956..75042176 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java @@ -1,28 +1,53 @@ package at.gv.egiz.pdfas.web; import lombok.val; +import org.jetbrains.annotations.NotNull; +import org.springframework.boot.EnvironmentPostProcessor; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.MapPropertySource; + +import java.util.HashMap; @SpringBootApplication public class PdfAsWeb extends SpringBootServletInitializer { - static { - // compatibility layer: map the old logback.configurationFile to the new logging.config - final String SPRING_LOG_CFG = "logging.config"; - final String LEGACY_LOGBACK_LOG_CFG = "logback.configurationFile"; - if (System.getProperty(SPRING_LOG_CFG) == null) { - val legacyValue = System.getProperty(LEGACY_LOGBACK_LOG_CFG); - if (legacyValue != null) { - System.setProperty(SPRING_LOG_CFG, legacyValue); + // registered in resources/META-INF/spring.factories + public static class DefaultProperties implements EnvironmentPostProcessor { + @Override + public void postProcessEnvironment( + @NotNull ConfigurableEnvironment environment, @NotNull SpringApplication application) + { + /* + == DEFAULT PROPERTIES == + these are properties with the lowest precedence + so anything else (pdf-as-web.properties, system params, etc) can override them + */ + val defaultProperties = new HashMap<String, Object>(); + // set the default application name + defaultProperties.put("spring.application.name", "PDF-AS Web"); + // disable spring boot admin client by default + defaultProperties.put("spring.boot.admin.client.enabled", "false"); + // compatibility layer: map the old logback.configurationFile to the new logging.config + val legacyLogProperty = System.getProperty("logback.configurationFile"); + if (legacyLogProperty != null) { + defaultProperties.put("logging.config", legacyLogProperty); } + + /* + == END DEFAULT PROPERTIES == + */ + + + environment.getPropertySources().addLast(new MapPropertySource("pdf-as-web-defaults", defaultProperties)); } } @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + protected @NotNull SpringApplicationBuilder configure(@NotNull SpringApplicationBuilder application) { return application.sources(PdfAsWeb.class); } |
