Migration Deep Dive für 09 · Servlet und Web öffnen →
⌂ ÜbersichtAlle Vergleiche
Modul 09 · 100 % Codeabdeckung

Servlet und Web

Vollständiger Legacy-Modern-Vergleich aller Java-Klassen, Tests, Maven-POMs und relevanten Ressourcen dieses Moduls. Jede Datei ist genau einmal einer fachlich passenden Vergleichsgruppe zugeordnet.

4Legacy-Dateien
5Modern-Dateien
94 → 81Codezeilen
10/10vollständig erfasst

Fachliche Einordnung

Legacy

HttpServlet

Das Servlet schreibt Status, Content-Type und Response-Body direkt über HttpServletResponse.

Modern

Spring REST Controller

Der Controller gibt ein typisiertes Response-Objekt zurück; Serialisierung übernimmt Spring MVC.

Vergleichsfokus: Alle Dateien werden nach technischer Rolle und fachlicher Verantwortung gruppiert.
Wichtige Abgrenzung: One-to-many-Änderungen werden als Gruppe dargestellt; eine künstliche 1:1-Zuordnung wird vermieden.

Vollständige Abdeckungsmatrix

Die Ähnlichkeit ist eine technische Orientierung auf normalisiertem Quelltext. Sie ersetzt keine fachliche Bewertung.

VergleichsgruppeLegacy-DateienModern-DateienLegacy-ZeilenModern-ZeilenÄhnlichkeit
Build-Konfiguration11414237%
Bootstrap und Konfiguration12211321%
HTTP-Endpunkt und Test22322630%

Gemeinsame Modulstruktur

Das Pair-POM bindet die Legacy- und Modern-Submodule zusammen und gehört deshalb ebenfalls zur vollständigen Codeabdeckung.

Gemeinsam · 19 Zeilenpom.xml
<?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"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>at.aydin.academy</groupId>
        <artifactId>java-modernization-deep-dive</artifactId>
        <version>1.0.0</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <artifactId>09servletweb-pair</artifactId>
    <packaging>pom</packaging>
    <name>Servlet/Web: Legacy und Modern</name>
    <modules>
        <module>legacy</module>
        <module>modern</module>
    </modules>
</project>

Alle semantischen Codevergleiche

01Build-KonfigurationDirektvergleich · Legacy 41 / Modern 42 Zeilen · Ähnlichkeit 37%

Servlet- und Spring-Web-Abhängigkeiten werden verglichen.

Legacy-DateienModern-DateienEinordnung
pom.xmlpom.xmlDirektvergleich
Semantische Ähnlichkeit: 37%

Legacy

Legacy · 41 Zeilenlegacy/pom.xml
<?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"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>at.aydin.academy</groupId>
        <artifactId>09servletweb-pair</artifactId>
        <version>1.0.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>servlet-web-legacy</artifactId>
    <packaging>jar</packaging>
    <name>Servlet Web Legacy (Jetty 10 / javax)</name>
    <dependencies>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>${jetty10.version}</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
            <version>${jetty10.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>

        </plugins>
    </build>
</project>

Modern

Modern · 42 Zeilenmodern/pom.xml
<?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"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>at.aydin.academy</groupId>
        <artifactId>09servletweb-pair</artifactId>
        <version>1.0.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>servlet-web-modern</artifactId>
    <packaging>jar</packaging>
    <name>Servlet Web Modern (Spring MVC)</name>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
02Bootstrap und KonfigurationDirektvergleich · Legacy 21 / Modern 13 Zeilen · Ähnlichkeit 21%

Servlet-Container-Setup wird durch eingebetteten Boot-Server ersetzt.

Legacy-DateienModern-DateienEinordnung
ServletLegacyApplication.javaWebModernApplication.java
application.properties
Direktvergleich
Semantische Ähnlichkeit: 21%

Legacy

package at.aydin.lab.web.legacy;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

public final class ServletLegacyApplication {
    private ServletLegacyApplication() {
    }

    public static void main(String[] args) throws Exception {
        Server server = new Server(8083);
        ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/");
        context.addServlet(new ServletHolder(new StatusServlet()), "/status");
        server.setHandler(context);
        server.start();
        System.out.println("Legacy Servlet: http://localhost:8083/status");
        server.join();
    }
}

Modern

package at.aydin.lab.web.modern;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class WebModernApplication {
    public static void main(String[] args) {
        SpringApplication.run(WebModernApplication.class, args);
    }
}
03HTTP-Endpunkt und TestDirektvergleich · Legacy 32 / Modern 26 Zeilen · Ähnlichkeit 30%

Servlet-API und MVC-Controller samt Tests werden gegenübergestellt.

Legacy-DateienModern-DateienEinordnung
StatusServlet.java
StatusServletTest.java
StatusController.java
StatusControllerTest.java
Direktvergleich
Semantische Ähnlichkeit: 30%

Legacy

package at.aydin.lab.web.legacy;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class StatusServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setStatus(200);
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().write(statusJson());
    }

    // Design Pattern: Front Controller (kleine Demonstration)
    // Zweck: Ein zentraler Servlet-Endpunkt verarbeitet den HTTP-Aufruf.
    static String statusJson() {
        return "{\"status\":\"UP\",\"stack\":\"javax.servlet\"}";
    }
}
package at.aydin.lab.web.legacy;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;

class StatusServletTest {
    @Test
    void statusIsUp() {
        assertTrue(StatusServlet.statusJson().contains("UP"));
    }
}

Modern

package at.aydin.lab.web.modern;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

@RestController
// Design Pattern: Front Controller + MVC Controller
// Zweck: Spring MVC übernimmt Routing, Konvertierung und HTTP-Infrastruktur.
public class StatusController {
    @GetMapping("/status")
    public Map<String, String> status() {
        return Map.of("status", "UP", "stack", "Spring MVC / jakarta.servlet");
    }
}
package at.aydin.lab.web.modern;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

class StatusControllerTest {
    @Test
    void statusIsUp() {
        assertEquals("UP", new StatusController().status().get("status"));
    }
}
⌂ Cockpit