Package org.springframework.boot.loader
Class Launcher
- java.lang.Object
- org.springframework.boot.loader.Launcher
- Direct Known Subclasses:
ExecutableArchiveLauncher
,PropertiesLauncher
public abstract class Launcher extends Object
Base class for launchers that can start an application with a fully configured classpath backed by one or moreArchive
s.
Constructor Summary
Constructors Constructor Description Launcher()
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Archive
createArchive()
protected ClassLoader
createClassLoader(URL[] urls)
Create a classloader for the specified URLs.protected ClassLoader
createClassLoader(List<Archive> archives)
Create a classloader for the specified archives.protected MainMethodRunner
createMainMethodRunner(String mainClass, String[] args, ClassLoader classLoader)
Create theMainMethodRunner
used to launch the application.protected abstract List<Archive>
getClassPathArchives()
Returns the archives that will be used to construct the class path.protected abstract String
getMainClass()
Returns the main class that should be launched.protected void
launch(String[] args)
Launch the application.protected void
launch(String[] args, String mainClass, ClassLoader classLoader)
Launch the application given the archive file and a fully configured classloader.
Constructor Detail
Launcher
public Launcher()
Method Detail
launch
protected void launch(String[] args) throws Exception
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
protected ClassLoader createClassLoader(List<Archive> archives) throws Exception
Create a classloader for the specified archives.- Parameters:
archives
- the archives- Returns:
- the classloader
- Throws:
Exception
- if the classloader cannot be created
createClassLoader
protected ClassLoader createClassLoader(URL[] urls) throws Exception
Create a classloader for the specified URLs.- Parameters:
urls
- the URLs- Returns:
- the classloader
- Throws:
Exception
- if the classloader cannot be created
launch
protected void launch(String[] args, String mainClass, ClassLoader classLoader) throws Exception
Launch the application given the archive file and a fully configured classloader.- Parameters:
args
- the incoming argumentsmainClass
- the main class to runclassLoader
- the classloader- Throws:
Exception
- if the launch fails
createMainMethodRunner
protected MainMethodRunner createMainMethodRunner(String mainClass, String[] args, ClassLoader classLoader)
Create theMainMethodRunner
used to launch the application.- Parameters:
mainClass
- the main classargs
- the incoming argumentsclassLoader
- the classloader- Returns:
- the main method runner
getMainClass
protected abstract String getMainClass() throws Exception
Returns the main class that should be launched.- Returns:
- the name of the main class
- Throws:
Exception
- if the main class cannot be obtained
getClassPathArchives
protected abstract List<Archive> getClassPathArchives() throws Exception
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
createArchive
protected final Archive createArchive() throws Exception
- Throws:
Exception