Package org.freedesktop.dbus.connections
Class ReceivingService
- java.lang.Object
-
- org.freedesktop.dbus.connections.ReceivingService
-
public class ReceivingService extends java.lang.ObjectService providing threads for every type of message expected to be received by DBus.- Version:
- 4.1.0 - 2022-02-02
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReceivingService.ExecutorNamesEnum representing different executor services.static interfaceReceivingService.IThreadPoolRetryHandlerInterface which specifies a handler which will be called when the thread pool throws any exception.
-
Field Summary
Fields Modifier and Type Field Description private booleanclosedprivate java.util.Map<ReceivingService.ExecutorNames,java.util.concurrent.ExecutorService>executorsprivate org.slf4j.Loggerlogger(package private) static intMAX_RETRIESprivate ReceivingService.IThreadPoolRetryHandlerretryHandler
-
Constructor Summary
Constructors Constructor Description ReceivingService(ReceivingServiceConfig _rsCfg)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) intexecErrorHandler(java.lang.Runnable _r)Execute a runnable which handles an error.(package private) intexecMethodCallHandler(java.lang.Runnable _r)Execute a runnable which handles a method call.(package private) intexecMethodReturnHandler(java.lang.Runnable _r)Execute a runnable which handles the return of a method.(package private) intexecOrFail(ReceivingService.ExecutorNames _executor, java.lang.Runnable _r)Executes a runnable in a given executor.(package private) intexecSignalHandler(java.lang.Runnable _r)Execute a runnable which handles a signal.(package private) java.util.concurrent.ExecutorServicegetExecutor(ReceivingService.ExecutorNames _executor)Returns the executor or null.voidshutdown(int _timeout, java.util.concurrent.TimeUnit _unit)Shutdown all executor services waiting up to the given timeout/unit.voidshutdownNow()Forcefully stop the executors.
-
-
-
Field Detail
-
MAX_RETRIES
static final int MAX_RETRIES
- See Also:
- Constant Field Values
-
logger
private final org.slf4j.Logger logger
-
closed
private boolean closed
-
executors
private final java.util.Map<ReceivingService.ExecutorNames,java.util.concurrent.ExecutorService> executors
-
retryHandler
private final ReceivingService.IThreadPoolRetryHandler retryHandler
-
-
Constructor Detail
-
ReceivingService
ReceivingService(ReceivingServiceConfig _rsCfg)
Creates a new instance.- Parameters:
_rsCfg- configuration
-
-
Method Detail
-
execSignalHandler
int execSignalHandler(java.lang.Runnable _r)
Execute a runnable which handles a signal.- Parameters:
_r- runnable- Returns:
- retries, if any input was null -1 is returned
-
execErrorHandler
int execErrorHandler(java.lang.Runnable _r)
Execute a runnable which handles an error.- Parameters:
_r- runnable- Returns:
- retries, if any input was null -1 is returned
-
execMethodCallHandler
int execMethodCallHandler(java.lang.Runnable _r)
Execute a runnable which handles a method call.- Parameters:
_r- runnable- Returns:
- retries, if any input was null -1 is returned
-
execMethodReturnHandler
int execMethodReturnHandler(java.lang.Runnable _r)
Execute a runnable which handles the return of a method.- Parameters:
_r- runnable- Returns:
- retries, if any input was null -1 is returned
-
execOrFail
int execOrFail(ReceivingService.ExecutorNames _executor, java.lang.Runnable _r)
Executes a runnable in a given executor. May retry execution ifExecutorServicehas thrown an exception and retry handler allows re-processing. When re-processing fails for 50 or more retries, an error will be logged and the runnable will not be executed.- Parameters:
_executor- executor to use_r- runnable- Returns:
- retries, if any input was null -1 is returned
-
getExecutor
java.util.concurrent.ExecutorService getExecutor(ReceivingService.ExecutorNames _executor)
Returns the executor or null.- Parameters:
_executor- executor to use- Returns:
- executor or null
-
shutdown
public void shutdown(int _timeout, java.util.concurrent.TimeUnit _unit)Shutdown all executor services waiting up to the given timeout/unit.- Parameters:
_timeout- timeout_unit- time unit
-
shutdownNow
public void shutdownNow()
Forcefully stop the executors.
-
-