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
-
Constructor Summary
Constructors -
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 abstract String
Returns the main class that should be launched.protected boolean
Returns if the launcher is running in an exploded mode.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.
-
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
-