org.apache.camel.impl
Class DefaultRoute

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.DefaultRoute
All Implemented Interfaces:
Route, Service, ShutdownableService, StatefulService, SuspendableService
Direct Known Subclasses:
EventDrivenConsumerRoute

public abstract class DefaultRoute
extends ServiceSupport
implements Route

Default implementation of Route.

Use the API from CamelContext to control the lifecycle of a route, such as starting and stopping using the CamelContext.startRoute(String) and CamelContext.stopRoute(String) methods.

Version:

Field Summary
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Fields inherited from interface org.apache.camel.Route
GROUP_PROPERTY, ID_PROPERTY, PARENT_PROPERTY
 
Constructor Summary
DefaultRoute(RouteContext routeContext, Endpoint endpoint)
           
DefaultRoute(RouteContext routeContext, Endpoint endpoint, Service... services)
           
 
Method Summary
 void addService(Service service)
          Adds a service to this route
protected  void addServices(List<Service> services)
          Strategy method to allow derived classes to lazily load services for the route
protected  void doShutdown()
          Implementations override this method to perform customized shutdown.
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
 Endpoint getEndpoint()
          Gets the inbound endpoint
 String getId()
          Gets the route id
 Map<String,Object> getProperties()
          This property map is used to associate information about the route.
 RouteContext getRouteContext()
          Gets the route context
 List<Service> getServices()
          Returns the services for this particular route
 void onStartingServices(List<Service> services)
          A strategy callback allowing special initialization when services are starting.
 void start()
          Do not invoke this method directly, use CamelContext.startRoute(String) to start a route.
 void stop()
          Do not invoke this method directly, use CamelContext.stopRoute(String) to stop a route.
 String toString()
           
 void warmUp()
          Callback preparing the route to be started, by warming up the route.
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, resume, shutdown, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Route
getConsumer, navigate, supportsSuspension
 

Constructor Detail

DefaultRoute

public DefaultRoute(RouteContext routeContext,
                    Endpoint endpoint)

DefaultRoute

public DefaultRoute(RouteContext routeContext,
                    Endpoint endpoint,
                    Service... services)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getId

public String getId()
Description copied from interface: Route
Gets the route id

Specified by:
getId in interface Route
Returns:
the route id

getEndpoint

public Endpoint getEndpoint()
Description copied from interface: Route
Gets the inbound endpoint

Specified by:
getEndpoint in interface Route
Returns:
the inbound endpoint

getRouteContext

public RouteContext getRouteContext()
Description copied from interface: Route
Gets the route context

Specified by:
getRouteContext in interface Route
Returns:
the route context

getProperties

public Map<String,Object> getProperties()
Description copied from interface: Route
This property map is used to associate information about the route.

Specified by:
getProperties in interface Route
Returns:
properties

onStartingServices

public void onStartingServices(List<Service> services)
                        throws Exception
Description copied from interface: Route
A strategy callback allowing special initialization when services are starting.

Specified by:
onStartingServices in interface Route
Parameters:
services - the service
Throws:
Exception - is thrown in case of error

getServices

public List<Service> getServices()
Description copied from interface: Route
Returns the services for this particular route

Specified by:
getServices in interface Route
Returns:
the services

addService

public void addService(Service service)
Description copied from interface: Route
Adds a service to this route

Specified by:
addService in interface Route
Parameters:
service - the service

warmUp

public void warmUp()
Description copied from interface: Route
Callback preparing the route to be started, by warming up the route.

Specified by:
warmUp in interface Route

start

public void start()
           throws Exception
Do not invoke this method directly, use CamelContext.startRoute(String) to start a route.

Specified by:
start in interface Service
Overrides:
start in class ServiceSupport
Throws:
Exception - is thrown if starting failed

stop

public void stop()
          throws Exception
Do not invoke this method directly, use CamelContext.stopRoute(String) to stop a route.

Specified by:
stop in interface Service
Overrides:
stop in class ServiceSupport
Throws:
Exception - is thrown if stopping failed

addServices

protected void addServices(List<Service> services)
                    throws Exception
Strategy method to allow derived classes to lazily load services for the route

Throws:
Exception

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

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

doShutdown

protected void doShutdown()
                   throws Exception
Description copied from class: ServiceSupport
Implementations override this method to perform customized shutdown.

Overrides:
doShutdown in class ServiceSupport
Throws:
Exception


Apache CAMEL