From 326c1cd1a7340932b027266927dda1bb60555032 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Fri, 12 Jun 2026 10:55:41 +0200 Subject: include springboot admin client (default to disabled) (#96) --- .../main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java | 43 +++++++++++++++++----- .../pdfas/web/servlets/SoapServiceServlet.java | 1 + 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'pdf-as-web/src/main/java') 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(); + // 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); } diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SoapServiceServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SoapServiceServlet.java index af395aee..8b97d7f7 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SoapServiceServlet.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SoapServiceServlet.java @@ -66,6 +66,7 @@ public class SoapServiceServlet extends CXFNonSpringServlet { try { p.close(); } catch (Exception e) { log.warn("Failed to close endpoint cleanly", e); } }); endpoints.clear(); + BusFactory.clearDefaultBusForAnyThread(getBus()); super.destroyBus(); } } -- cgit v1.2.3