org.jbpm.runtime.manager.impl

## Class SingletonRuntimeManager

- java.lang.Object
- - org.jbpm.runtime.manager.impl.AbstractRuntimeManager
  - - org.jbpm.runtime.manager.impl.SingletonRuntimeManager

- All Implemented Interfaces:
    org.kie.api.runtime.manager.RuntimeManager, org.kie.internal.runtime.manager.InternalRuntimeManager

      public class SingletonRuntimeManager
      extends AbstractRuntimeManager

  This RuntimeManager is backed by a "Singleton" strategy, meaning that only one `RuntimeEngine` instance will exist for for the given RuntimeManager instance. The RuntimeEngine will be synchronized to make sure it will work properly in multi-threaded environments. However, this might cause some performance issues due to sequential execution.
  An important aspect of this manager is that it will persists it's identifier as a temporary file to keep track of the `KieSession` it was using to maintain its state: for example, the session state including (drools) facts, etc. The mentioned file is named as follows:
  `manager.getIdentifier()-jbpmSessionId.ser` For example, for default named manager it will be:
  default-singleton-jbpmSessionId.ser
  The location of the file will be one of the following, it is resolved in below order:
  - system property named: jbpm.data.dir
  - system property named: jboss.server.data.dir - shall be used by default on JBoss AS
  - system property named: java.io.tmpdir
  In case there is a need to reset the state, simply removing of the *-jbpm.SessionId.ser from the mentioned location will do the trick.

- - ### Field Summary

    - ### Fields inherited from class org.jbpm.runtime.manager.impl.AbstractRuntimeManager

      `cacheManager, closed, deploymentDescriptor, engineInitEager, engineLocks, environment, executionErrorManager, identifier, kieContainer, registry, securityManager`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SingletonRuntimeManager()`
    `SingletonRuntimeManager(org.kie.api.runtime.manager.RuntimeEnvironment environment, org.kie.internal.runtime.manager.SessionFactory factory, org.kie.internal.runtime.manager.TaskServiceFactory taskServiceFactory, String identifier)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `activate()`
    `void` | `close()`
    `void` | `deactivate()`
    `void` | `disposeRuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine runtime)`
    `org.kie.internal.runtime.manager.SessionFactory` | `getFactory()`
    `protected String` | `getLocation()`
    `protected Long` | `getPersistedSessionId(String location, String identifier)` Retrieves session id from serialized file named jbpmSessionId.ser from given location.
    `org.kie.api.runtime.manager.RuntimeEngine` | `getRuntimeEngine(org.kie.api.runtime.manager.Context context)`
    `org.kie.internal.runtime.manager.TaskServiceFactory` | `getTaskServiceFactory()`
    `void` | `init()`
    `protected void` | `persistSessionId(String location, String identifier, Long ksessionId)` Stores gives ksessionId in a serialized file in given location under jbpmSessionId.ser file name
    `void` | `setFactory(org.kie.internal.runtime.manager.SessionFactory factory)`
    `void` | `setTaskServiceFactory(org.kie.internal.runtime.manager.TaskServiceFactory taskServiceFactory)`
    `void` | `signalEvent(String type, Object event)`
    `void` | `validate(org.kie.api.runtime.KieSession ksession, org.kie.api.runtime.manager.Context<?> context)`

    - ### Methods inherited from class org.jbpm.runtime.manager.impl.AbstractRuntimeManager

      `attachManager, canDestroy, canDispose, checkPermission, close, configureRuntimeOnTaskService, createLockOnGetEngine, createLockOnGetEngine, createLockOnNewProcessInstance, getCacheManager, getDeploymentDescriptor, getEnvironment, getExecutionErrorManager, getIdentifier, getKieContainer, getTransactionManager, getTransactionManagerInternal, hasEnvironmentEntry, hasSecurityManager, isActive, isClosed, isUseLocking, newTaskService, registerDisposeCallback, registerItems, releaseAndCleanLock, releaseAndCleanLock, removeRuntimeFromTaskService, setCacheManager, setDeploymentDescriptor, setEnvironment, setIdentifier, setKieContainer, setSecurityManager, softDispose`

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

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

- - ### Constructor Detail

    - #### SingletonRuntimeManager

          public SingletonRuntimeManager()

    - #### SingletonRuntimeManager

          public SingletonRuntimeManager(org.kie.api.runtime.manager.RuntimeEnvironment environment,
                                         org.kie.internal.runtime.manager.SessionFactory factory,
                                         org.kie.internal.runtime.manager.TaskServiceFactory taskServiceFactory,
                                         String identifier)

  - ### Method Detail

    - #### init

          public void init()

      Specified by:
        `init` in class `AbstractRuntimeManager`

    - #### activate

          public void activate()

      Specified by:
        `activate` in interface `org.kie.internal.runtime.manager.InternalRuntimeManager`
      Overrides:
        `activate` in class `AbstractRuntimeManager`

    - #### deactivate

          public void deactivate()

      Specified by:
        `deactivate` in interface `org.kie.internal.runtime.manager.InternalRuntimeManager`
      Overrides:
        `deactivate` in class `AbstractRuntimeManager`

    - #### getRuntimeEngine

          public org.kie.api.runtime.manager.RuntimeEngine getRuntimeEngine(org.kie.api.runtime.manager.Context context)

    - #### signalEvent

          public void signalEvent(String type,
                                  Object event)

    - #### validate

          public void validate(org.kie.api.runtime.KieSession ksession,
                               org.kie.api.runtime.manager.Context<?> context)
                        throws IllegalStateException

      Throws:
        `IllegalStateException`

    - #### disposeRuntimeEngine

          public void disposeRuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine runtime)

    - #### close

          public void close()

      Specified by:
        `close` in interface `org.kie.api.runtime.manager.RuntimeManager`
      Overrides:
        `close` in class `AbstractRuntimeManager`

    - #### getPersistedSessionId

          protected Long getPersistedSessionId(String location,
                                               String identifier)

      Retrieves session id from serialized file named jbpmSessionId.ser from given location.
      Parameters:
        `location` - directory where jbpmSessionId.ser file should be
        `identifier` - of the manager owning this ksessionId
      Returns:
        sessionId if file was found otherwise 0

    - #### persistSessionId

          protected void persistSessionId(String location,
                                          String identifier,
                                          Long ksessionId)

      Stores gives ksessionId in a serialized file in given location under jbpmSessionId.ser file name
      Parameters:
        `location` - directory where serialized file should be stored
        `identifier` - of the manager owning this ksessionId
        `ksessionId` - value of ksessionId to be stored

    - #### getLocation

          protected String getLocation()

    - #### getFactory

          public org.kie.internal.runtime.manager.SessionFactory getFactory()

      Specified by:
        `getFactory` in class `AbstractRuntimeManager`

    - #### setFactory

          public void setFactory(org.kie.internal.runtime.manager.SessionFactory factory)

    - #### getTaskServiceFactory

          public org.kie.internal.runtime.manager.TaskServiceFactory getTaskServiceFactory()

    - #### setTaskServiceFactory

          public void setTaskServiceFactory(org.kie.internal.runtime.manager.TaskServiceFactory taskServiceFactory)

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