public abstract class MainSupport
extends org.apache.camel.support.service.ServiceSupport
| Modifier and Type | Class and Description |
|---|---|
class |
MainSupport.Option |
class |
MainSupport.ParameterOption |
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.camel.CamelContext |
camelContext |
protected org.apache.camel.ProducerTemplate |
camelTemplate |
protected AtomicBoolean |
completed |
protected String |
configurationClasses |
protected List<Object> |
configurations |
protected static int |
DEFAULT_EXIT_CODE |
protected AtomicInteger |
exitCode |
protected Properties |
initialProperties |
protected CountDownLatch |
latch |
protected List<MainListener> |
listeners |
protected static org.slf4j.Logger |
LOG |
protected MainConfigurationProperties |
mainConfigurationProperties |
protected List<MainSupport.Option> |
options |
protected Properties |
overrideProperties |
protected String |
propertyPlaceholderLocations |
protected String |
routeBuilderClasses |
protected List<org.apache.camel.builder.RouteBuilder> |
routeBuilders |
protected static int |
UNINITIALIZED_EXIT_CODE |
| Modifier | Constructor and Description |
|---|---|
protected |
MainSupport() |
protected |
MainSupport(Class... configurationClasses) |
| Modifier and Type | Method and Description |
|---|---|
void |
addConfiguration(Object configuration) |
void |
addConfigurationClass(Class... configuration) |
void |
addMainListener(MainListener listener)
Adds a
MainListener to receive callbacks when the main is started or stopping |
void |
addOption(MainSupport.Option option) |
void |
addRouteBuilder(Class... routeBuilder) |
void |
addRouteBuilder(org.apache.camel.builder.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 |
autoConfigurationFailFast(org.apache.camel.CamelContext camelContext,
Map<String,String> autoConfiguredProperties) |
protected void |
autoConfigurationFromProperties(org.apache.camel.CamelContext camelContext,
Map<String,String> autoConfiguredProperties) |
protected void |
autoConfigurationMainConfiguration(org.apache.camel.CamelContext camelContext,
MainConfigurationProperties config,
Map<String,String> autoConfiguredProperties) |
protected void |
autoConfigurationPropertiesComponent(org.apache.camel.CamelContext camelContext,
Map<String,String> autoConfiguredProperties) |
protected void |
autowireConfigurationFromRegistry(org.apache.camel.CamelContext camelContext,
boolean deepNesting) |
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.
|
MainConfigurationProperties |
configure()
To configure options on Camel Main.
|
protected abstract org.apache.camel.CamelContext |
createCamelContext() |
void |
disableHangupSupport()
Disable the hangup support.
|
protected void |
doConfigureCamelContextFromMainConfiguration(org.apache.camel.CamelContext camelContext,
MainConfigurationProperties config,
Map<String,String> autoConfiguredProperties)
Configures CamelContext from the
MainConfigurationProperties properties. |
protected void |
doStart() |
protected void |
doStop() |
void |
enableHangupSupport()
Hangup support is enabled by default.
|
void |
enableTrace() |
protected abstract org.apache.camel.ProducerTemplate |
findOrCreateCamelTemplate() |
org.apache.camel.CamelContext |
getCamelContext() |
org.apache.camel.ProducerTemplate |
getCamelTemplate() |
String |
getConfigurationClasses() |
List<Object> |
getConfigurations() |
int |
getDuration()
Deprecated.
|
int |
getDurationHitExitCode()
Deprecated.
|
int |
getDurationIdle()
Deprecated.
|
int |
getDurationMaxMessages()
Deprecated.
|
int |
getExitCode() |
Properties |
getInitialProperties() |
Properties |
getOverrideProperties() |
String |
getPropertyPlaceholderLocations() |
String |
getRouteBuilderClasses() |
List<org.apache.camel.builder.RouteBuilder> |
getRouteBuilders() |
List<org.apache.camel.model.RouteDefinition> |
getRouteDefinitions() |
protected void |
initCamelContext() |
boolean |
isAutoConfigurationEnabled()
Deprecated.
|
boolean |
isTrace() |
protected void |
loadConfigurations(org.apache.camel.CamelContext camelContext) |
protected static Properties |
loadEnvironmentVariablesAsProperties(String[] prefixes) |
protected void |
loadRouteBuilders(org.apache.camel.CamelContext camelContext) |
void |
parseArguments(String[] arguments)
Parses the command line arguments.
|
protected void |
postProcessCamelContext(org.apache.camel.CamelContext camelContext) |
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 |
setAutoConfigurationEnabled(boolean autoConfigurationEnabled)
Deprecated.
use
configure() |
void |
setConfigurationClasses(String configurations) |
void |
setConfigurations(List<Object> configurations) |
void |
setDuration(int duration)
Deprecated.
use
configure() |
void |
setDurationHitExitCode(int durationHitExitCode)
Deprecated.
use
configure() |
void |
setDurationIdle(int durationIdle)
Deprecated.
use
configure() |
void |
setDurationMaxMessages(int durationMaxMessages)
Deprecated.
use
configure() |
void |
setInitialProperties(Properties initialProperties)
Sets initial properties for the properties component,
which will be used before any locations are resolved.
|
void |
setOverrideProperties(Properties overrideProperties)
Sets a special list of override properties that take precedence
and will use first, if a property exist.
|
void |
setPropertyPlaceholderLocations(String location)
A list of locations to add for loading properties.
|
void |
setRouteBuilderClasses(String builders) |
void |
setRouteBuilders(List<org.apache.camel.builder.RouteBuilder> routeBuilders) |
void |
showOptions()
Displays the command line options.
|
void |
showOptionsHeader()
Displays the header message for the command line options.
|
protected void |
validateOptionAndValue(String key,
String option,
String value) |
protected void |
waitUntilCompleted() |
doInit, doResume, doShutdown, doSuspend, getStatus, init, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendprotected 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 volatile org.apache.camel.CamelContext camelContext
protected volatile org.apache.camel.ProducerTemplate camelTemplate
protected final MainConfigurationProperties mainConfigurationProperties
protected List<org.apache.camel.builder.RouteBuilder> routeBuilders
protected String routeBuilderClasses
protected String configurationClasses
protected String propertyPlaceholderLocations
protected Properties initialProperties
protected Properties overrideProperties
protected MainSupport(Class... configurationClasses)
protected MainSupport()
public void run()
throws Exception
Exceptionpublic void disableHangupSupport()
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)
MainListenerlistener - the listenerprotected void beforeStart()
throws Exception
MainListener instead.Exceptionprotected void afterStart()
throws Exception
MainListener instead.Exceptionprotected void beforeStop()
throws Exception
MainListener instead.Exceptionprotected void afterStop()
throws Exception
MainListener instead.Exceptionpublic void completed()
public void showOptions()
public void parseArguments(String[] arguments)
public void addOption(MainSupport.Option option)
public MainConfigurationProperties configure()
@Deprecated public int getDuration()
@Deprecated public void setDuration(int duration)
configure()@Deprecated public int getDurationIdle()
@Deprecated public void setDurationIdle(int durationIdle)
configure()@Deprecated public int getDurationMaxMessages()
@Deprecated public void setDurationMaxMessages(int durationMaxMessages)
configure()@Deprecated public void setDurationHitExitCode(int durationHitExitCode)
configure()@Deprecated public int getDurationHitExitCode()
public int getExitCode()
public String getConfigurationClasses()
public void setConfigurationClasses(String configurations)
public void addConfigurationClass(Class... configuration)
public void addConfiguration(Object configuration)
public String getRouteBuilderClasses()
public void setRouteBuilderClasses(String builders)
public String getPropertyPlaceholderLocations()
public void setPropertyPlaceholderLocations(String location)
@Deprecated public boolean isAutoConfigurationEnabled()
@Deprecated public void setAutoConfigurationEnabled(boolean autoConfigurationEnabled)
configure()Registry.bind(String, Object) method
or by using the BindToRegistry annotation style.
This option is default enabled.public Properties getInitialProperties()
public void setInitialProperties(Properties initialProperties)
public Properties getOverrideProperties()
public void setOverrideProperties(Properties overrideProperties)
public boolean isTrace()
public void enableTrace()
protected void doStop()
throws Exception
doStop in class org.apache.camel.support.service.ServiceSupportExceptionprotected void doStart()
throws Exception
doStart in class org.apache.camel.support.service.ServiceSupportExceptionprotected void waitUntilCompleted()
public void run(String[] args) throws Exception
Exceptionpublic void showOptionsHeader()
public org.apache.camel.CamelContext getCamelContext()
public List<org.apache.camel.builder.RouteBuilder> getRouteBuilders()
public void setRouteBuilders(List<org.apache.camel.builder.RouteBuilder> routeBuilders)
public List<org.apache.camel.model.RouteDefinition> getRouteDefinitions()
public org.apache.camel.ProducerTemplate getCamelTemplate()
throws Exception
Exceptionprotected abstract org.apache.camel.ProducerTemplate findOrCreateCamelTemplate()
protected abstract org.apache.camel.CamelContext createCamelContext()
protected void loadRouteBuilders(org.apache.camel.CamelContext camelContext)
throws Exception
Exceptionprotected void loadConfigurations(org.apache.camel.CamelContext camelContext)
throws Exception
Exceptionprotected void postProcessCamelContext(org.apache.camel.CamelContext camelContext)
throws Exception
Exceptionprotected void autoConfigurationFailFast(org.apache.camel.CamelContext camelContext,
Map<String,String> autoConfiguredProperties)
throws Exception
Exceptionprotected void doConfigureCamelContextFromMainConfiguration(org.apache.camel.CamelContext camelContext,
MainConfigurationProperties config,
Map<String,String> autoConfiguredProperties)
throws Exception
MainConfigurationProperties properties.Exceptionprotected void autoConfigurationPropertiesComponent(org.apache.camel.CamelContext camelContext,
Map<String,String> autoConfiguredProperties)
throws Exception
Exceptionprotected void autoConfigurationMainConfiguration(org.apache.camel.CamelContext camelContext,
MainConfigurationProperties config,
Map<String,String> autoConfiguredProperties)
throws Exception
Exceptionprotected void autoConfigurationFromProperties(org.apache.camel.CamelContext camelContext,
Map<String,String> autoConfiguredProperties)
throws Exception
Exceptionprotected void autowireConfigurationFromRegistry(org.apache.camel.CamelContext camelContext,
boolean deepNesting)
throws Exception
Exceptionprotected static Properties loadEnvironmentVariablesAsProperties(String[] prefixes)
protected void validateOptionAndValue(String key, String option, String value)
public void addRouteBuilder(org.apache.camel.builder.RouteBuilder routeBuilder)
public void addRouteBuilder(Class... routeBuilder)
Apache Camel