Package fish.payara.micro.boot.loader
Class Launcher
- java.lang.Object
-
- fish.payara.micro.boot.loader.Launcher
-
- Direct Known Subclasses:
ExecutableArchiveLauncher
public abstract class Launcher extends Object
Base class for launchers that can start an application with a fully configured classpath backed by one or moreArchives.- Author:
- Phillip Webb, Dave Syer
-
-
Constructor Summary
Constructors Constructor Description Launcher()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ArchivecreateArchive()protected ClassLoadercreateClassLoader(URL[] urls)Create a classloader for the specified URLs.protected ClassLoadercreateClassLoader(List<Archive> archives)Create a classloader for the specified archives.protected MainMethodRunnercreateMainMethodRunner(String mainClass, String method, String[] args, ClassLoader classLoader)Create theMainMethodRunnerused to launch the application.protected abstract List<Archive>getClassPathArchives()Returns the archives that will be used to construct the class path.protected abstract StringgetMainClass()Returns the main class that should be launched.protected Objectlaunch(String method, String[] args)Launch the application.protected Objectlaunch(String method, String[] args, String mainClass, ClassLoader classLoader)Launch the application given the archive file and a fully configured classloader.
-
-
-
Method Detail
-
launch
protected Object launch(String method, 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 Object launch(String method, 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 method, 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
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
-
-