Package org.jbpm.bpmn2.handler
Class LoggingTaskHandlerDecorator
- java.lang.Object
-
- org.jbpm.bpmn2.handler.AbstractExceptionHandlingTaskHandler
-
- org.jbpm.bpmn2.handler.LoggingTaskHandlerDecorator
-
- All Implemented Interfaces:
org.kie.api.runtime.process.WorkItemHandler
public class LoggingTaskHandlerDecorator extends AbstractExceptionHandlingTaskHandler
This class is aWorkItemHandlerimplementation that is meant to wrap otherWorkItemHandlerimplementations. When an exception is thrown by the wrappedWorkItemHandlerinstance, it's added to a list ofLoggingTaskHandlerDecorator.WorkItemExceptionInfoinstances that contain as much information as possible about the exception, theWorkItemthat caused the exception and theProcessInstanceid of the process in which the exception was thrown.- See the
LoggingTaskHandlerDecorator.WorkItemExceptionInfoclass for more information. - The list of
LoggingTaskHandlerDecorator.WorkItemExceptionInfoclasses is available via thegetWorkItemExceptionInfoList()method.
Logger.warn(String). The message logged is configurable: seesetLoggedMessageFormat(String)for more information. This class is thread-safe, although it does not take any responsibility for theWorkItemHandlerthat it wraps. If you are using this with multiple threads, please make sure the theWorkItemHandlerinstance wrapped is also thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLoggingTaskHandlerDecorator.InputParameterType of input parameter that will be used in theMessageFormatstring set insetLoggedMessageFormat(String).classLoggingTaskHandlerDecorator.WorkItemExceptionInfo
-
Constructor Summary
Constructors Constructor Description LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass)Constructs anLoggingTaskHandlerDecoratorinstance that wraps a created instance of theWorkItemHandlerclass given.LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass, int logLimit)Constructs anLoggingTaskHandlerDecoratorinstance that wraps a created instance of theWorkItemHandlerclass given.LoggingTaskHandlerDecorator(org.kie.api.runtime.process.WorkItemHandler originalTaskHandler)Constructs aLoggingTaskHandlerDecoratorinstance that wraps the givenWorkItemHandlerinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<LoggingTaskHandlerDecorator.WorkItemExceptionInfo>getWorkItemExceptionInfoList()voidhandleAbortException(Throwable cause, org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)voidhandleExecuteException(Throwable cause, org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)voidsetLoggedExceptionInfoListSize(int loggedExceptionInfoListSize)voidsetLoggedMessageFormat(String logMessageFormat)Sets theMessageFormatstring to be used to format the log messages.voidsetLoggedMessageInput(List<LoggingTaskHandlerDecorator.InputParameter> inputParameterList)Sets the list of parameter types used for the log message format that is set insetLoggedMessageFormat(String).voidsetPrintStackTrace(boolean printStackTrace)-
Methods inherited from class org.jbpm.bpmn2.handler.AbstractExceptionHandlingTaskHandler
abortWorkItem, executeWorkItem, getOriginalTaskHandler
-
-
-
-
Constructor Detail
-
LoggingTaskHandlerDecorator
public LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass, int logLimit)
Constructs anLoggingTaskHandlerDecoratorinstance that wraps a created instance of theWorkItemHandlerclass given. This instance will only keep the given number ofLoggingTaskHandlerDecorator.WorkItemExceptionInfoinstances instead of the default 100.- Parameters:
originalTaskHandlerClass-logLimit-
-
LoggingTaskHandlerDecorator
public LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass)
Constructs anLoggingTaskHandlerDecoratorinstance that wraps a created instance of theWorkItemHandlerclass given. Only information about the last 100 exceptions will be held in the list available fromgetWorkItemExceptionInfoList();- Parameters:
originalTaskHandlerClass-
-
LoggingTaskHandlerDecorator
public LoggingTaskHandlerDecorator(org.kie.api.runtime.process.WorkItemHandler originalTaskHandler)
Constructs aLoggingTaskHandlerDecoratorinstance that wraps the givenWorkItemHandlerinstance. This instance will only keep a refere- Parameters:
originalTaskHandler-
-
-
Method Detail
-
setLoggedMessageFormat
public void setLoggedMessageFormat(String logMessageFormat)
Sets theMessageFormatstring to be used to format the log messages. If this method is used, it's a good idea to also use thesetLoggedMessageInput(List)method. The defaultMessageFormatstring used is one of the following: If theWorkItemHandleris aServiceTaskHandler(that is used with<serviceTask>nodes), then the format is:{0}.{1} threw {2} when {3}ing work item {4} in process instance {5}.- The name of the interface used for the <serviceTask>
- The name of the operation used for the <serviceTask>
- The simple name of the class of the exception thrown
- "excut" or "abort" depending on the WorkItemHandler method called
- The work item id
- The process instance id
WorkItemHandlerimplementations, the format is:{0} thrown when work item {1} ({2}) was {3}ed in process instance {4}.- The (simple) class name of the exception
- The work item id
- The name of the work item
- "excut" or "abort" depending on the WorkItemHandler method called
- The process instance id
- Parameters:
logMessageFormat- The format to use for logged messages.
-
setLoggedMessageInput
public void setLoggedMessageInput(List<LoggingTaskHandlerDecorator.InputParameter> inputParameterList)
Sets the list of parameter types used for the log message format that is set insetLoggedMessageFormat(String). The order of theLoggingTaskHandlerDecorator.InputParametervalue in the list corresponds to theMessageFormatnumber used in the String given tosetLoggedMessageFormat(String). SeeLoggingTaskHandlerDecorator.InputParameterfor more information.- Parameters:
inputParameterList-
-
setLoggedExceptionInfoListSize
public void setLoggedExceptionInfoListSize(int loggedExceptionInfoListSize)
-
setPrintStackTrace
public void setPrintStackTrace(boolean printStackTrace)
-
getWorkItemExceptionInfoList
public List<LoggingTaskHandlerDecorator.WorkItemExceptionInfo> getWorkItemExceptionInfoList()
-
handleExecuteException
public void handleExecuteException(Throwable cause, org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
- Specified by:
handleExecuteExceptionin classAbstractExceptionHandlingTaskHandler
-
handleAbortException
public void handleAbortException(Throwable cause, org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
- Specified by:
handleAbortExceptionin classAbstractExceptionHandlingTaskHandler
-
-