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 a `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.
  - See the `LoggingTaskHandlerDecorator.WorkItemExceptionInfo` class for more information.
  - The list of `LoggingTaskHandlerDecorator.WorkItemExceptionInfo` classes is available via the `getWorkItemExceptionInfoList()` method.
  After the exception info has been saved, this class then logs a message the appropriate information via `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.

- - ### Nested Class Summary

    Nested Classes
    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 Summary

    Constructors
    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.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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)`

    - ### Methods inherited from class org.jbpm.bpmn2.handler.AbstractExceptionHandlingTaskHandler

      `abortWorkItem, executeWorkItem, getOriginalTaskHandler`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LoggingTaskHandlerDecorator

          public 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. This instance will only keep the given number of `LoggingTaskHandlerDecorator.WorkItemExceptionInfo` instances instead of the default 100.
      Parameters:
        `originalTaskHandlerClass` -
        `logLimit` -

    - #### LoggingTaskHandlerDecorator

          public LoggingTaskHandlerDecorator(Class<? extends org.kie.api.runtime.process.WorkItemHandler> originalTaskHandlerClass)

      Constructs an `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()`;
      Parameters:
        `originalTaskHandlerClass` -

    - #### LoggingTaskHandlerDecorator

          public LoggingTaskHandlerDecorator(org.kie.api.runtime.process.WorkItemHandler originalTaskHandler)

      Constructs a `LoggingTaskHandlerDecorator` instance that wraps the given `WorkItemHandler` instance. This instance will only keep a refere
      Parameters:
        `originalTaskHandler` -

  - ### Method Detail

    - #### setLoggedMessageFormat

          public void setLoggedMessageFormat(String logMessageFormat)

      Sets the `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}.`
      0. The name of the interface used for the <serviceTask>
      1. The name of the operation used for the <serviceTask>
      2. The simple name of the class of the exception thrown
      3. "excut" or "abort" depending on the WorkItemHandler method called
      4. The work item id
      5. The process instance id
      For all other `WorkItemHandler` implementations, the format is:
      `{0} thrown when work item {1} ({2}) was {3}ed in process instance {4}.`
      where the parameters are the following:
      0. The (simple) class name of the exception
      1. The work item id
      2. The name of the work item
      3. "excut" or "abort" depending on the WorkItemHandler method called
      4. 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 in `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.
      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:
        `handleExecuteException` in class `AbstractExceptionHandlingTaskHandler`

    - #### handleAbortException

          public void handleAbortException(Throwable cause,
                                           org.kie.api.runtime.process.WorkItem workItem,
                                           org.kie.api.runtime.process.WorkItemManager manager)

      Specified by:
        `handleAbortException` in class `AbstractExceptionHandlingTaskHandler`

Copyright © 2001–2018 JBoss by Red Hat. All rights reserved.