Added Quarkus util classes.

This commit is contained in:
Konrad Neitzel 2025-11-29 19:00:47 +01:00
parent 5798955c65
commit 7d16122e9e
6 changed files with 150 additions and 4 deletions

View File

@ -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.

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@ -18,6 +18,7 @@
<module>net</module>
<module>log4j</module>
<module>fx-example</module>
<module>quarkus</module>
</modules>
<properties>

59
quarkus/pom.xml Normal file
View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.neitzel.lib</groupId>
<artifactId>neitzellib</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>quarkus</artifactId>
<properties>
<!-- Application Properties -->
<link.name>${project.artifactId}</link.name>
<launcher>${project.artifactId}</launcher>
<appName>${project.artifactId}</appName>
<jar.filename>${project.artifactId}-${project.version}</jar.filename>
<quarkus.platform.version>3.30.1</quarkus.platform.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/io.quarkus/quarkus-core -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
<version>${quarkus.platform.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
<version>${quarkus.platform.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-routes</artifactId>
<version>${quarkus.platform.version}</version>
</dependency>
</dependencies>
<build>
<finalName>${jar.filename}</finalName>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -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
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}