Package org.eclipse.jetty.start
Class BaseHome
- java.lang.Object
-
- org.eclipse.jetty.start.BaseHome
-
public class BaseHome extends java.lang.ObjectFile 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 java.lang.StringJETTY_BASEstatic java.lang.StringJETTY_HOME
-
Constructor Summary
Constructors Constructor Description BaseHome()BaseHome(java.lang.String[] cmdLine)BaseHome(CommandLineConfigSource cmdLineSource)BaseHome(ConfigSources sources)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetBase()java.nio.file.PathgetBasePath()java.nio.file.PathgetBasePath(java.lang.String path)Create aPathreference to some content in"${jetty.base}"ConfigSourcesgetConfigSources()java.lang.StringgetHome()java.nio.file.PathgetHomePath()java.nio.file.PathgetPath(java.lang.String path)Get a specific path reference.java.util.List<java.nio.file.Path>getPaths(java.lang.String pattern)Get a List ofPaths from a provided pattern.java.util.List<java.nio.file.Path>getPaths(java.nio.file.Path dir, int searchDepth, java.lang.String pattern)Search specified Path with pattern and return hitsbooleanisBaseDifferent()java.lang.StringtoShortForm(java.io.File path)Convenience method fortoShortForm(file.toPath())java.lang.StringtoShortForm(java.lang.String path)Replace/Shorten arbitrary path with property strings"${jetty.home}"or"${jetty.base}"where appropriate.java.lang.StringtoShortForm(java.nio.file.Path path)Replace/Shorten arbitrary path with property strings"${jetty.home}"or"${jetty.base}"where appropriate.
-
-
-
Field Detail
-
JETTY_BASE
public static final java.lang.String JETTY_BASE
- See Also:
- Constant Field Values
-
JETTY_HOME
public static final java.lang.String JETTY_HOME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseHome
public BaseHome() throws java.io.IOException- Throws:
java.io.IOException
-
BaseHome
public BaseHome(java.lang.String[] cmdLine) throws java.io.IOException- Throws:
java.io.IOException
-
BaseHome
public BaseHome(CommandLineConfigSource cmdLineSource) throws java.io.IOException
- Throws:
java.io.IOException
-
BaseHome
public BaseHome(ConfigSources sources)
-
-
Method Detail
-
getBase
public java.lang.String getBase()
-
getBasePath
public java.nio.file.Path getBasePath()
-
getBasePath
public java.nio.file.Path getBasePath(java.lang.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 java.lang.String getHome()
-
getHomePath
public java.nio.file.Path getHomePath()
-
getPath
public java.nio.file.Path getPath(java.lang.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 java.util.List<java.nio.file.Path> getPaths(java.nio.file.Path dir, int searchDepth, java.lang.String pattern) throws java.io.IOExceptionSearch 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:
java.io.IOException- if unable to search the path
-
getPaths
public java.util.List<java.nio.file.Path> getPaths(java.lang.String pattern) throws java.io.IOExceptionGet 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:
java.io.IOException- if error during search operation
- If the pattern starts with "regex:" or "glob:" then a standard
-
isBaseDifferent
public boolean isBaseDifferent()
-
toShortForm
public java.lang.String toShortForm(java.io.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 java.lang.String toShortForm(java.nio.file.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 java.lang.String toShortForm(java.lang.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
-
-