Package org.eclipse.jetty.start
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseHome.SearchDir
-
Field Summary
Fields Modifier and Type Field Description static StringJETTY_BASEstatic StringJETTY_HOME
-
Constructor Summary
Constructors Constructor Description BaseHome()BaseHome(String[] cmdLine)BaseHome(CommandLineConfigSource cmdLineSource)BaseHome(ConfigSources sources)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetBase()PathgetBasePath()PathgetBasePath(String path)Create aPathreference to some content in"${jetty.base}"ConfigSourcesgetConfigSources()StringgetHome()PathgetHomePath()PathgetPath(String path)Get a specific path reference.List<Path>getPaths(String pattern)Get a List ofPaths from a provided pattern.List<Path>getPaths(Path dir, int searchDepth, String pattern)Search specified Path with pattern and return hitsbooleanisBaseDifferent()StringtoShortForm(File path)Convenience method fortoShortForm(file.toPath())StringtoShortForm(String path)Replace/Shorten arbitrary path with property strings"${jetty.home}"or"${jetty.base}"where appropriate.StringtoShortForm(Path path)Replace/Shorten arbitrary path with property strings"${jetty.home}"or"${jetty.base}"where appropriate.
-
-
-
Field Detail
-
JETTY_BASE
public static final String JETTY_BASE
- See Also:
- Constant Field Values
-
JETTY_HOME
public static final String JETTY_HOME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseHome
public BaseHome() throws IOException- Throws:
IOException
-
BaseHome
public BaseHome(String[] cmdLine) throws IOException
- Throws:
IOException
-
BaseHome
public BaseHome(CommandLineConfigSource cmdLineSource) throws IOException
- Throws:
IOException
-
BaseHome
public BaseHome(ConfigSources sources)
-
-
Method Detail
-
getBase
public String getBase()
-
getBasePath
public Path getBasePath()
-
getBasePath
public Path getBasePath(String path)
Create aPathreference 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.
- If provided path is an absolute reference., and exists, return that reference
- If exists relative to
${jetty.base}, return that reference - If exists relative to and
include-jetty-dirlocations, return that reference - If exists relative to
${jetty.home}, return that reference - Return standard
Pathreference obtained fromFileSystem.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 fromsearchDepth- the number of directories deep to perform the searchpattern- 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 ofPaths from a provided pattern.Resolution Steps:
- If the pattern starts with "regex:" or "glob:" then a standard
PathMatcheris built usingFileSystem.getPathMatcher(String)as a file search. - If pattern starts with a known filesystem root (using information from
FileSystem.getRootDirectories()) then this is assumed to be a absolute file system pattern. - All other patterns are treated as relative to BaseHome information:
- Search ${jetty.home} first
- 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 underlibending in-dev.jar etc/jetty.xml- Relative pattern, no glob, search for
${jetty.home}/etc/jetty.xmlthen${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).
SeeFileSystem.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
- If the pattern starts with "regex:" or "glob:" then a standard
-
isBaseDifferent
public boolean isBaseDifferent()
-
toShortForm
public String toShortForm(File path)
Convenience method fortoShortForm(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
-
-