Class CatalinaBaseGenerator

java.lang.Object
io.github.rajendarreddyj.tomcat.config.CatalinaBaseGenerator

public final class CatalinaBaseGenerator extends Object
Generates a custom CATALINA_BASE directory with modified server.xml for port configuration. This allows running Tomcat with custom ports without modifying the original installation.
Since:
1.0.0
Author:
rajendarreddyj
  • Method Details

    • generate

      public static void generate(Path catalinaHome, Path catalinaBase, int httpPort, String httpHost) throws IOException
      Generates a CATALINA_BASE directory with customized configuration.
      Parameters:
      catalinaHome - the CATALINA_HOME directory (original Tomcat installation)
      catalinaBase - the target CATALINA_BASE directory to create
      httpPort - the HTTP port to configure
      httpHost - the HTTP host/address to bind to
      Throws:
      IOException - if an I/O error occurs
    • isValidCatalinaBase

      public static boolean isValidCatalinaBase(Path catalinaBase)
      Checks if a CATALINA_BASE already exists and appears valid.
      Parameters:
      catalinaBase - the CATALINA_BASE path to check
      Returns:
      true if the directory exists and has required structure
    • hasCorrectPort

      public static boolean hasCorrectPort(Path catalinaBase, int expectedPort)
      Checks if a CATALINA_BASE has the correct HTTP port configured.
      Parameters:
      catalinaBase - the CATALINA_BASE path to check
      expectedPort - the expected HTTP port
      Returns:
      true if the HTTP connector port matches the expected port