Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| jBPM distribution 6.0.0-SNAPSHOT
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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:
  RuntimeManager, org.kie.internal.runtime.manager.InternalRuntimeManager

    public class SingletonRuntimeManager

extends AbstractRuntimeManager

RuntimeManager that is backed by "Singleton" strategy meaning only one `RuntimeEngine` instance will exist for for given RuntimeManager instance. The RuntimeEngine will be synchronized to make sure it will work properly in multi-thread environments but might cause some performance issues due to sequential execution.
Important aspect of this manager is that it will persists it's identifier as temporary file to keep track of the `KieSession` it was using to maintain its state - for example session state such as 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 can 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
`activeManagers, closed, environment, identifier`

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

Method Summary
`void` | `close()` Closes `RuntimeManager` and releases it's resources.
`void` | `disposeRuntimeEngine(RuntimeEngine runtime)` Disposes `RuntimeEngine` and notifies all listeners about that fact.
`org.kie.internal.runtime.manager.SessionFactory` | `getFactory()`
`protected String` | `getLocation()`
`protected int` | `getPersistedSessionId(String location, String identifier)` Retrieves session id from serialized file named jbpmSessionId.ser from given location.
`RuntimeEngine` | `getRuntimeEngine(Context context)` Returns `RuntimeEngine` instance that is fully initialized: KiseSession is created or loaded depending on the strategy TaskService is initialized and attached to ksession (via listener) WorkItemHandlers are initialized and registered on ksession EventListeners (process, agenda, working memory) are initialized and added to ksession
`org.kie.internal.runtime.manager.TaskServiceFactory` | `getTaskServiceFactory()`
`void` | `init()`
`protected void` | `persistSessionId(String location, String identifier, int 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` | `validate(KieSession ksession, Context<?> context)`

Methods inherited from class org.jbpm.runtime.manager.impl.AbstractRuntimeManager
`attachManager, canDestroy, close, configureRuntimeOnTaskService, getEnvironment, getIdentifier, isClosed, registerDisposeCallback, registerItems, removeRuntimeFromTaskService, setEnvironment, setIdentifier`

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(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`

### getRuntimeEngine

    public RuntimeEngine getRuntimeEngine(Context context)

  Description copied from interface: `RuntimeManager`
  Returns `RuntimeEngine` instance that is fully initialized:
  - KiseSession is created or loaded depending on the strategy
  - TaskService is initialized and attached to ksession (via listener)
  - WorkItemHandlers are initialized and registered on ksession
  - EventListeners (process, agenda, working memory) are initialized and added to ksession

  Parameters:
    `context` - the concrete implementation of the context that is supported by given `RuntimeManager`
  Returns:
    instance of the `RuntimeEngine`

### validate

    public void validate(KieSession ksession,
                         Context<?> context)
                  throws IllegalStateException

  Throws:
    `IllegalStateException`

### disposeRuntimeEngine

    public void disposeRuntimeEngine(RuntimeEngine runtime)

  Description copied from interface: `RuntimeManager`
  Disposes `RuntimeEngine` and notifies all listeners about that fact. This method should always be used to dispose `RuntimeEngine` that is not needed anymore.
  ksession.dispose() shall never be used with RuntimeManager as it will break the internal mechanisms of the manager responsible for clear and efficient disposal.
  Dispose is not needed if `RuntimeEngine` was obtained within active JTA transaction, this means that when getRuntimeEngine method was invoked during active JTA transaction then dispose of the runtime engine will happen automatically on transaction completion.

### close

    public void close()

  Description copied from interface: `RuntimeManager`
  Closes `RuntimeManager` and releases it's resources. Shall always be called when runtime manager is not needed any more. Otherwise it will still be active and operational.

  Specified by:
    `close` in interface `RuntimeManager`
  Overrides:
    `close` in class `AbstractRuntimeManager`

### getPersistedSessionId

    protected int 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,
                                    int 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()

### 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)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| jBPM distribution 6.0.0-SNAPSHOT
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2013 JBoss by Red Hat. All Rights Reserved.