Package org.jbpm.runtime.manager.impl

## Class SimpleRuntimeEnvironment

- java.lang.Object
- - org.jbpm.runtime.manager.impl.SimpleRuntimeEnvironment

- All Implemented Interfaces:
    `SchedulerProvider`, `org.kie.api.runtime.manager.RuntimeEnvironment`, `org.kie.internal.runtime.manager.RuntimeEnvironment`
  Direct Known Subclasses:
    `DefaultRuntimeEnvironment`

      public class SimpleRuntimeEnvironment
      extends Object
      implements org.kie.internal.runtime.manager.RuntimeEnvironment, SchedulerProvider

  The most basic implementation of the `RuntimeEnvironment` that, at the same time, serves as base implementation for all extensions. Encapsulates all important configuration that `RuntimeManager` requires for execution.
  - EntityManagerFactory - shared for all runtime engine build based on same `RuntimeEnvironment`
  - Environment - Drools/jBPM environment object - will be cloned for every `RuntimeEngine`
  - KieSessionConfiguration - will be build passed on defined properties - cloned for every `RuntimeEngine`
  - KieBase - resulting knowledge base build on given assets or returned if it was preset
  - RegisterableItemsFactory - factory used to provide listeners and work item handlers
  - Mapper - mapper used to keep context information
  - UserGroupCallback - user group callback, if not given null will be returned
  - GlobalSchedulerService - since this environment implements `SchedulerProvider` it allows to get `GlobalTimerService` if available

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected ClassLoader` | `classLoader` |
    `protected org.kie.api.runtime.KieSessionConfiguration` | `configuration` |
    `protected javax.persistence.EntityManagerFactory` | `emf` |
    `protected org.kie.api.runtime.Environment` | `environment` |
    `protected Map<String,​Object>` | `environmentEntries` |
    `protected org.kie.api.KieBase` | `kbase` |
    `protected org.kie.internal.builder.KnowledgeBuilder` | `kbuilder` |
    `protected org.kie.internal.runtime.manager.Mapper` | `mapper` |
    `protected org.kie.api.runtime.manager.RegisterableItemsFactory` | `registerableItemsFactory` |
    `protected GlobalSchedulerService` | `schedulerService` |
    `protected Properties` | `sessionConfigProperties` |
    `protected boolean` | `usePersistence` |
    `protected org.kie.api.task.UserGroupCallback` | `userGroupCallback` |
    `protected org.kie.api.task.UserInfo` | `userInfo` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SimpleRuntimeEnvironment()` |
    `SimpleRuntimeEnvironment​(org.kie.api.runtime.manager.RegisterableItemsFactory registerableItemsFactory)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addAsset​(org.kie.api.io.Resource resource, org.kie.api.io.ResourceType type)` | Adds given asset to knowledge builder to produce KieBase
    `protected void` | `addIfPresent​(String name, org.kie.api.runtime.Environment copy)` |
    `void` | `addToConfiguration​(String name, String value)` | Adds configuration property that will be part of `KieSessionConfiguration`
    `void` | `addToEnvironment​(String name, Object value)` | Adds element to the drools/jbpm environment - the value must be thread save as it will be shared between all `RuntimeEngine` instances
    `void` | `close()` |
    `protected org.kie.api.runtime.Environment` | `copyEnvironment()` |
    `ClassLoader` | `getClassLoader()` |
    `org.kie.api.runtime.KieSessionConfiguration` | `getConfiguration()` |
    `javax.persistence.EntityManagerFactory` | `getEmf()` |
    `org.kie.api.runtime.Environment` | `getEnvironment()` |
    `org.kie.api.runtime.Environment` | `getEnvironmentTemplate()` |
    `org.kie.api.KieBase` | `getKieBase()` |
    `org.kie.internal.runtime.manager.Mapper` | `getMapper()` |
    `org.kie.api.runtime.manager.RegisterableItemsFactory` | `getRegisterableItemsFactory()` |
    `GlobalSchedulerService` | `getSchedulerService()` | Returns fully configured instance of `SchedulerService` ready to be used/
    `Properties` | `getSessionConfigProperties()` |
    `org.kie.api.task.UserGroupCallback` | `getUserGroupCallback()` |
    `org.kie.api.task.UserInfo` | `getUserInfo()` |
    `void` | `init()` |
    `void` | `setClassLoader​(ClassLoader classLoader)` |
    `void` | `setEmf​(javax.persistence.EntityManagerFactory emf)` |
    `void` | `setKieBase​(org.kie.api.KieBase kbase)` |
    `void` | `setMapper​(org.kie.internal.runtime.manager.Mapper mapper)` |
    `void` | `setRegisterableItemsFactory​(org.kie.api.runtime.manager.RegisterableItemsFactory registerableItemsFactory)` |
    `void` | `setSchedulerService​(GlobalSchedulerService schedulerService)` |
    `void` | `setSessionConfigProperties​(Properties sessionConfigProperties)` |
    `void` | `setUsePersistence​(boolean usePersistence)` |
    `void` | `setUserGroupCallback​(org.kie.api.task.UserGroupCallback userGroupCallback)` |
    `void` | `setUserInfo​(org.kie.api.task.UserInfo userInfo)` |
    `boolean` | `usePersistence()` |

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

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

