org.apache.camel.util
Class ServiceHelper

java.lang.Object
  extended by org.apache.camel.util.ServiceHelper

public final class ServiceHelper
extends Object

A collection of helper methods for working with Service objects

Version:

Method Summary
static Set<Service> getChildServices(Service service)
          Gather all child services by navigating the service to recursively gather all child services.
static boolean isStarted(Object value)
          Is the given service starting or started?
static boolean isStopped(Object value)
          Is the given service stopping or stopped?
static boolean isSuspended(Object value)
          Is the given service suspended
static boolean resumeService(Service service)
          Resumes the given service.
static void resumeServices(Collection<?> services)
           
static void startService(Object value)
          Starts all of the given services
static void startService(Service service)
          Starts all of the given services
static void startServices(Collection<?> services)
          Starts all of the given services
static void startServices(Object... services)
          Starts all of the given services
static void stopAndShutdownService(Object value)
          Stops and shutdowns all of the given services, throwing the first exception caught
static void stopAndShutdownServices(Collection<?> services)
          Stops and shutdowns all of the given services, throwing the first exception caught
static void stopAndShutdownServices(Object... services)
          Stops and shutdowns all of the given services, throwing the first exception caught
static void stopService(Object value)
          Stops all of the given services, throwing the first exception caught
static void stopServices(Collection<?> services)
          Stops all of the given services, throwing the first exception caught
static void stopServices(Object... services)
          Stops all of the given services, throwing the first exception caught
static boolean suspendService(Service service)
          Suspends the given service.
static void suspendServices(Collection<?> services)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

startService

public static void startService(Object value)
                         throws Exception
Starts all of the given services

Throws:
Exception

startService

public static void startService(Service service)
                         throws Exception
Starts all of the given services

Throws:
Exception

startServices

public static void startServices(Object... services)
                          throws Exception
Starts all of the given services

Throws:
Exception

startServices

public static void startServices(Collection<?> services)
                          throws Exception
Starts all of the given services

Throws:
Exception

stopServices

public static void stopServices(Object... services)
                         throws Exception
Stops all of the given services, throwing the first exception caught

Throws:
Exception

stopService

public static void stopService(Object value)
                        throws Exception
Stops all of the given services, throwing the first exception caught

Throws:
Exception

stopServices

public static void stopServices(Collection<?> services)
                         throws Exception
Stops all of the given services, throwing the first exception caught

Throws:
Exception

stopAndShutdownServices

public static void stopAndShutdownServices(Object... services)
                                    throws Exception
Stops and shutdowns all of the given services, throwing the first exception caught

Throws:
Exception

stopAndShutdownService

public static void stopAndShutdownService(Object value)
                                   throws Exception
Stops and shutdowns all of the given services, throwing the first exception caught

Throws:
Exception

stopAndShutdownServices

public static void stopAndShutdownServices(Collection<?> services)
                                    throws Exception
Stops and shutdowns all of the given services, throwing the first exception caught

Throws:
Exception

resumeServices

public static void resumeServices(Collection<?> services)
                           throws Exception
Throws:
Exception

resumeService

public static boolean resumeService(Service service)
                             throws Exception
Resumes the given service.

If the service is a SuspendableService then the resume operation is only invoked if the service is suspended.

If the service is a ServiceSupport then the start operation is only invoked if the service is startable.

Otherwise the service is started.

Parameters:
service - the service
Returns:
true if either resume or start was invoked, false if the service is already in the desired state.
Throws:
Exception - is thrown if error occurred

suspendServices

public static void suspendServices(Collection<?> services)
                            throws Exception
Throws:
Exception

suspendService

public static boolean suspendService(Service service)
                              throws Exception
Suspends the given service.

If the service is a SuspendableService then the suspend operation is only invoked if the service is not suspended.

If the service is a ServiceSupport then the stop operation is only invoked if the service is stoppable.

Otherwise the service is stopped.

Parameters:
service - the service
Returns:
true if either suspend or stop was invoked, false if the service is already in the desired state.
Throws:
Exception - is thrown if error occurred

isStopped

public static boolean isStopped(Object value)
Is the given service stopping or stopped?

Returns:
true if already stopped, otherwise false

isStarted

public static boolean isStarted(Object value)
Is the given service starting or started?

Returns:
true if already started, otherwise false

isSuspended

public static boolean isSuspended(Object value)
Is the given service suspended

Returns:
true if already suspended, otherwise false

getChildServices

public static Set<Service> getChildServices(Service service)
Gather all child services by navigating the service to recursively gather all child services.

Parameters:
service - the service
Returns:
the services, including the parent service, and all its children


Apache CAMEL