forge-kit

forge-common

Overview

forge-common contains shared utilities and primitives used across Forge Kit modules.

It focuses on consistency, correctness, and developer ergonomics rather than feature richness.


Key Features


Design Principles


Typical Use Cases


Usage

forge-common provides utilities that are automatically wired in when included as a dependency. No additional configuration is required.

Validation Exception Mapper

The ValidationExceptionMapper automatically converts ConstraintViolationException to 400 Bad Request responses. Simply use Jakarta Bean Validation annotations:

@POST
@Path("/users")
public Response createUser(@Valid CreateUserRequest request) {
    // If validation fails, a 400 response is automatically returned
    return Response.ok().build();
}

record CreateUserRequest(
    @NotBlank String name,
    @Email String email
) {}

Method Entry Logging

The LogMethodEntryInterceptor automatically logs method entry when methods are annotated with @LogMethodEntry:

@LogMethodEntry
public Response getData() {
    // Logs: "DataResource#getData"
    return Response.ok().build();
}

@LogMethodEntry(message = "for user: %s")
public Response getUser(String userId) {
    // Logs: "DataResource#getUser for user: {userId}"
    return Response.ok().build();
}

Both interceptors are automatically registered - no additional wiring is required.


Examples

See: examples/forge-common

Code examples demonstrate: