Primavera

Contents

Resources

Contact

SaaS Developer · Renaissance Edition

Renaissance Artwork

Spring

My simple learning archive covering the Spring ecosystem and modern Java.

VOLUME I · PART IFRAMEWORK HIERARCHY

The Spring Ecosystem

The complete module topology powering enterprise Java applications from core IoC container to cloud gateway routing.

spring-ecosystem-hierarchy.ascii
[ THE SPRING ECOSYSTEM ]├── Spring Boot .........──> Pre-configures and runs applications instantly│   ├── spring-boot ............... (Core lifecycle, runner setup, and banner logic)│   ├── spring-boot-autoconfigure . (The "magic" engine that auto-wires beans)│   ├── spring-boot-actuator ...... (Production-ready monitoring & health endpoints)│   └── spring-boot-starters ...... (Pre-packaged dependency bundles like starter-web)├── Spring Data .........──> Simplifies SQL/NoSQL database interactions│   ├── spring-data-commons ....... (The core interfaces & repository abstractions)│   ├── spring-data-jpa ........... (Relational database management via Hibernate)│   ├── spring-data-mongodb ....... (NoSQL document storage support)│   └── spring-data-redis ......... (Key-value memory cache support)├── Spring Security ....──> Handles authentication, authorization, and safety│   ├── spring-security-core ...... (Core authentication & access control logic)│   ├── spring-security-web ....... (HTTP security filters and URL blocking rules)│   ├── spring-security-config .... (The Java configuration fluent API engine)│   └── spring-security-crypto .... (Password hashing, salts, and encryption tools)├── Spring Cloud .......──> Manages microservices and distributed systems│   ├── spring-cloud-config ....... (Centralized server for managing environment properties)│   ├── spring-cloud-gateway ...... (API routing, security, and traffic throttling)│   └── spring-cloud-stream ....... (Event-driven messaging abstracting Kafka/RabbitMQ)├── Spring Batch .......──> Processes massive volumes of background data│   ├── spring-batch-infrastructure (Low-level readers, writers, and retry mechanisms)│   └── spring-batch-core ......... (Job execution lifecycle, steps, and restart logic)├── Spring Integration .──> Connects distinct enterprise systems together│   ├── spring-integration-core ... (The messaging pipelines, gateways, and channels)│   └── spring-integration-file ... (Specific adapters to stream external files/data pools)├── Spring Shell .......──> Builds terminal-based command-line tools│   ├── spring-shell-core ......... (The terminal parsing engine and command UI)│   └── spring-shell-standard ..... (Built-in CLI commands like help, clear, and exit)└── Spring Framework ...──> The foundation engine managing the core mechanics    ├── spring-aop ................ (Aspect-Oriented Programming for logging/transactions)    ├── spring-web ................ (Web integration, REST clients, and HTTP filters)    ├── spring-context ............ (The Application Context registry holding beans)    └── spring-core ............... (The absolute bedrock IoC and DI container utils)
Spring Framework 6.x & Spring Boot 3.3.xPart I
VOLUME I · PART IIDIRECTORY ANATOMY

Folder Structure Blueprint

Standard production layout for Maven & Spring Boot applications isolating source packages, static assets, configs, and build targets.

spring-boot-project-structure.tree
[organizationProject]/
# The root project folder
├── .mvn/
# Hidden folder storing Maven Wrapper configurations
│ └── wrapper/
│ ├── maven-wrapper.jar
# Tiny binary that downloads/boots the Maven version
│ └── maven-wrapper.properties
# Properties file configuring the exact target Maven version
├── src/
# Source code root
│ ├── main/
# Production-ready code and assets
│ │ ├── java/
# Root directory for all Java source code packages
│ │ │ └── [topLevelDomain]/
│ │ │ └── [organizationProject]/
│ │ │ └── [moduleName]/
# Main application package matching Group + Artifact
│ │ │ └── Application.java
# Main entry point class with main method
│ │ └── resources/
# Non-code assets used by your application
│ │ ├── application.properties
# Main configuration file (ports, DB URLs, log levels)
│ │ ├── static/
# Folder for static web frontend assets (HTML, CSS, JS)
│ │ └── templates/
# Folder for server-side UI engine templates (Thymeleaf)
│ └── test/
# Test code root (isolated from production build)
│ └── java/
# Root directory for unit tests and integration tests
├── mvnw
# Executable Linux/macOS shell script for Maven Wrapper
├── mvnw.cmd
# Executable Windows batch script for Maven Wrapper
├── pom.xml
# Core configuration file managing versions & dependencies
└── target/
# Autogenerated build output containing compiled .class & JARs
Maven & Gradle Packaging StandardsPart II
VOLUME I · PART IIIREQUEST LIFECYCLE

Spring Web MVC Mechanics

Internal request dispatching via DispatcherServlet, HandlerMapping, and Jackson HttpMessageConverters.

spring-mvc-request-lifecycle.flow
STEP 01Client / Consumer

HTTP Request

Client sends HTTP request to the Spring Boot application server.

GET /api/v1/products/42
STEP 02Front Controller

DispatcherServlet

Central Front Controller servlet receives the raw HTTP request and initiates dispatching.

Central Interceptor
STEP 03Route Registry

HandlerMapping

Matches URL pattern & HTTP method against registered @RequestMapping handler methods.

Finds @RestController
STEP 04Handler & Service Layer

Controller Execution

Invokes controller method, validates request DTOs, and queries @Service / @Repository layers.

@GetMapping Execution
STEP 05Jackson Serializer

HttpMessageConverter

Jackson converts returned ProductDTO domain model into raw JSON bytes.

Java Record -> JSON
STEP 06Servlet Response

HTTP 200 Response

DispatcherServlet flushes response stream back to client with HTTP 200 OK headers.

application/json
INSPECTOR · STEP 01HTTP Request (Client / Consumer)
Click any step above to inspect
GET /api/v1/products/42 HTTP/1.1
Host: api.primavera.dev
Accept: application/json
DispatcherServlet & Jackson HttpMessageConvertersPart III
PILLAR IModel (M)

Data & State Representation

Holds application state, database entities (@Entity), and immutable Data Transfer Objects (Java Records).

public record ProductDTO(
  Long id, String name, BigDecimal price
)
PILLAR IIView (V)

Presentation Serialization

Renders Model for consumer. In REST APIs, Spring uses Jackson2HttpMessageConverter to convert objects to JSON.

{
  "id": 42,
  "name": "Spring Boot Guide"
}
PILLAR IIIController (C)

Routing & Orchestration

Intercepts HTTP requests via @RestController, validates payloads with @Valid, & delegates to Service layer.

@GetMapping("/products/{id}")
public ProductDTO getProduct(...)
VOLUME II — LANGUAGE INNOVATION

Modern Java 21+ Platform

Official Java 21+ Documentation
SECTION IVJava 21 LTS

Virtual Threads (Project Loom)

High-throughput, lightweight threads managed by the JVM instead of OS threads. Million-thread concurrency with traditional synchronous thread-per-request code.

Code SpecificationJava 21 LTS
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
    IntStream.range(0, 10_000).forEach(i -> {
        executor.submit(() -> {
            Thread.sleep(Duration.ofSeconds(1));
            return i;
        });
    });
}
SECTION VJava 21 LTS

Generational ZGC (Low-Latency)

Scalable zero-pause garbage collector capable of handling terabyte heaps with sub-millisecond maximum pause times.

Code SpecificationJava 21 LTS
# Enable Generational ZGC in Java 21+
java -XX:+UseZGC -XX:+ZGenerational -jar primavera-app.jar
SECTION VIJava 21 LTS

Pattern Matching & Record Patterns

Deconstruct records directly in switch expressions with guards, enabling safe functional programming and algebraic type handling.

Code SpecificationJava 21 LTS
static String formatValue(Object obj) {
    return switch (obj) {
        case Point(int x, int y) -> "Point at (%d, %d)".formatted(x, y);
        case String s when s.length() > 5 -> "Long string: " + s;
        case Integer i -> "Number: " + i;
        default -> "Unknown";
    };
}
SECTION VIIJava 17 / 21

Sealed Classes & Exhaustive Switches

Restrict subclassing to known permits, guaranteeing compile-time safety and eliminating the need for fallback default cases in switch statements.

Code SpecificationJava 21 LTS
public sealed interface PaymentMethod permits CreditCard, Crypto, BankTransfer {}

public record CreditCard(String cardNumber) implements PaymentMethod {}
public record Crypto(String walletAddress) implements PaymentMethod {}
public record BankTransfer(String iban) implements PaymentMethod {}