public class LoggingTaskHandlerDecorator extends AbstractExceptionHandlingTaskHandler
WorkItemHandler implementation that is meant to wrap
other WorkItemHandler implementations.
When an exception is thrown by the wrapped WorkItemHandler
instance, it's added to a list of LoggingTaskHandlerDecorator.WorkItemExceptionInfo instances
that contain as much information as possible about the exception, the
WorkItem that caused the exception and the ProcessInstance id
of the process in which the exception was thrown.
LoggingTaskHandlerDecorator.WorkItemExceptionInfo class for more information.LoggingTaskHandlerDecorator.WorkItemExceptionInfo classes is available via the
getWorkItemExceptionInfoList() method.Logger.warn(String). The message
logged is configurable: see
setLoggedMessageFormat(String) for more
information.
This class is thread-safe, although it does not take any responsibility
for the WorkItemHandler that it wraps. If you are using this with
multiple threads, please make sure the the WorkItemHandler instance
wrapped is also thread-safe.| Modifier and Type | Class and Description |
|---|---|
static class |
LoggingTaskHandlerDecorator.InputParameter
Type of input parameter that will be used in the
MessageFormat string set in
setLoggedMessageFormat(String). |
class |
LoggingTaskHandlerDecorator.WorkItemExceptionInfo |
| Constructor and Description |
|---|
LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass)
Constructs an
LoggingTaskHandlerDecorator instance that wraps a
created instance of the WorkItemHandler class given. |
LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass,
int logLimit)
Constructs an
LoggingTaskHandlerDecorator instance that wraps a
created instance of the WorkItemHandler class given. |
LoggingTaskHandlerDecorator(org.kie.api.runtime.process.WorkItemHandler originalTaskHandler)
Constructs a
LoggingTaskHandlerDecorator instance that wraps the
given WorkItemHandler instance. |
| Modifier and Type | Method and Description |
|---|---|
List<LoggingTaskHandlerDecorator.WorkItemExceptionInfo> |
getWorkItemExceptionInfoList() |
void |
handleAbortException(Throwable cause,
org.kie.api.runtime.process.WorkItem workItem,
org.kie.api.runtime.process.WorkItemManager manager) |
void |
handleExecuteException(Throwable cause,
org.kie.api.runtime.process.WorkItem workItem,
org.kie.api.runtime.process.WorkItemManager manager) |
void |
setLoggedExceptionInfoListSize(int loggedExceptionInfoListSize) |
void |
setLoggedMessageFormat(String logMessageFormat)
Sets the
MessageFormat string to be used to format the log
messages. |
void |
setLoggedMessageInput(List<LoggingTaskHandlerDecorator.InputParameter> inputParameterList)
Sets the list of parameter types used for the log message format that is set in
setLoggedMessageFormat(String). |
void |
setPrintStackTrace(boolean printStackTrace) |
abortWorkItem, executeWorkItem, getOriginalTaskHandlerpublic LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass, int logLimit)
LoggingTaskHandlerDecorator instance that wraps a
created instance of the WorkItemHandler class given. This
instance will only keep the given number of LoggingTaskHandlerDecorator.WorkItemExceptionInfo
instances instead of the default 100.originalTaskHandlerClass - logLimit - public LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass)
LoggingTaskHandlerDecorator instance that wraps a
created instance of the WorkItemHandler class given. Only
information about the last 100 exceptions will be held in the list
available from
getWorkItemExceptionInfoList();originalTaskHandlerClass - public LoggingTaskHandlerDecorator(org.kie.api.runtime.process.WorkItemHandler originalTaskHandler)
LoggingTaskHandlerDecorator instance that wraps the
given WorkItemHandler instance. This instance will only keep a
refereoriginalTaskHandler - public void setLoggedMessageFormat(String logMessageFormat)
MessageFormat string to be used to format the log
messages. If this method is used, it's a good idea to also use the
setLoggedMessageInput(List) method.
The default MessageFormat string used is one of the
following:
If the WorkItemHandler is a ServiceTaskHandler (that
is used with <serviceTask> nodes), then the format is:
{0}.{1} threw {2} when {3}ing work item {4} in process instance {5}.
WorkItemHandler implementations, the format is:
{0} thrown when work item {1} ({2}) was {3}ed in process instance {4}.
logMessageFormat - The format to use for logged messages.public void setLoggedMessageInput(List<LoggingTaskHandlerDecorator.InputParameter> inputParameterList)
setLoggedMessageFormat(String).
The order of the LoggingTaskHandlerDecorator.InputParameter value in the list corresponds to the MessageFormat number
used in the String given to setLoggedMessageFormat(String).
See LoggingTaskHandlerDecorator.InputParameter for more information.inputParameterList - public void setLoggedExceptionInfoListSize(int loggedExceptionInfoListSize)
public void setPrintStackTrace(boolean printStackTrace)
public List<LoggingTaskHandlerDecorator.WorkItemExceptionInfo> getWorkItemExceptionInfoList()
public void handleExecuteException(Throwable cause, org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
handleExecuteException in class AbstractExceptionHandlingTaskHandlerpublic void handleAbortException(Throwable cause, org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
handleAbortException in class AbstractExceptionHandlingTaskHandlerCopyright © 2001–2020 JBoss by Red Hat. All rights reserved.