- - ### Field Detail

    - #### usePersistence

          protected boolean usePersistence

    - #### emf

          protected javax.persistence.EntityManagerFactory emf

    - #### environmentEntries

          protected Map<String,​Object> environmentEntries

    - #### environment

          protected org.kie.api.runtime.Environment environment

    - #### configuration

          protected org.kie.api.runtime.KieSessionConfiguration configuration

    - #### kbase

          protected org.kie.api.KieBase kbase

    - #### kbuilder

          protected org.kie.internal.builder.KnowledgeBuilder kbuilder

    - #### registerableItemsFactory

          protected org.kie.api.runtime.manager.RegisterableItemsFactory registerableItemsFactory

    - #### mapper

          protected org.kie.internal.runtime.manager.Mapper mapper

    - #### userGroupCallback

          protected org.kie.api.task.UserGroupCallback userGroupCallback

    - #### userInfo

          protected org.kie.api.task.UserInfo userInfo

    - #### schedulerService

          protected GlobalSchedulerService schedulerService

    - #### classLoader

          protected ClassLoader classLoader

    - #### sessionConfigProperties

          protected Properties sessionConfigProperties

  - ### Constructor Detail

    - #### SimpleRuntimeEnvironment

          public SimpleRuntimeEnvironment()

    - #### SimpleRuntimeEnvironment

          public SimpleRuntimeEnvironment​(org.kie.api.runtime.manager.RegisterableItemsFactory registerableItemsFactory)

  - ### Method Detail

    - #### init

          public void init()

    - #### addAsset

          public void addAsset​(org.kie.api.io.Resource resource,
                               org.kie.api.io.ResourceType type)

      Adds given asset to knowledge builder to produce KieBase
      Parameters:
        `resource` - asset to be added
        `type` - type of the asset

    - #### addToEnvironment

          public void addToEnvironment​(String name,
                                       Object value)

      Adds element to the drools/jbpm environment - the value must be thread save as it will be shared between all `RuntimeEngine` instances
      Parameters:
        `name` - name of the environment entry
        `value` - value of the environment entry

    - #### addToConfiguration

          public void addToConfiguration​(String name,
                                         String value)

      Adds configuration property that will be part of `KieSessionConfiguration`
      Parameters:
        `name` - name of the property
        `value` - value of the property

    - #### getKieBase

          public org.kie.api.KieBase getKieBase()

      Specified by:
        `getKieBase` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### getEnvironmentTemplate

          public org.kie.api.runtime.Environment getEnvironmentTemplate()

    - #### getEnvironment

          public org.kie.api.runtime.Environment getEnvironment()

      Specified by:
        `getEnvironment` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### getConfiguration

          public org.kie.api.runtime.KieSessionConfiguration getConfiguration()

      Specified by:
        `getConfiguration` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### usePersistence

          public boolean usePersistence()

      Specified by:
        `usePersistence` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### getRegisterableItemsFactory

          public org.kie.api.runtime.manager.RegisterableItemsFactory getRegisterableItemsFactory()

      Specified by:
        `getRegisterableItemsFactory` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### close

          public void close()

      Specified by:
        `close` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### addIfPresent

          protected void addIfPresent​(String name,
                                      org.kie.api.runtime.Environment copy)

    - #### copyEnvironment

          protected org.kie.api.runtime.Environment copyEnvironment()

    - #### getMapper

          public org.kie.internal.runtime.manager.Mapper getMapper()

      Specified by:
        `getMapper` in interface `org.kie.internal.runtime.manager.RuntimeEnvironment`

    - #### getUserGroupCallback

          public org.kie.api.task.UserGroupCallback getUserGroupCallback()

      Specified by:
        `getUserGroupCallback` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### setUserGroupCallback

          public void setUserGroupCallback​(org.kie.api.task.UserGroupCallback userGroupCallback)

    - #### getUserInfo

          public org.kie.api.task.UserInfo getUserInfo()

      Specified by:
        `getUserInfo` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### setUserInfo

          public void setUserInfo​(org.kie.api.task.UserInfo userInfo)

    - #### getSessionConfigProperties

          public Properties getSessionConfigProperties()

    - #### setSessionConfigProperties

          public void setSessionConfigProperties​(Properties sessionConfigProperties)

    - #### setUsePersistence

          public void setUsePersistence​(boolean usePersistence)

    - #### setKieBase

          public void setKieBase​(org.kie.api.KieBase kbase)

    - #### setMapper

          public void setMapper​(org.kie.internal.runtime.manager.Mapper mapper)

    - #### getSchedulerService

          public GlobalSchedulerService getSchedulerService()

      Description copied from interface: `SchedulerProvider`
      Returns fully configured instance of `SchedulerService` ready to be used/
      Specified by:
        `getSchedulerService` in interface `SchedulerProvider`
      Returns:
        `GlobalSchedulerService` instance configured according to environment needs

    - #### setSchedulerService

          public void setSchedulerService​(GlobalSchedulerService schedulerService)

    - #### setRegisterableItemsFactory

          public void setRegisterableItemsFactory​(org.kie.api.runtime.manager.RegisterableItemsFactory registerableItemsFactory)

    - #### getEmf

          public javax.persistence.EntityManagerFactory getEmf()

    - #### setEmf

          public void setEmf​(javax.persistence.EntityManagerFactory emf)

    - #### getClassLoader

          public ClassLoader getClassLoader()

      Specified by:
        `getClassLoader` in interface `org.kie.api.runtime.manager.RuntimeEnvironment`

    - #### setClassLoader

          public void setClassLoader​(ClassLoader classLoader)