|
Spring for Apache Hadoop | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.yarn.launch.AbstractCommandLineRunner<T>
T
- the type of bean to runpublic abstract class AbstractCommandLineRunner<T>
Base implementation used for launching a Spring Application Context and executing a bean using a command line. This command line runner is meant to be used from a subclass.
The general idea of this launcher concept is to provide a way to define context config location, bean name for execution handling, options and a arguments. Possible examples are:
contextConfig contextConfig,childContextConfig beanIdentifier contextConfig beanIdentifier <arguments> contextConfig <options> beanIdentifier contextConfig <options> beanIdentifier <arguments> <options> contextConfig <options> beanIdentifier <arguments>
Constructor Summary | |
---|---|
AbstractCommandLineRunner()
|
Method Summary | |
---|---|
protected void |
doMain(java.lang.String[] args)
Main method visible to sub-classes. |
void |
exit(int status)
Exit method wrapping handling through SystemExiter . |
protected org.springframework.context.ConfigurableApplicationContext |
getApplicationContext(java.lang.String configLocation)
Gets the Application Context. |
protected org.springframework.context.ConfigurableApplicationContext |
getChildApplicationContext(java.lang.String configLocation,
org.springframework.context.ConfigurableApplicationContext parent)
Gets the Application Context. |
protected java.lang.String |
getChildContextConfigPath(java.lang.String path)
Allows subclass to modify parsed context configuration path. |
protected java.lang.String |
getContextConfigPath(java.lang.String path)
Allows subclass to modify parsed context configuration path. |
protected abstract java.lang.String |
getDefaultBeanIdentifier()
Gets a default bean id which is used to resolve the instance from an Application Context. |
static java.lang.String |
getErrorMessage()
Gets the static error message set for this class. |
protected java.util.List<java.lang.String> |
getValidOpts()
Gets the list of valid option arguments. |
protected abstract ExitStatus |
handleBeanRun(T bean,
java.lang.String[] parameters,
java.util.Set<java.lang.String> opts)
Handles the execution of a bean after Application Context(s) has been initialized. |
static void |
presetSystemExiter(SystemExiter systemExiter)
Sets the SystemExiter . |
protected int |
start(java.lang.String configLocation,
java.lang.String masterIdentifier,
java.lang.String childConfigLocation,
java.lang.String[] parameters,
java.util.Set<java.lang.String> opts)
Builds the Application Context(s) and handles 'execution' of a bean. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractCommandLineRunner()
Method Detail |
---|
public static java.lang.String getErrorMessage()
public static void presetSystemExiter(SystemExiter systemExiter)
SystemExiter
. Useful
for testing.
systemExiter
- the system exiterprotected abstract ExitStatus handleBeanRun(T bean, java.lang.String[] parameters, java.util.Set<java.lang.String> opts)
It is implementors responsibility to decide what to do with the given bean since this class only knows the typed bean instance.
bean
- the bean instanceparameters
- the parametersopts
- the options
protected abstract java.lang.String getDefaultBeanIdentifier()
protected java.util.List<java.lang.String> getValidOpts()
When overriding valid options make sure that options doesn't match anything else planned to be used in a command line. i.e. usually it's advised to prefix options with '-' character.
protected java.lang.String getContextConfigPath(java.lang.String path)
Default implementation just returns the given without modifying it.
path
- the parsed config path
protected java.lang.String getChildContextConfigPath(java.lang.String path)
Default implementation just returns the given without modifying it.
path
- the parsed config path
protected int start(java.lang.String configLocation, java.lang.String masterIdentifier, java.lang.String childConfigLocation, java.lang.String[] parameters, java.util.Set<java.lang.String> opts)
configLocation
- the main context config locationmasterIdentifier
- the bean identifierchildConfigLocation
- the child context config locationparameters
- the parametersopts
- the options
protected org.springframework.context.ConfigurableApplicationContext getApplicationContext(java.lang.String configLocation)
configLocation
- the context config location
protected org.springframework.context.ConfigurableApplicationContext getChildApplicationContext(java.lang.String configLocation, org.springframework.context.ConfigurableApplicationContext parent)
configLocation
- the context config locationparent
- the parent context
public void exit(int status)
SystemExiter
. This method mostly
exist order to not do a real exit on
a unit tests.
status
- the exit codeprotected void doMain(java.lang.String[] args)
args
- the Arguments
|
Spring for Apache Hadoop | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |