Class BaseHome


public class BaseHome extends Object
File access for ${jetty.home}, ${jetty.base}, directories.

By default, both ${jetty.home} and ${jetty.base} are the same directory, but they can point at different directories.

The ${jetty.home} directory is where the main Jetty binaries and default configuration is housed.

The ${jetty.base} directory is where the execution specific configuration and webapps are obtained from.

  • Field Details

  • Constructor Details

  • Method Details

    • getBase

      public String getBase()
    • getBasePath

      public Path getBasePath()
    • getBasePath

      public Path getBasePath(String path)
      Create a Path reference to some content in "${jetty.base}"
      path - the path to reference
      the file reference
    • getConfigSources

      public ConfigSources getConfigSources()
    • getHome

      public String getHome()
    • getHomePath

      public Path getHomePath()
    • getPath

      public Path getPath(String path)
      Get a specific path reference.

      Path references are searched based on the config source search order.

      1. If provided path is an absolute reference., and exists, return that reference
      2. If exists relative to ${jetty.base}, return that reference
      3. If exists relative to and include-jetty-dir locations, return that reference
      4. If exists relative to ${jetty.home}, return that reference
      5. Return standard Path reference obtained from FileSystem.getPath(String, String...) (no exists check performed)
      path - the path to get.
      the path reference.
    • getPaths

      public List<Path> getPaths(Path dir, int searchDepth, String pattern) throws IOException
      Search specified Path with pattern and return hits
      dir - the path to a directory to start search from
      searchDepth - the number of directories deep to perform the search
      pattern - the raw pattern to use for the search (must be relative)
      the list of Paths found
      IOException - if unable to search the path
    • getPaths

      public List<Path> getPaths(String pattern) throws IOException
      Get a List of Paths from a provided pattern.

      Resolution Steps:

      1. If the pattern starts with "regex:" or "glob:" then a standard PathMatcher is built using FileSystem.getPathMatcher(String) as a file search.
      2. If pattern starts with a known filesystem root (using information from FileSystem.getRootDirectories()) then this is assumed to be a absolute file system pattern.
      3. All other patterns are treated as relative to BaseHome information:
        1. Search ${jetty.home} first
        2. Search ${jetty.base} for overrides

      Pattern examples:

      Relative pattern, not recursive, search ${jetty.home} then ${jetty.base} for lib/logging/*.jar content
      Relative pattern, recursive search ${jetty.home} then ${jetty.base} for files under lib ending in -dev.jar
      Relative pattern, no glob, search for ${jetty.home}/etc/jetty.xml then ${jetty.base}/etc/jetty.xml
      PathMapper pattern, glob, search /opt/app/common/ for *-corp.jar


      • FileSystem case sensitivity is implementation specific (eg: linux is case-sensitive, windows is case-insensitive).
        See FileSystem.getPathMatcher(String) for more details
      • Pattern slashes are implementation neutral (use '/' always and you'll be fine)
      • Recursive searching is limited to 30 levels deep (not configurable)
      • File System loops are detected and skipped
      pattern - the pattern to search.
      the collection of paths found
      IOException - if error during search operation
    • isBaseDifferent

      public boolean isBaseDifferent()
    • toShortForm

      public String toShortForm(File path)
      Convenience method for toShortForm(file.toPath())
      path - the path to shorten
      the short form of the path as a String
    • toShortForm

      public String toShortForm(Path path)
      Replace/Shorten arbitrary path with property strings "${jetty.home}" or "${jetty.base}" where appropriate.
      path - the path to shorten
      the potentially shortened path
    • toShortForm

      public String toShortForm(String path)
      Replace/Shorten arbitrary path with property strings "${jetty.home}" or "${jetty.base}" where appropriate.
      path - the path to shorten
      the potentially shortened path