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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ClassLoader
createClassLoader
(Collection<URL> urls) Create a classloader for the specified archives.protected abstract Archive
Return the archive being launched ornull
if there is no archive.Returns the archives that will be used to construct the class path.protected String
Return the path prefix for relevant entries in the archive.protected abstract String
Returns the main class that should be launched.protected boolean
Returns if the launcher is running in an exploded mode.protected boolean
Determine if the specified entry is a nested item that should be added to the classpath.protected boolean
protected boolean
protected void
launch
(ClassLoader classLoader, String mainClassName, String[] args) Launch the application given the archive file and a fully configured classloader.protected void
Launch 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 returnstrue
then 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 ornull
if 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:
true
if the entry is a nested item (jar or directory)
-
isLibraryFileOrClassesDirectory
-
isIncludedOnClassPathAndNotIndexed
-