Class Launcher
java.lang.Object
org.springframework.boot.loader.launch.Launcher
- Direct Known Subclasses:
ExecutableArchiveLauncher,PropertiesLauncher
Base class for launchers that can start an application with a fully configured
classpath.
- Since:
- 3.2.0
- Author:
- Phillip Webb, Dave Syer, Scott Frederick
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ClassLoadercreateClassLoader(Collection<URL> urls) Create a classloader for the specified archives.protected abstract ArchiveReturn the archive being launched ornullif there is no archive.Returns the archives that will be used to construct the class path.protected StringReturn the path prefix for relevant entries in the archive.protected abstract StringReturns the main class that should be launched.protected booleanReturns if the launcher is running in an exploded mode.protected booleanDetermine if the specified entry is a nested item that should be added to the classpath.protected booleanprotected booleanprotected voidlaunch(ClassLoader classLoader, String mainClassName, String[] args) Launch the application given the archive file and a fully configured classloader.protected voidLaunch the application.
-
Field Details
-
BOOT_CLASSPATH_INDEX_ATTRIBUTE
- See Also:
-
DEFAULT_CLASSPATH_INDEX_FILE_NAME
- See Also:
-
classPathIndex
protected org.springframework.boot.loader.launch.ClassPathIndexFile classPathIndex
-
-
Constructor Details
-
Launcher
public Launcher()
-
-
Method Details
-
launch
Launch the application. This method is the initial entry point that should be called by a subclasspublic static void main(String[] args)method.- Parameters:
args- the incoming arguments- Throws:
Exception- if the application fails to launch
-
createClassLoader
Create a classloader for the specified archives.- Parameters:
urls- the classpath URLs- Returns:
- the classloader
- Throws:
Exception- if the classloader cannot be created
-
launch
protected void launch(ClassLoader classLoader, String mainClassName, String[] args) throws Exception Launch the application given the archive file and a fully configured classloader.- Parameters:
classLoader- the classloadermainClassName- the main class to runargs- the incoming arguments- Throws:
Exception- if the launch fails
-
isExploded
protected boolean isExploded()Returns if the launcher is running in an exploded mode. If this method returnstruethen only regular JARs are supported and the additional URL and ClassLoader support infrastructure can be optimized.- Returns:
- if the jar is exploded.
-
getArchive
Return the archive being launched ornullif there is no archive.- Returns:
- the launched archive
-
getMainClass
Returns the main class that should be launched.- Returns:
- the name of the main class
- Throws:
Exception- if the main class cannot be obtained
-
getClassPathUrls
Returns the archives that will be used to construct the class path.- Returns:
- the class path archives
- Throws:
Exception- if the class path archives cannot be obtained
-
getEntryPathPrefix
Return the path prefix for relevant entries in the archive.- Returns:
- the entry path prefix
-
isIncludedOnClassPath
Determine if the specified entry is a nested item that should be added to the classpath.- Parameters:
entry- the entry to check- Returns:
trueif the entry is a nested item (jar or directory)
-
isLibraryFileOrClassesDirectory
-
isIncludedOnClassPathAndNotIndexed
-