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 long |
durationIdle |
protected int |
durationMaxMessages |
protected AtomicInteger |
exitCode |
protected String |
fileWatchDirectory |
protected boolean |
fileWatchDirectoryRecursively |
protected boolean |
hangupInterceptorEnabled |
protected CountDownLatch |
latch |
protected List<MainListener> |
listeners |
protected static org.slf4j.Logger |
LOG |
protected List<MainSupport.Option> |
options |
protected ReloadStrategy |
reloadStrategy |
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() |
long |
getDurationIdle() |
int |
getDurationMaxMessages() |
int |
getExitCode() |
String |
getFileWatchDirectory() |
ModelJAXBContextFactory |
getModelJAXBContextFactory() |
ReloadStrategy |
getReloadStrategy() |
String |
getRouteBuilderClasses() |
List<RouteBuilder> |
getRouteBuilders() |
List<RouteDefinition> |
getRouteDefinitions() |
TimeUnit |
getTimeUnit() |
boolean |
isFileWatchDirectoryRecursively() |
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 (in seconds) to run the application until it
should be terminated.
|
void |
setDurationHitExitCode(int durationHitExitCode)
Sets the exit code for the application if duration was hit
|
void |
setDurationIdle(long durationIdle)
Sets the maximum idle duration (in seconds) when running the application, and
if there has been no message processed after being idle for more than this duration
then the application should be terminated.
|
void |
setDurationMaxMessages(int durationMaxMessages)
Sets the duration to run the application to process at most max messages until it
should be terminated.
|
void |
setFileWatchDirectory(String fileWatchDirectory)
Sets the directory name to watch XML file changes to trigger live reload of Camel routes.
|
void |
setFileWatchDirectoryRecursively(boolean fileWatchDirectoryRecursively)
Sets the flag to watch directory of XML file changes recursively to trigger live reload of Camel routes.
|
void |
setReloadStrategy(ReloadStrategy reloadStrategy)
Sets a custom
ReloadStrategy to be used. |
void |
setRouteBuilderClasses(String builders) |
void |
setRouteBuilders(List<RouteBuilder> routeBuilders) |
void |
setTimeUnit(TimeUnit timeUnit)
Sets the time unit duration (seconds by default).
|
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 long durationIdle
protected int durationMaxMessages
protected boolean trace
protected List<RouteBuilder> routeBuilders
protected String routeBuilderClasses
protected String fileWatchDirectory
protected boolean fileWatchDirectoryRecursively
protected final List<CamelContext> camelContexts
protected ProducerTemplate camelTemplate
protected boolean hangupInterceptorEnabled
protected int durationHitExitCode
protected ReloadStrategy reloadStrategy
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 long getDurationIdle()
public void setDurationIdle(long durationIdle)
public int getDurationMaxMessages()
public void setDurationMaxMessages(int durationMaxMessages)
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 getFileWatchDirectory()
public void setFileWatchDirectory(String fileWatchDirectory)
ReloadStrategy
as well.public boolean isFileWatchDirectoryRecursively()
public void setFileWatchDirectoryRecursively(boolean fileWatchDirectoryRecursively)
ReloadStrategy
as well.public String getRouteBuilderClasses()
public ReloadStrategy getReloadStrategy()
public void setReloadStrategy(ReloadStrategy reloadStrategy)
ReloadStrategy
to be used.
Notice you cannot set this value and the fileWatchDirectory as well.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