org.apache.camel.impl
Class ServiceSupport

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
All Implemented Interfaces:
Service, ShutdownableService
Direct Known Subclasses:
AggregateProcessor, BaseTypeConverterRegistry, BatchProcessor, BeanProcessor, ChoiceProcessor, ConsumerCache, DefaultCamelContext, DefaultChannel, DefaultComponent, DefaultConsumer, DefaultConsumerTemplate, DefaultExecutorServiceStrategy, DefaultInflightRepository, DefaultManagementAgent, DefaultProducer, DefaultProducerTemplate, DefaultRoute, DefaultServicePool, DefaultShutdownStrategy, DefaultTimeoutMap, DelegateAsyncProcessor, DelegateProcessor, Enricher, ErrorHandlerSupport, EventNotifierSupport, FileIdempotentRepository, IdempotentConsumer, InterceptorToAsyncProcessorBridge, LoadBalancerSupport, Logger, MainSupport, MarshalProcessor, MemoryAggregationRepository, MemoryIdempotentRepository, MulticastProcessor, OnCompletionProcessor, PollEnricher, PollingConsumerSupport, ProducerCache, RecipientList, RoutePolicySupport, RouteService, RoutingSlip, SedaConsumer, SendProcessor, StreamResequencer, ThreadsProcessor, TryProcessor, UnmarshalProcessor

public abstract class ServiceSupport
extends Object
implements Service, ShutdownableService

A useful base class which ensures that a service is only initialized once and provides some helper methods for enquiring of its status.

Implementations can extend this base class and implement SuspendableService in case they support suspend/resume.

Version:
$Revision: 981180 $

Constructor Summary
ServiceSupport()
           
 
Method Summary
protected  void addChildService(Object childService)
           
protected  void doResume()
          Implementations override this method to support customized suspend/resume.
protected  void doShutdown()
          Implementations override this method to perform customized shutdown
protected abstract  void doStart()
           
protected abstract  void doStop()
           
protected  void doSuspend()
          Implementations override this method to support customized suspend/resume.
 ServiceStatus getStatus()
          Returns the current status
 String getVersion()
          Returns the version of this service
 boolean isRunAllowed()
          Helper methods so the service knows if it should keep running.
 boolean isStarted()
           
 boolean isStarting()
           
 boolean isStopped()
           
 boolean isStopping()
           
 boolean isSuspended()
           
 boolean isSuspending()
           
protected  boolean removeChildService(Object childService)
           
 void resume()
           
 void shutdown()
          Shutdown the service, which means it cannot be started again.
 void start()
          Starts the service
 void start(boolean startChildren)
           
 void stop()
          Stops the service
 void suspend()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceSupport

public ServiceSupport()
Method Detail

start

public void start()
           throws Exception
Description copied from interface: Service
Starts the service

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

start

public void start(boolean startChildren)
           throws Exception
Throws:
Exception

stop

public void stop()
          throws Exception
Description copied from interface: Service
Stops the service

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

suspend

public void suspend()
             throws Exception
Throws:
Exception

resume

public void resume()
            throws Exception
Throws:
Exception

shutdown

public void shutdown()
              throws Exception
Description copied from interface: ShutdownableService
Shutdown the service, which means it cannot be started again.

Specified by:
shutdown in interface ShutdownableService
Throws:
Exception - is thrown if shutting down failed

getStatus

public ServiceStatus getStatus()
Returns the current status


isStarted

public boolean isStarted()
Returns:
true if this service has been started

isStarting

public boolean isStarting()
Returns:
true if this service is being started

isStopping

public boolean isStopping()
Returns:
true if this service is in the process of stopping

isStopped

public boolean isStopped()
Returns:
true if this service is stopped

isSuspending

public boolean isSuspending()
Returns:
true if this service is in the process of suspending

isSuspended

public boolean isSuspended()
Returns:
true if this service is suspended

isRunAllowed

public boolean isRunAllowed()
Helper methods so the service knows if it should keep running. Returns false if the service is being stopped or is stopped.

Returns:
true if the service should continue to run.

doStart

protected abstract void doStart()
                         throws Exception
Throws:
Exception

doStop

protected abstract void doStop()
                        throws Exception
Throws:
Exception

doSuspend

protected void doSuspend()
                  throws Exception
Implementations override this method to support customized suspend/resume.

Throws:
Exception

doResume

protected void doResume()
                 throws Exception
Implementations override this method to support customized suspend/resume.

Throws:
Exception

doShutdown

protected void doShutdown()
                   throws Exception
Implementations override this method to perform customized shutdown

Throws:
Exception

addChildService

protected void addChildService(Object childService)

removeChildService

protected boolean removeChildService(Object childService)

getVersion

public String getVersion()
Returns the version of this service



Apache CAMEL