Package org.apache.camel.support.service
Class ServiceHelper
- java.lang.Object
-
- org.apache.camel.support.service.ServiceHelper
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbuildService(Object value)Builds the givenvalueif it's aServiceor a collection of it.static voidbuildService(Object... services)Builds each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.static Set<Service>getChildServices(Service service)Gathers all child services by navigating the service to recursively gather all child services.static Set<Service>getChildServices(Service service, boolean includeErrorHandler)Gathers all child services by navigating the service to recursively gather all child services.static voidinitService(Object value)Initializes the givenvalueif it's aServiceor a collection of it.static voidinitService(Object... services)Initializes each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.static booleanisStarted(Object value)Is the given service starting or already started?static booleanisStopped(Object value)Is the given service stopping or already stopped?static booleanisSuspended(Object value)Is the given service suspending or already suspended?static booleanresumeService(Object service)Resumes the givenservice.static voidresumeServices(Collection<?> services)Resumes each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.static voidstartService(Object value)Starts the givenvalueif it's aServiceor a collection of it.static voidstartService(Object... services)Starts each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.static voidstopAndShutdownService(Object value)Stops and shutdowns the givenservice, rethrowing the first exception caught.static voidstopAndShutdownServices(Object... services)Stops and shutdowns each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.static voidstopAndShutdownServices(Collection<?> services)Stops and shutdowns each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.static voidstopService(Object value)Stops the givenvalue, rethrowing the first exception caught.static voidstopService(Object... services)Stops each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.static voidstopService(Collection<?> services)Stops each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.static booleansuspendService(Object service)Suspends the givenservice.static voidsuspendServices(Collection<?> services)Suspends each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.
-
-
-
Method Detail
-
buildService
public static void buildService(Object value)
Builds the givenvalueif it's aServiceor a collection of it. Calling this method has no effect ifvalueisnull.
-
buildService
public static void buildService(Object... services)
Builds each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.- See Also:
buildService(Object)
-
initService
public static void initService(Object value)
Initializes the givenvalueif it's aServiceor a collection of it. Calling this method has no effect ifvalueisnull.
-
initService
public static void initService(Object... services)
Initializes each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.- See Also:
initService(Object)
-
startService
public static void startService(Object value)
Starts the givenvalueif it's aServiceor a collection of it. Calling this method has no effect ifvalueisnull.
-
startService
public static void startService(Object... services)
Starts each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately.- See Also:
startService(Object)
-
stopService
public static void stopService(Object... services)
Stops each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately. If there's any exception being thrown while stopping the elements one after the other this method would rethrow the first such exception being thrown.- See Also:
stopService(Collection)
-
stopService
public static void stopService(Object value)
Stops the givenvalue, rethrowing the first exception caught. Calling this method has no effect ifvalueisnull.- See Also:
Service.stop(),stopService(Collection)
-
stopService
public static void stopService(Collection<?> services)
Stops each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately. If there's any exception being thrown while stopping the elements one after the other this method would rethrow the first such exception being thrown.- See Also:
stopService(Object)
-
stopAndShutdownServices
public static void stopAndShutdownServices(Object... services)
Stops and shutdowns each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately. If there's any exception being thrown while stopping/shutting down the elements one after the other this method would rethrow the first such exception being thrown.- See Also:
stopAndShutdownServices(Collection)
-
stopAndShutdownService
public static void stopAndShutdownService(Object value)
Stops and shutdowns the givenservice, rethrowing the first exception caught. Calling this method has no effect ifvalueisnull.
-
stopAndShutdownServices
public static void stopAndShutdownServices(Collection<?> services)
Stops and shutdowns each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately. If there's any exception being thrown while stopping/shutting down the elements one after the other this method would rethrow the first such exception being thrown.
-
resumeServices
public static void resumeServices(Collection<?> services)
Resumes each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately. If there's any exception being thrown while resuming the elements one after the other this method would rethrow the first such exception being thrown.- See Also:
resumeService(Object)
-
resumeService
public static boolean resumeService(Object service)
Resumes the givenservice. Ifserviceis bothSuspendableandSuspendableServicethen itsSuspendableService.resume()is called but only ifserviceis alreadysuspended. Ifserviceis not aSuspendableandSuspendableServicethen itsService.start()is called. Calling this method has no effect ifserviceisnull.- Parameters:
service- the service- Returns:
- true if either resume method or
startService(Object)was called, false otherwise. - Throws:
Exception- is thrown if error occurred- See Also:
startService(Object)
-
suspendServices
public static void suspendServices(Collection<?> services)
Suspends each element of the givenservicesifservicesitself is notnull, otherwise this method would return immediately. If there's any exception being thrown while suspending the elements one after the other this method would rethrow the first such exception being thrown.- See Also:
suspendService(Object)
-
suspendService
public static boolean suspendService(Object service)
Suspends the givenservice. Ifserviceis bothSuspendableandSuspendableServicethen itsSuspendableService.suspend()is called but only ifserviceis not alreadysuspended. Ifserviceis not aSuspendableandSuspendableServicethen itsService.stop()is called. Calling this method has no effect ifserviceisnull.- Parameters:
service- the service- Returns:
- true if either the suspend method or
stopService(Object)was called, false otherwise. - Throws:
Exception- is thrown if error occurred- See Also:
stopService(Object)
-
isStopped
public static boolean isStopped(Object value)
Is the given service stopping or already stopped?- Returns:
- true if stopping or already stopped, false otherwise
- See Also:
StatefulService.isStopping(),StatefulService.isStopped()
-
isStarted
public static boolean isStarted(Object value)
Is the given service starting or already started?- Returns:
- true if starting or already started, false otherwise
- See Also:
StatefulService.isStarting(),StatefulService.isStarted()
-
isSuspended
public static boolean isSuspended(Object value)
Is the given service suspending or already suspended?- Returns:
- true if suspending or already suspended, false otherwise
- See Also:
StatefulService.isSuspending(),SuspendableService.isSuspended()
-
getChildServices
public static Set<Service> getChildServices(Service service)
Gathers all child services by navigating the service to recursively gather all child services. The returned set does not include the children being error handler.- Parameters:
service- the service- Returns:
- the services, including the parent service, and all its children
-
getChildServices
public static Set<Service> getChildServices(Service service, boolean includeErrorHandler)
Gathers all child services by navigating the service to recursively gather all child services.- Parameters:
service- the serviceincludeErrorHandler- whether to include error handlers- Returns:
- the services, including the parent service, and all its children
-
-