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 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

      protected final AtomicInteger exitCode
    • shutdownStrategy

      protected MainShutdownStrategy 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

      protected void doInit() throws Exception
      Overrides:
      doInit in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • autoconfigure

      protected void autoconfigure(org.apache.camel.CamelContext camelContext) throws Exception
      Overrides:
      autoconfigure in class BaseMainSupport
      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 use MainListener instead.

      Throws:
      Exception
    • afterStart

      protected void afterStart() throws Exception
      Callback to run custom logic after CamelContext has been started.

      It is recommended to use MainListener 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 use MainListener instead.

      Throws:
      Exception
    • afterStop

      protected void afterStop() throws Exception
      Callback to run custom logic after CamelContext has been stopped.

      It is recommended to use MainListener 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()
      Registers MainBootstrapCloseable with the CamelContext.
    • getDuration

      @Deprecated public int getDuration()
      Deprecated.
    • setDuration

      @Deprecated public void setDuration(int duration)
      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)
      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)
      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)
      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 the MainShutdownStrategy used to properly shut-down the main instance. By default a DefaultMainShutdownStrategy 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 class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • configureLifecycle

      protected void configureLifecycle(org.apache.camel.CamelContext camelContext) throws Exception
      Overrides:
      configureLifecycle in class BaseMainSupport
      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
    • initCamelContext

      protected void initCamelContext() throws Exception
      Throws:
      Exception