Package org.apache.camel.main
Class MainSupport
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.main.BaseMainSupport
-
- org.apache.camel.main.MainSupport
-
- Direct Known Subclasses:
MainCommandLineSupport
public abstract class MainSupport extends BaseMainSupport
Class for main implementations to allow starting up a JVM with Camel embedded.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.camel.ProducerTemplate
camelTemplate
protected static int
DEFAULT_EXIT_CODE
protected AtomicInteger
exitCode
protected static org.slf4j.Logger
LOG
protected MainShutdownStrategy
shutdownStrategy
protected static int
UNINITIALIZED_EXIT_CODE
-
Fields inherited from class org.apache.camel.main.BaseMainSupport
camelContext, DEFAULT_PROPERTY_PLACEHOLDER_LOCATION, defaultPropertyPlaceholderLocation, helper, INITIAL_PROPERTIES_LOCATION, initialProperties, listeners, mainConfigurationProperties, OVERRIDE_PROPERTIES_LOCATION, overrideProperties, PROPERTY_PLACEHOLDER_LOCATION, propertyPlaceholderLocations, routesCollector, standalone, wildcardProperties
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MainSupport()
protected
MainSupport(Class<? extends org.apache.camel.CamelConfiguration>... configurationClasses)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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
autoconfigure(org.apache.camel.CamelContext camelContext)
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.protected void
configureLifecycle(org.apache.camel.CamelContext camelContext)
protected abstract org.apache.camel.CamelContext
createCamelContext()
protected void
doInit()
protected void
doStart()
protected void
doStop()
void
enableTrace()
void
enableTraceStandby()
protected abstract org.apache.camel.ProducerTemplate
findOrCreateCamelTemplate()
String
getAppName()
org.apache.camel.ProducerTemplate
getCamelTemplate()
Runnable
getCompleteTask()
Gets the complete task which allows to trigger this on demand.int
getDuration()
Deprecated.int
getDurationHitExitCode()
Deprecated.int
getDurationIdle()
Deprecated.int
getDurationMaxMessages()
Deprecated.int
getExitCode()
MainShutdownStrategy
getShutdownStrategy()
protected void
initCamelContext()
protected void
internalBeforeStart()
Tasks to run before start() is called.boolean
isTrace()
protected void
registerMainBootstrap()
RegistersMainBootstrapCloseable
with the CamelContext.void
run()
Runs this process with the given arguments, and will wait until completed, or the JVM terminates.void
setAppName(String appName)
Application name (used for logging start and stop)void
setDuration(int duration)
Deprecated.void
setDurationHitExitCode(int durationHitExitCode)
Deprecated.void
setDurationIdle(int durationIdle)
Deprecated.void
setDurationMaxMessages(int durationMaxMessages)
Deprecated.void
setShutdownStrategy(MainShutdownStrategy shutdownStrategy)
Set theMainShutdownStrategy
used to properly shut-down the main instance.protected void
waitUntilCompleted()
-
Methods inherited from class org.apache.camel.main.BaseMainSupport
addInitialProperty, addMainListener, addOverrideProperty, addProperty, autoConfigurationFailFast, autoConfigurationFromProperties, autoConfigurationMainConfiguration, autoConfigurationPropertiesComponent, autoConfigurationSingleOption, autowireWildcardProperties, configure, configurePackageScan, configurePropertiesService, configureRoutes, configureRoutesLoader, configureStartupRecorder, doAutowireWildcardProperties, doConfigureCamelContextFromMainConfiguration, getCamelContext, getDefaultPropertyPlaceholderLocation, getInitialProperties, getOverrideProperties, getPropertyPlaceholderLocations, getRoutesCollector, loadConfigurations, modelineRoutes, postProcessCamelContext, removeMainListener, setDefaultPropertyPlaceholderLocation, setInitialProperties, setInitialProperties, setOverrideProperties, setOverrideProperties, setPropertyPlaceholderLocations, setRoutesCollector
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
-
UNINITIALIZED_EXIT_CODE
protected static final int UNINITIALIZED_EXIT_CODE
- See Also:
- Constant Field Values
-
DEFAULT_EXIT_CODE
protected static final int DEFAULT_EXIT_CODE
- See Also:
- Constant Field Values
-
exitCode
protected final AtomicInteger exitCode
-
shutdownStrategy
protected MainShutdownStrategy shutdownStrategy
-
camelTemplate
protected volatile org.apache.camel.ProducerTemplate camelTemplate
-
-
Constructor Detail
-
MainSupport
@SafeVarargs protected MainSupport(Class<? extends org.apache.camel.CamelConfiguration>... configurationClasses)
-
MainSupport
protected MainSupport()
-
-
Method Detail
-
doInit
protected void doInit() throws Exception
- Overrides:
doInit
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
autoconfigure
protected void autoconfigure(org.apache.camel.CamelContext camelContext) throws Exception
- Overrides:
autoconfigure
in classBaseMainSupport
- Throws:
Exception
-
run
public void run() throws Exception
Runs this process with the given arguments, and will wait until completed, or the JVM terminates.- Throws:
Exception
-
beforeStart
protected void beforeStart() throws Exception
Callback to run custom logic before CamelContext is being started. It is recommended to useMainListener
instead.- Throws:
Exception
-
afterStart
protected void afterStart() throws Exception
Callback to run custom logic after CamelContext has been started. It is recommended to useMainListener
instead.- Throws:
Exception
-
internalBeforeStart
protected void internalBeforeStart()
Tasks to run before start() is called.
-
beforeStop
protected void beforeStop() throws Exception
Callback to run custom logic before CamelContext is being stopped. It is recommended to useMainListener
instead.- Throws:
Exception
-
afterStop
protected void afterStop() throws Exception
Callback to run custom logic after CamelContext has been stopped. It is recommended to useMainListener
instead.- Throws:
Exception
-
completed
public void completed()
Marks this process as being completed.
-
getCompleteTask
public Runnable getCompleteTask()
Gets the complete task which allows to trigger this on demand.
-
registerMainBootstrap
protected void registerMainBootstrap()
RegistersMainBootstrapCloseable
with the CamelContext.
-
getDuration
@Deprecated public int getDuration()
Deprecated.
-
setDuration
@Deprecated public void setDuration(int duration)
Deprecated.Sets the duration (in seconds) to run the application until it should be terminated. Defaults to -1. Any value <= 0 will run forever.
-
getDurationIdle
@Deprecated public int getDurationIdle()
Deprecated.
-
setDurationIdle
@Deprecated public void setDurationIdle(int durationIdle)
Deprecated.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. Defaults to -1. Any value <= 0 will run forever.
-
getDurationMaxMessages
@Deprecated public int getDurationMaxMessages()
Deprecated.
-
setDurationMaxMessages
@Deprecated public void setDurationMaxMessages(int durationMaxMessages)
Deprecated.Sets the duration to run the application to process at most max messages until it should be terminated. Defaults to -1. Any value <= 0 will run forever.
-
setDurationHitExitCode
@Deprecated public void setDurationHitExitCode(int durationHitExitCode)
Deprecated.Sets the exit code for the application if duration was hit
-
getDurationHitExitCode
@Deprecated public int getDurationHitExitCode()
Deprecated.
-
getExitCode
public int getExitCode()
-
isTrace
public boolean isTrace()
-
enableTrace
public void enableTrace()
-
enableTraceStandby
public void enableTraceStandby()
-
getShutdownStrategy
public MainShutdownStrategy getShutdownStrategy()
-
setShutdownStrategy
public void setShutdownStrategy(MainShutdownStrategy shutdownStrategy)
Set theMainShutdownStrategy
used to properly shut-down the main instance. By default aDefaultMainShutdownStrategy
will be used.- Parameters:
shutdownStrategy
- the shutdown strategy
-
getAppName
public String getAppName()
-
setAppName
public void setAppName(String appName)
Application name (used for logging start and stop)
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
configureLifecycle
protected void configureLifecycle(org.apache.camel.CamelContext camelContext) throws Exception
- Overrides:
configureLifecycle
in classBaseMainSupport
- Throws:
Exception
-
waitUntilCompleted
protected void waitUntilCompleted()
-
findOrCreateCamelTemplate
protected abstract org.apache.camel.ProducerTemplate findOrCreateCamelTemplate()
-
createCamelContext
protected abstract org.apache.camel.CamelContext createCamelContext()
-
getCamelTemplate
public org.apache.camel.ProducerTemplate getCamelTemplate() throws Exception
- Throws:
Exception
-
-