org.jbpm.kie.services.impl.bpmn2.builder.dialect

## Class ThreadLocalAbstractBuilderFacade<T>

- java.lang.Object
- - org.jbpm.kie.services.impl.bpmn2.builder.dialect.ThreadLocalAbstractBuilderFacade<T>

- Type Parameters:
    `T` - The Builder type, one of the following: `ActionBuilder`, `ReturnValueEvaluatorBuilder`, `AssignmentBuilder` or `ProcessClassBuilder`.
  Direct Known Subclasses:
    ThreadLocalMvelActionBuilder, ThreadLocalMvelReturnValueBuilder

      public abstract class ThreadLocalAbstractBuilderFacade<T>
      extends Object

  For every thread in which the `BPMN2DataServiceImpl` instance collects process information, we use the same `DataServiceExpressionBuilder` instance. This happens because of the `ThreadLocal`<DataServiceExpressionBuilder> field in the implementations of this class.

  However, the `DataServiceExpressionBuilder` instance also contains a `ThreadLocal` variable to store `ProcessDescRepoHelper` instances. That way we can use a particular thread local `ProcessDescRepoHelper` instance per thread to save all the information for the particular process being built: see `useDataServiceBuilder(ProcessDescRepoHelper)`.

  The main reason for this architecture is that the jbpm-flow/jbpm-bpmn2 infrastructure calls `ProcessDialectRegistry.getDialect(String)` directly -- while the data service only needs to replace the result of the `ProcessDialect.getActionBuilder()` and similar methods.

  The logic looks like this:

  - The `BPMN2DataServiceImpl` sets the thread-local `ProcessDescRepoHelper` instance on the various builders (via this class)
  - When `KnowledgeBuilder` is processing a definition, `ProcessDialectRegistry.getDialect(String)` is called when a script or expression is encountered.
  - `ProcessDialectRegistry.getDialect(String)` returns a data service implemenation of a dialect, for example: `DataServiceJavaProcessDialect`.
  - `ProcessDialect.getActionBuilder()` returns the (singleton) `ThreadLocalAbstractBuilderFacade` implementation of the `ActionBuilder` instance
  - When the build(...) method on the `ActionBuilder` instance is called, it collects information into the thread-local `ProcessDescRepoHelper` instance
  - After the process definition has been compiled, the thread-local `ActionBuilder` field in the `ThreadLocalAbstractBuilderFacade` implementation is reset to the defaul `JavaActionBuilder`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ThreadLocalAbstractBuilderFacade()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract DataServiceExpressionBuilder` | `getDataServiceBuilderInstance()`
    `abstract T` | `getDefaultBuilderInstance()`
    `abstract T` | `getThreadLocalBuilder()`
    `void` | `resetThreadLocalBuilder()`
    `abstract void` | `setThreadLocalBuilder(T actionBuilder)`
    `void` | `useDataServiceBuilder(ProcessDescRepoHelper helper)`

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

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

- - ### Constructor Detail

    - #### ThreadLocalAbstractBuilderFacade

          public ThreadLocalAbstractBuilderFacade()

  - ### Method Detail

    - #### getThreadLocalBuilder

          public abstract T getThreadLocalBuilder()

    - #### setThreadLocalBuilder

          public abstract void setThreadLocalBuilder(T actionBuilder)

    - #### getDataServiceBuilderInstance

          public abstract DataServiceExpressionBuilder getDataServiceBuilderInstance()

    - #### getDefaultBuilderInstance

          public abstract T getDefaultBuilderInstance()

    - #### useDataServiceBuilder

          public void useDataServiceBuilder(ProcessDescRepoHelper helper)

    - #### resetThreadLocalBuilder

          public void resetThreadLocalBuilder()

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