Package org.springframework.boot.cli.app
Class SpringApplicationLauncher
- java.lang.Object
- org.springframework.boot.cli.app.SpringApplicationLauncher
public class SpringApplicationLauncher extends Object
A launcher forSpringApplication
or aSpringApplication
subclass. The class that is used can be configured using the System propertyspring.application.class.name
or theSPRING_APPLICATION_CLASS_NAME
environment variable. Uses reflection to allow the launching code to exist in a separate ClassLoader from the application code.- Since:
- 1.2.0
- See Also:
System.getProperty(String)
,System.getenv(String)
Constructor Summary
Constructors Constructor Description SpringApplicationLauncher(ClassLoader classLoader)
Creates a new launcher that will use the givenclassLoader
to load the configuredSpringApplication
class.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
getEnvironmentVariable(String name)
Object
launch(Class<?>[] sources, String[] args)
Launches the application created using the givensources
.
Constructor Detail
SpringApplicationLauncher
public SpringApplicationLauncher(ClassLoader classLoader)
Creates a new launcher that will use the givenclassLoader
to load the configuredSpringApplication
class.- Parameters:
classLoader
- theClassLoader
to use
Method Detail
launch
public Object launch(Class<?>[] sources, String[] args) throws Exception
Launches the application created using the givensources
. The application is launched with the givenargs
.- Parameters:
sources
- the sources for the applicationargs
- the args for the application- Returns:
- the application's
ApplicationContext
- Throws:
Exception
- if the launch fails
getEnvironmentVariable
protected String getEnvironmentVariable(String name)