From 7d16122e9ec18dfc032a624b665585ef42caad96 Mon Sep 17 00:00:00 2001 From: Konrad Neitzel Date: Sat, 29 Nov 2025 19:00:47 +0100 Subject: [PATCH] Added Quarkus util classes. --- fx/fx.adoc | 4 +- pom.xml | 5 +- quarkus/pom.xml | 59 +++++++++++++++++++ .../quarkus/util/GlobalRouteLogging.java | 26 ++++++++ .../quarkus/util/IncomingRequestFilter.java | 36 +++++++++++ .../quarkus/util/LoggingRequestFilter.java | 24 ++++++++ 6 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 quarkus/pom.xml create mode 100644 quarkus/src/main/java/de/neitzel/quarkus/util/GlobalRouteLogging.java create mode 100644 quarkus/src/main/java/de/neitzel/quarkus/util/IncomingRequestFilter.java create mode 100644 quarkus/src/main/java/de/neitzel/quarkus/util/LoggingRequestFilter.java diff --git a/fx/fx.adoc b/fx/fx.adoc index 20b5979..aa1ba55 100644 --- a/fx/fx.adoc +++ b/fx/fx.adoc @@ -12,9 +12,9 @@ Dieses Prinzip lässt sich noch erweitern: === component -Ähnlich wie in anderen UI-Frameworks (z. B. React) versuche ich, ein komponentenbasiertes Modell zu etablieren, um datengetriebene Oberflächen schnell und modular zusammenstellen zu können. +Ähnlich wie in anderen UI-Frameworks (z.B. React) versuche ich, ein komponentenbasiertes Modell zu etablieren, um datengetriebene Oberflächen schnell und modular zusammenstellen zu können. -Die Grundidee ist, mit möglichst geringem Aufwand Kombinationen aus Datenmodell und FXML zu erzeugen. So lässt sich z. B. eine FXML-Datei definieren, die eine Adresse darstellt – inklusive Felder und der zugehörigen Bindings. Möchte man nun einen Datensatz mit einer Adresse anzeigen, kann für das Adressfeld eine Pane erzeugt werden, die sowohl das Binding auf die Adresse als auch den Verweis auf die FXML-Datei enthält. +Die Grundidee ist, mit möglichst geringem Aufwand Kombinationen aus Datenmodell und FXML zu erzeugen. So lässt sich z.B. eine FXML-Datei definieren, die eine Adresse darstellt – inklusive Felder und der zugehörigen Bindings. Möchte man nun einen Datensatz mit einer Adresse anzeigen, kann für das Adressfeld eine Pane erzeugt werden, die sowohl das Binding auf die Adresse als auch den Verweis auf die FXML-Datei enthält. Dabei wird das MVVM-Pattern verwendet: Ausgehend vom Model wird ein passendes ViewModel automatisch generiert. diff --git a/pom.xml b/pom.xml index b0afd04..374fd26 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 @@ -18,6 +18,7 @@ net log4j fx-example + quarkus diff --git a/quarkus/pom.xml b/quarkus/pom.xml new file mode 100644 index 0000000..51ca136 --- /dev/null +++ b/quarkus/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + + de.neitzel.lib + neitzellib + 1.0-SNAPSHOT + + + quarkus + + + + ${project.artifactId} + ${project.artifactId} + ${project.artifactId} + ${project.artifactId}-${project.version} + + 3.30.1 + + + + + + io.quarkus + quarkus-core + ${quarkus.platform.version} + + + io.quarkus + quarkus-rest + ${quarkus.platform.version} + + + io.quarkus + quarkus-reactive-routes + ${quarkus.platform.version} + + + + + ${jar.filename} + + + + com.github.spotbugs + spotbugs-maven-plugin + + + + org.apache.maven.plugins + maven-pmd-plugin + + + + diff --git a/quarkus/src/main/java/de/neitzel/quarkus/util/GlobalRouteLogging.java b/quarkus/src/main/java/de/neitzel/quarkus/util/GlobalRouteLogging.java new file mode 100644 index 0000000..541d4be --- /dev/null +++ b/quarkus/src/main/java/de/neitzel/quarkus/util/GlobalRouteLogging.java @@ -0,0 +1,26 @@ +package de.neitzel.quarkus.util; + +import io.quarkus.vertx.web.RouteFilter; +import io.vertx.ext.web.RoutingContext; +import lombok.extern.slf4j.Slf4j; + +/** + * A utility class that logs details of all incoming routes within a Quarkus application using Vert.x Web. + * This logging is performed at the global level, meaning it applies to all routes handled by the application. + */ +@Slf4j +public class GlobalRouteLogging { + + /** + * Logs all details of the incoming route request, including the method and URI, as well as all headers present in the request. + * This method is designed to be used within a Vert.x Web application to log details for every incoming route globally. + * + * @param rc The routing context containing information about the current request and response. + */ + @RouteFilter(100) + void logAll(RoutingContext rc) { + log.info("⬅️ {} {}", rc.request().method(), rc.request().uri()); + rc.request().headers().forEach(h -> log.info("Header {}: {}", h.getKey(), h.getValue())); + rc.next(); // wichtig: weiterreichen + } +} diff --git a/quarkus/src/main/java/de/neitzel/quarkus/util/IncomingRequestFilter.java b/quarkus/src/main/java/de/neitzel/quarkus/util/IncomingRequestFilter.java new file mode 100644 index 0000000..2afcbe5 --- /dev/null +++ b/quarkus/src/main/java/de/neitzel/quarkus/util/IncomingRequestFilter.java @@ -0,0 +1,36 @@ +package de.neitzel.quarkus.util; + +import jakarta.annotation.Priority; +import jakarta.ws.rs.Priorities; +import jakarta.ws.rs.container.ContainerRequestContext; +import jakarta.ws.rs.container.ContainerRequestFilter; +import jakarta.ws.rs.container.PreMatching; +import jakarta.ws.rs.ext.Provider; +import lombok.extern.slf4j.Slf4j; + +/** + * A JAX-RS filter that logs the details of incoming HTTP requests before they are processed by the application. + * This filter is annotated with {@code @Provider} to indicate it is a JAX-RS extension, + * {@code @PreMatching} to specify it should run before the matching phase, and + * {@code @Slf4j} for automatic logging using Lombok's {@code @Log} annotation. + * It has a user priority level of {@link Priorities#USER}, which means it is executed after + * but still within the standard processing chain. + */ +@Provider +@PreMatching +@Slf4j +@Priority(Priorities.USER) +public class IncomingRequestFilter implements ContainerRequestFilter { + + /** + * Logs the details of incoming HTTP requests before they are processed by the application. + * This includes logging the request method and URI, as well as all headers present in the request. + * + * @param ctx The context of the incoming container request being filtered. + */ + @Override + public void filter(ContainerRequestContext ctx) { + log.info("⬅️ {} {}", ctx.getMethod(), ctx.getUriInfo().getRequestUri()); + ctx.getHeaders().forEach((k, v) -> log.info("Header {}: {}", k, v)); + } +} diff --git a/quarkus/src/main/java/de/neitzel/quarkus/util/LoggingRequestFilter.java b/quarkus/src/main/java/de/neitzel/quarkus/util/LoggingRequestFilter.java new file mode 100644 index 0000000..64c2399 --- /dev/null +++ b/quarkus/src/main/java/de/neitzel/quarkus/util/LoggingRequestFilter.java @@ -0,0 +1,24 @@ +package de.neitzel.quarkus.util; + +import jakarta.ws.rs.client.ClientRequestContext; +import jakarta.ws.rs.client.ClientRequestFilter; +import jakarta.ws.rs.ext.Provider; +import lombok.extern.slf4j.Slf4j; + +/** + * A client-side filter that logs the details of HTTP requests before they are sent. + */ +@Slf4j +@Provider +public class LoggingRequestFilter implements ClientRequestFilter { + /** + * Logs the details of HTTP requests before they are sent. + * + * @param requestContext The context of the client request being filtered. + */ + @Override + public void filter(ClientRequestContext requestContext) { + log.info("➡️ Calling {} {}", requestContext.getMethod(), requestContext.getUri()); + requestContext.getHeaders().forEach((k, v) -> log.info("Header {}: {}", k, v)); + } +}