public abstract class MainSupport extends ServiceSupport
Modifier and Type | Class and Description |
---|---|
class |
MainSupport.Option |
class |
MainSupport.ParameterOption |
Modifier and Type | Field and Description |
---|---|
protected List<CamelContext> |
camelContexts |
protected ProducerTemplate |
camelTemplate |
protected AtomicBoolean |
completed |
protected static int |
DEFAULT_EXIT_CODE |
protected long |
duration |
protected int |
durationHitExitCode |
protected AtomicInteger |
exitCode |
protected boolean |
hangupInterceptorEnabled |
protected CountDownLatch |
latch |
protected List<MainListener> |
listeners |
protected static org.slf4j.Logger |
LOG |
protected List<MainSupport.Option> |
options |
protected String |
routeBuilderClasses |
protected List<RouteBuilder> |
routeBuilders |
protected TimeUnit |
timeUnit |
protected boolean |
trace |
protected static int |
UNINITIALIZED_EXIT_CODE |
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Modifier | Constructor and Description |
---|---|
protected |
MainSupport() |
Modifier and Type | Method and Description |
---|---|
void |
addMainListener(MainListener listener)
Adds a
MainListener to receive callbacks when the main is started or stopping |
void |
addOption(MainSupport.Option option) |
void |
addRouteBuilder(RouteBuilder routeBuilder) |
protected void |
afterStart()
Callback to run custom logic after CamelContext has been started.
|
protected void |
afterStop()
Callback to run custom logic after CamelContext has been stopped.
|
protected void |
beforeStart()
Callback to run custom logic before CamelContext is being started.
|
protected void |
beforeStop()
Callback to run custom logic before CamelContext is being stopped.
|
void |
completed()
Marks this process as being completed.
|
void |
disableHangupSupport()
Disable the hangup support.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
void |
enableHangupSupport()
Deprecated.
is enabled by default now, so no longer need to call this method.
|
void |
enableTrace() |
protected abstract ProducerTemplate |
findOrCreateCamelTemplate() |
protected abstract Map<String,CamelContext> |
getCamelContextMap() |
List<CamelContext> |
getCamelContexts() |
ProducerTemplate |
getCamelTemplate() |
long |
getDuration() |
int |
getDurationHitExitCode() |
int |
getExitCode() |
ModelJAXBContextFactory |
getModelJAXBContextFactory() |
String |
getRouteBuilderClasses() |
List<RouteBuilder> |
getRouteBuilders() |
List<RouteDefinition> |
getRouteDefinitions() |
TimeUnit |
getTimeUnit() |
boolean |
isTrace() |
protected void |
loadRouteBuilders(CamelContext camelContext) |
void |
parseArguments(String[] arguments)
Parses the command line arguments.
|
protected void |
postProcessCamelContext(CamelContext camelContext) |
protected void |
postProcessContext() |
void |
removeMainListener(MainListener listener)
Removes the
MainListener |
void |
run()
Runs this process with the given arguments, and will wait until completed, or the JVM terminates.
|
void |
run(String[] args)
Parses the command line arguments then runs the program.
|
void |
setDuration(long duration)
Sets the duration to run the application for in milliseconds until it
should be terminated.
|
void |
setDurationHitExitCode(int durationHitExitCode)
Sets the exit code for the application if duration was hit
|
void |
setRouteBuilderClasses(String builders) |
void |
setRouteBuilders(List<RouteBuilder> routeBuilders) |
void |
setTimeUnit(TimeUnit timeUnit)
Sets the time unit duration.
|
void |
showOptions()
Displays the command line options.
|
void |
showOptionsHeader()
Displays the header message for the command line options.
|
protected void |
waitUntilCompleted() |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
protected static final org.slf4j.Logger LOG
protected static final int UNINITIALIZED_EXIT_CODE
protected static final int DEFAULT_EXIT_CODE
protected final List<MainListener> listeners
protected final List<MainSupport.Option> options
protected final CountDownLatch latch
protected final AtomicBoolean completed
protected final AtomicInteger exitCode
protected long duration
protected boolean trace
protected List<RouteBuilder> routeBuilders
protected String routeBuilderClasses
protected final List<CamelContext> camelContexts
protected ProducerTemplate camelTemplate
protected boolean hangupInterceptorEnabled
protected int durationHitExitCode
protected MainSupport()
public void run() throws Exception
Exception
public void disableHangupSupport()
@Deprecated public void enableHangupSupport()
public void addMainListener(MainListener listener)
MainListener
to receive callbacks when the main is started or stoppinglistener
- the listenerpublic void removeMainListener(MainListener listener)
MainListener
listener
- the listenerprotected void beforeStart() throws Exception
MainListener
instead.Exception
protected void afterStart() throws Exception
MainListener
instead.Exception
protected void beforeStop() throws Exception
MainListener
instead.Exception
protected void afterStop() throws Exception
MainListener
instead.Exception
public void completed()
public void showOptions()
public void parseArguments(String[] arguments)
public void addOption(MainSupport.Option option)
public long getDuration()
public void setDuration(long duration)
public TimeUnit getTimeUnit()
public void setTimeUnit(TimeUnit timeUnit)
public void setDurationHitExitCode(int durationHitExitCode)
public int getDurationHitExitCode()
public int getExitCode()
public void setRouteBuilderClasses(String builders)
public String getRouteBuilderClasses()
public boolean isTrace()
public void enableTrace()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void waitUntilCompleted()
public void run(String[] args) throws Exception
Exception
public void showOptionsHeader()
public List<CamelContext> getCamelContexts()
public List<RouteBuilder> getRouteBuilders()
public void setRouteBuilders(List<RouteBuilder> routeBuilders)
public List<RouteDefinition> getRouteDefinitions()
public ProducerTemplate getCamelTemplate() throws Exception
Exception
protected abstract ProducerTemplate findOrCreateCamelTemplate()
protected abstract Map<String,CamelContext> getCamelContextMap()
protected void postProcessContext() throws Exception
Exception
public ModelJAXBContextFactory getModelJAXBContextFactory()
protected void loadRouteBuilders(CamelContext camelContext) throws Exception
Exception
protected void postProcessCamelContext(CamelContext camelContext) throws Exception
Exception
public void addRouteBuilder(RouteBuilder routeBuilder)
Apache Camel