org.apache.camel.impl
Class ServiceSupport

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
All Implemented Interfaces:
Service
Direct Known Subclasses:
BatchProcessor, BeanProcessor, ChoiceProcessor, CompositeProcessor, DefaultCamelContext, DefaultComponent, DefaultConsumer, DefaultInstrumentationAgent, DefaultProducer, DefaultProducerTemplate, DelegateAsyncProcessor, DelegateProcessor, ErrorHandlerSupport, IdempotentConsumer, LoadBalancerSupport, MainSupport, MulticastProcessor, PollingConsumerSupport, ProducerCache, RecipientList, RoutingSlip, SedaConsumer, SendProcessor, StreamResequencer, TryProcessor

public abstract class ServiceSupport
extends Object
implements Service

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

Version:
$Revision: 1856 $

Constructor Summary
ServiceSupport()
           
 
Method Summary
protected  void addChildService(Object childService)
           
protected abstract  void doStart()
           
protected abstract  void doStop()
           
protected  String getThreadName(String prefix)
          Creates a new thread name with the given prefix
protected  String getVersion()
           
protected  boolean isRunAllowed()
          Helper methods so the service knows if it should keep running.
 boolean isStarted()
           
 boolean isStarting()
           
 boolean isStopped()
           
 boolean isStopping()
           
protected static int nextThreadCounter()
           
protected  boolean removeChildService(Object childService)
           
 void start()
          Starts the service
 void stop()
          Stops the service
 
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

stop

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

Specified by:
stop in interface Service
Throws:
Exception

isStarted

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

isStarting

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

isStopping

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

isRunAllowed

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

isStopped

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

doStart

protected abstract void doStart()
                         throws Exception
Throws:
Exception

doStop

protected abstract void doStop()
                        throws Exception
Throws:
Exception

getThreadName

protected String getThreadName(String prefix)
Creates a new thread name with the given prefix


nextThreadCounter

protected static int nextThreadCounter()

addChildService

protected void addChildService(Object childService)

removeChildService

protected boolean removeChildService(Object childService)

getVersion

protected String getVersion()


Copyright © 2009 IONA Open Source Community. All Rights Reserved.