Class BaseHome

java.lang.Object
org.eclipse.jetty.start.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}"
      Parameters:
      path - the path to reference
      Returns:
      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)
      Parameters:
      path - the path to get.
      Returns:
      the path reference.
    • getPaths

      public List<Path> getPaths(Path dir, int searchDepth, String pattern) throws IOException
      Search specified Path with pattern and return hits
      Parameters:
      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)
      Returns:
      the list of Paths found
      Throws:
      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:

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

      Notes:

      • 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
      Parameters:
      pattern - the pattern to search.
      Returns:
      the collection of paths found
      Throws:
      IOException - if error during search operation
    • isBaseDifferent

      public boolean isBaseDifferent()
    • toShortForm

      public String toShortForm(File path)
      Convenience method for toShortForm(file.toPath())
      Parameters:
      path - the path to shorten
      Returns:
      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.
      Parameters:
      path - the path to shorten
      Returns:
      the potentially shortened path
    • toShortForm

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