Package org.springframework.boot.loader
Class Launcher
java.lang.Object
org.springframework.boot.loader.Launcher
- Direct Known Subclasses:
ExecutableArchiveLauncher,PropertiesLauncher
Base class for launchers that can start an application with a fully configured
classpath backed by one or more
Archives.- Since:
- 1.0.0
- Author:
- Phillip Webb, Dave Syer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final Archiveprotected ClassLoadercreateClassLoader(URL[] urls) Create a classloader for the specified URLs.protected ClassLoadercreateClassLoader(Iterator<Archive> archives) Create a classloader for the specified archives.protected MainMethodRunnercreateMainMethodRunner(String mainClass, String[] args, ClassLoader classLoader) Create theMainMethodRunnerused to launch the application.protected ArchiveReturn the root archive.Returns the archives that will be used to construct the class path.protected abstract StringReturns the main class that should be launched.protected booleanReturns if the launcher is running in an exploded mode.protected voidLaunch the application.protected voidlaunch(String[] args, String launchClass, ClassLoader classLoader) Launch the application given the archive file and a fully configured classloader.
-
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:
archives- the archives- Returns:
- the classloader
- Throws:
Exception- if the classloader cannot be created- Since:
- 2.3.0
-
createClassLoader
Create a classloader for the specified URLs.- Parameters:
urls- the URLs- Returns:
- the classloader
- Throws:
Exception- if the classloader cannot be created
-
launch
Launch the application given the archive file and a fully configured classloader.- Parameters:
args- the incoming argumentslaunchClass- the launch class to runclassLoader- the classloader- Throws:
Exception- if the launch fails
-
createMainMethodRunner
protected MainMethodRunner createMainMethodRunner(String mainClass, String[] args, ClassLoader classLoader) Create theMainMethodRunnerused to launch the application.- Parameters:
mainClass- the main classargs- the incoming argumentsclassLoader- the classloader- Returns:
- the main method runner
-
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
-
getClassPathArchivesIterator
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- Since:
- 2.3.0
-
createArchive
- Throws:
Exception
-
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.
- Since:
- 2.3.0
-
getArchive
Return the root archive.- Returns:
- the root archive
- Since:
- 2.3.1
-