org.apache.camel.main
Class MainSupport

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.main.MainSupport
All Implemented Interfaces:
Service, ShutdownableService, StatefulService, SuspendableService
Direct Known Subclasses:
Main, MainSupport

public abstract class MainSupport
extends ServiceSupport

Version:

Nested Class Summary
 class MainSupport.Option
           
 class MainSupport.ParameterOption
           
 
Field Summary
protected  boolean aggregateDot
           
protected  List<CamelContext> camelContexts
           
protected  ProducerTemplate camelTemplate
           
protected  AtomicBoolean completed
           
protected  String dotOutputDir
           
protected  long duration
           
protected  CountDownLatch latch
           
protected static org.slf4j.Logger LOG
           
protected  List<MainSupport.Option> options
           
protected  String routeBuilderClasses
           
protected  List<RouteBuilder> routeBuilders
           
protected  String routesOutputFile
           
protected  TimeUnit timeUnit
           
protected  boolean trace
           
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
protected MainSupport()
           
 
Method Summary
 void addOption(MainSupport.Option option)
           
 void addRouteBuilder(RouteBuilder routeBuilder)
           
protected  void afterStart()
          Callback to run custom logic after CamelContext has been started.
protected  void beforeStop()
          Callback to run custom logic before CamelContext is being stopped.
 void completed()
          Marks this process as being completed.
protected abstract  ModelFileGenerator createModelFileGenerator()
           
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
 void enableHangupSupport()
          Enables the hangup support.
 void enableTrace()
           
protected abstract  ProducerTemplate findOrCreateCamelTemplate()
           
protected  void generateDot(String name, CamelContext camelContext, int size)
           
protected abstract  Map<String,CamelContext> getCamelContextMap()
           
 List<CamelContext> getCamelContexts()
           
 ProducerTemplate getCamelTemplate()
           
 String getDotOutputDir()
           
 long getDuration()
           
 String getRouteBuilderClasses()
           
 List<RouteBuilder> getRouteBuilders()
           
 List<RouteDefinition> getRouteDefinitions()
           
 String getRoutesOutputFile()
           
 TimeUnit getTimeUnit()
           
 boolean isAggregateDot()
           
 boolean isTrace()
           
protected  void loadRouteBuilders(CamelContext camelContext)
           
protected  void outputRoutesToFile()
           
 void parseArguments(String[] arguments)
          Parses the command line arguments.
protected  void postProcessCamelContext(CamelContext camelContext)
           
protected  void postProcessContext()
           
 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 setAggregateDot(boolean aggregateDot)
           
 void setDotOutputDir(String dotOutputDir)
          Sets the output directory of the generated DOT Files to show the visual representation of the routes.
 void setDuration(long duration)
          Sets the duration to run the application for in milliseconds until it should be terminated.
 void setRouteBuilderClasses(String builders)
           
 void setRouteBuilders(List<RouteBuilder> routeBuilders)
           
 void setRoutesOutputFile(String routesOutputFile)
           
 void setTimeUnit(TimeUnit timeUnit)
          Sets the time unit duration.
 void showOptions()
          Displays the command line options.
 void showOptionsHeader()
          Displays the header message for the command line options.
protected  void waitUntilCompleted()
           
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.slf4j.Logger LOG

dotOutputDir

protected String dotOutputDir

options

protected final List<MainSupport.Option> options

latch

protected final CountDownLatch latch

completed

protected final AtomicBoolean completed

duration

protected long duration

timeUnit

protected TimeUnit timeUnit

routesOutputFile

protected String routesOutputFile

aggregateDot

protected boolean aggregateDot

trace

protected boolean trace

routeBuilders

protected List<RouteBuilder> routeBuilders

routeBuilderClasses

protected String routeBuilderClasses

camelContexts

protected final List<CamelContext> camelContexts

camelTemplate

protected ProducerTemplate camelTemplate
Constructor Detail

MainSupport

protected MainSupport()
Method Detail

run

public void run()
         throws Exception
