org.apache.camel.impl
Class MainSupport

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

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  List<RouteBuilder> routeBuilders
           
protected  String routesOutputFile
           
protected  TimeUnit timeUnit
           
protected  boolean trace
           
 
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()
           
protected  void doStop()
           
 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()
          Returns a ProducerTemplate from the Spring ApplicationContext instances or lazily creates a new one dynamically
 String getDotOutputDir()
           
 long getDuration()
           
 List<RouteBuilder> getRouteBuilders()
           
 List<RouteDefinition> getRouteDefinitions()
           
 String getRoutesOutputFile()
           
 TimeUnit getTimeUnit()
           
 boolean isAggregateDot()
           
 boolean isTrace()
           
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 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.impl.ServiceSupport
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, 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

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()
Callback to run custom logic after CamelContext has been started


beforeStop

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


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

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
Specified by:
doStop in class ServiceSupport
Throws:
Exception

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class ServiceSupport
Throws:
Exception

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
Returns a ProducerTemplate from the Spring ApplicationContext instances or lazily creates a new one dynamically

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

postProcessCamelContext

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

addRouteBuilder

public void addRouteBuilder(RouteBuilder routeBuilder)


Apache CAMEL