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.ProducerTemplatecamelTemplateprotected static intDEFAULT_EXIT_CODEprotected AtomicIntegerexitCodeprotected static org.slf4j.LoggerLOGprotected MainShutdownStrategyshutdownStrategyprotected static intUNINITIALIZED_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 protectedMainSupport()protectedMainSupport(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 voidafterStart()Callback to run custom logic after CamelContext has been started.protected voidafterStop()Callback to run custom logic after CamelContext has been stopped.protected voidautoconfigure(org.apache.camel.CamelContext camelContext)protected voidbeforeStart()Callback to run custom logic before CamelContext is being started.protected voidbeforeStop()Callback to run custom logic before CamelContext is being stopped.voidcompleted()Marks this process as being completed.protected voidconfigureLifecycle(org.apache.camel.CamelContext camelContext)protected abstract org.apache.camel.CamelContextcreateCamelContext()protected voiddoInit()protected voiddoStart()protected voiddoStop()voidenableTrace()voidenableTraceStandby()protected abstract org.apache.camel.ProducerTemplatefindOrCreateCamelTemplate()StringgetAppName()org.apache.camel.ProducerTemplategetCamelTemplate()RunnablegetCompleteTask()Gets the complete task which allows to trigger this on demand.intgetDuration()Deprecated.intgetDurationHitExitCode()Deprecated.intgetDurationIdle()Deprecated.intgetDurationMaxMessages()Deprecated.intgetExitCode()MainShutdownStrategygetShutdownStrategy()protected voidinitCamelContext()protected voidinternalBeforeStart()Tasks to run before start() is called.booleanisTrace()protected voidregisterMainBootstrap()RegistersMainBootstrapCloseablewith the CamelContext.voidrun()Runs this process with the given arguments, and will wait until completed, or the JVM terminates.voidsetAppName(String appName)Application name (used for logging start and stop)voidsetDuration(int duration)Deprecated.voidsetDurationHitExitCode(int durationHitExitCode)Deprecated.voidsetDurationIdle(int durationIdle)Deprecated.voidsetDurationMaxMessages(int durationMaxMessages)Deprecated.voidsetShutdownStrategy(MainShutdownStrategy shutdownStrategy)Set theMainShutdownStrategyused to properly shut-down the main instance.protected voidwaitUntilCompleted()-
Methods inherited from class org.apache.camel.main.BaseMainSupport
addInitialProperty, addMainListener, addOverrideProperty, addProperty, autoConfigurationFailFast, autoConfigurationFromProperties, autoConfigurationFromReloadedProperties, autoConfigurationMainConfiguration, autoConfigurationPropertiesComponent, autoConfigurationSingleOption, autowireWildcardProperties, configure, configurePackageScan, configurePropertiesService, configureRoutes, configureRoutesLoader, configureStartupRecorder, configureVault, doAutoConfigurationFromProperties, 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:
doInitin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
autoconfigure
protected void autoconfigure(org.apache.camel.CamelContext camelContext) throws Exception- Overrides:
autoconfigurein classBaseMainSupport- Throws:
Exception
-
run
public void run() throws ExceptionRuns this process with the given arguments, and will wait until completed, or the JVM terminates.- Throws:
Exception
-
beforeStart
protected void beforeStart() throws ExceptionCallback to run custom logic before CamelContext is being started. It is recommended to useMainListenerinstead.- Throws:
Exception
-
afterStart
protected void afterStart() throws ExceptionCallback to run custom logic after CamelContext has been started. It is recommended to useMainListenerinstead.- Throws:
Exception
-
internalBeforeStart
protected void internalBeforeStart()
Tasks to run before start() is called.
-
beforeStop
protected void beforeStop() throws ExceptionCallback to run custom logic before CamelContext is being stopped. It is recommended to useMainListenerinstead.- Throws:
Exception
-
afterStop
protected void afterStop() throws ExceptionCallback to run custom logic after CamelContext has been stopped. It is recommended to useMainListenerinstead.- 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()
RegistersMainBootstrapCloseablewith 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 theMainShutdownStrategyused to properly shut-down the main instance. By default aDefaultMainShutdownStrategywill 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:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
configureLifecycle
protected void configureLifecycle(org.apache.camel.CamelContext camelContext) throws Exception- Overrides:
configureLifecyclein 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
-
-