Runs this process with the given arguments, and will wait until completed, or the JVM terminates.

Throws:
Exception

enableHangupSupport

public void enableHangupSupport()
Enables the hangup support. Gracefully stops by calling stop() on a Hangup signal.


afterStart

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

Throws:
Exception

beforeStop

protected void beforeStop()
                   throws Exception
Callback to run custom logic before CamelContext is being stopped.

Throws:
Exception

completed

public void completed()
Marks this process as being completed.


showOptions

public void showOptions()
Displays the command line options.


parseArguments

public void parseArguments(String[] arguments)
Parses the command line arguments.


addOption

public void addOption(MainSupport.Option option)

getDuration

public long getDuration()

setDuration

public void setDuration(long duration)
Sets the duration to run the application for in milliseconds until it should be terminated. Defaults to -1. Any value <= 0 will run forever.


getTimeUnit

public TimeUnit getTimeUnit()

setTimeUnit

public void setTimeUnit(TimeUnit timeUnit)
Sets the time unit duration.


getDotOutputDir

public String getDotOutputDir()

setRouteBuilderClasses

public void setRouteBuilderClasses(String builders)

getRouteBuilderClasses

public String getRouteBuilderClasses()

setDotOutputDir

public void setDotOutputDir(String dotOutputDir)
Sets the output directory of the generated DOT Files to show the visual representation of the routes. A null value disables the dot file generation.


setAggregateDot

public void setAggregateDot(boolean aggregateDot)

isAggregateDot

public boolean isAggregateDot()

isTrace

public boolean isTrace()

enableTrace

public void enableTrace()

setRoutesOutputFile

public void setRoutesOutputFile(String routesOutputFile)

getRoutesOutputFile

public String getRoutesOutputFile()

doStop

protected void doStop()
               throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: Camel will invoke this ServiceSupport.doStop() method when the service is being stopped. This method will also be invoked if the service is still in uninitialized state (eg has not been started). The method is always called to allow the service to do custom logic when the service is being stopped, such as when CamelContext is shutting down.

Specified by:
doStop in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStart()

doStart

protected void doStart()
                throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: See ServiceSupport.doStop() for more details.

Specified by:
doStart in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStop()

waitUntilCompleted

protected void waitUntilCompleted()

run

public void run(String[] args)
         throws Exception
Parses the command line arguments then runs the program.

Throws:
Exception

showOptionsHeader

public void showOptionsHeader()
Displays the header message for the command line options.


getCamelContexts

public List<CamelContext> getCamelContexts()

getRouteBuilders

public List<RouteBuilder> getRouteBuilders()

setRouteBuilders

public void setRouteBuilders(List<RouteBuilder> routeBuilders)

getRouteDefinitions

public List<RouteDefinition> getRouteDefinitions()

getCamelTemplate

public ProducerTemplate getCamelTemplate()
                                  throws Exception
Throws:
Exception

findOrCreateCamelTemplate

protected abstract ProducerTemplate findOrCreateCamelTemplate()

getCamelContextMap

protected abstract Map<String,CamelContext> getCamelContextMap()

postProcessContext

protected void postProcessContext()
                           throws Exception
Throws:
Exception

outputRoutesToFile

protected void outputRoutesToFile()
                           throws IOException,
                                  JAXBException
Throws:
IOException
JAXBException

createModelFileGenerator

protected abstract ModelFileGenerator createModelFileGenerator()
                                                        throws JAXBException
Throws:
JAXBException

generateDot

protected void generateDot(String name,
                           CamelContext camelContext,
                           int size)
                    throws IOException
Throws:
IOException

loadRouteBuilders

protected void loadRouteBuilders(CamelContext camelContext)
                          throws Exception
Throws:
Exception

postProcessCamelContext

protected void postProcessCamelContext(CamelContext camelContext)
                                throws Exception
Throws:
Exception

addRouteBuilder

public void addRouteBuilder(RouteBuilder routeBuilder)


Apache Camel