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
Class for main implementations to allow starting up a JVM with Camel embedded.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.camel.ProducerTemplateprotected static final intprotected final AtomicIntegerprotected static final org.slf4j.Loggerprotected MainShutdownStrategyprotected static final intFields inherited from class org.apache.camel.main.BaseMainSupport
camelContext, defaultPropertyPlaceholderLocation, helper, initialProperties, listeners, mainConfigurationProperties, overrideProperties, propertyPlaceholderLocations, routesCollector, standalone, wildcardPropertiesFields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedMainSupport(Class<? extends org.apache.camel.CamelConfiguration>... configurationClasses) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCallback to run custom logic after CamelContext has been started.protected voidCallback to run custom logic after CamelContext has been stopped.protected voidautoconfigure(org.apache.camel.CamelContext camelContext) protected voidCallback to run custom logic before CamelContext is being started.protected voidCallback to run custom logic before CamelContext is being stopped.voidMarks this process as being completed.protected voidconfigureLifecycle(org.apache.camel.CamelContext camelContext) protected abstract org.apache.camel.CamelContextprotected voiddoInit()protected voiddoStart()protected voiddoStop()voidvoidprotected abstract org.apache.camel.ProducerTemplateorg.apache.camel.ProducerTemplateGets the complete task which allows to trigger this on demand.intprotected voidprotected voidTasks to run before start() is called.booleanisTrace()protected voidRegistersMainBootstrapCloseablewith 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)voidsetShutdownStrategy(MainShutdownStrategy shutdownStrategy) Set theMainShutdownStrategyused to properly shut-down the main instance.protected voidMethods inherited from class org.apache.camel.main.BaseMainSupport
addInitialProperty, addMainListener, addOverrideProperty, addProperty, autoConfigurationFailFast, autoConfigurationFromProperties, autoConfigurationFromReloadedProperties, autoConfigurationMainConfiguration, autoConfigurationPropertiesComponent, autoConfigurationSingleOption, autoConfigurationStartupConditions, autowireWildcardProperties, configure, configureMainListener, configurePackageScan, configurePropertiesService, configureRoutes, configureRoutesLoader, configureStartupRecorder, createLifecycleStrategy, detectCamelDebugJar, detectResilience4jMicrometer, doAutoConfigurationFromProperties, doAutowireWildcardProperties, doConfigureCamelContextFromMainConfiguration, doConfigureVaultFromMainConfiguration, doInitFileConfigurations, getCamelContext, getDefaultPropertyPlaceholderLocation, getInitialProperties, getMainListeners, getOverrideProperties, getPropertyPlaceholderLocations, getRoutesCollector, loadConfigurations, loadCustomBeans, modelineRoutes, postProcessCamelContext, postProcessCamelRegistry, preProcessCamelRegistry, removeMainListener, setDefaultPropertyPlaceholderLocation, setInitialProperties, setInitialProperties, setOverrideProperties, setOverrideProperties, setPropertyPlaceholderLocations, setRoutesCollectorMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
UNINITIALIZED_EXIT_CODE
protected static final int UNINITIALIZED_EXIT_CODE- See Also:
-
DEFAULT_EXIT_CODE
protected static final int DEFAULT_EXIT_CODE- See Also:
-
exitCode
-
shutdownStrategy
-
camelTemplate
protected volatile org.apache.camel.ProducerTemplate camelTemplate
-
-
Constructor Details
-
MainSupport
@SafeVarargs protected MainSupport(Class<? extends org.apache.camel.CamelConfiguration>... configurationClasses) -
MainSupport
protected MainSupport()
-
-
Method Details
-
doInit
- Overrides:
doInitin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
autoconfigure
- Overrides:
autoconfigurein classBaseMainSupport- Throws:
Exception
-
run
Runs this process with the given arguments, and will wait until completed, or the JVM terminates.- Throws:
Exception
-
beforeStart
Callback to run custom logic before CamelContext is being started. It is recommended to useMainListenerinstead.- Throws:
Exception
-
afterStart
Callback 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
Callback to run custom logic before CamelContext is being stopped. It is recommended to useMainListenerinstead.- Throws:
Exception
-
afterStop
Callback 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
Gets the complete task which allows to trigger this on demand. -
registerMainBootstrap
protected void registerMainBootstrap()RegistersMainBootstrapCloseablewith the CamelContext. -
getExitCode
public int getExitCode() -
isTrace
public boolean isTrace() -
enableTrace
public void enableTrace() -
enableTraceStandby
public void enableTraceStandby() -
getShutdownStrategy
-
setShutdownStrategy
Set theMainShutdownStrategyused to properly shut-down the main instance. By default aDefaultMainShutdownStrategywill be used.- Parameters:
shutdownStrategy- the shutdown strategy
-
getAppName
-
setAppName
Application name (used for logging start and stop) -
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
configureLifecycle
- 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
- Throws:
Exception
-
initCamelContext
- Throws:
Exception
-