Package org.camunda.bpm.engine
Class ProcessEngines
- java.lang.Object
-
- org.camunda.bpm.engine.ProcessEngines
-
public abstract class ProcessEngines extends java.lang.Object
Helper for initializing and closing process engines in server environments.
All createdProcessEngine
s will be registered with this class.
The activiti-webapp-init webapp will call theinit()
method when the webapp is deployed and it will call thedestroy()
method when the webapp is destroyed, using a context-listener (org.camunda.bpm.engine.test.impl.servlet.listener.ProcessEnginesServletContextListener
). That way, all applications can just use thegetProcessEngines()
to obtain pre-initialized and cached process engines.
Please note that there is no lazy initialization of process engines, so make sure the context-listener is configured orProcessEngine
s are already created so they were registered on this class.
Theinit()
method will try to build oneProcessEngine
for each camunda.cfg.xml file found on the classpath. If you have more then one, make sure you specify different process.engine.name values.- Author:
- Tom Baeyens, Joram Barrez
-
-
Field Summary
Fields Modifier and Type Field Description protected static boolean
isInitialized
static java.lang.String
NAME_DEFAULT
protected static java.util.List<ProcessEngineInfo>
processEngineInfos
protected static java.util.Map<java.lang.String,ProcessEngineInfo>
processEngineInfosByName
protected static java.util.Map<java.lang.String,ProcessEngineInfo>
processEngineInfosByResourceUrl
protected static java.util.Map<java.lang.String,ProcessEngine>
processEngines
-
Constructor Summary
Constructors Constructor Description ProcessEngines()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
destroy()
closes all process engines.static ProcessEngine
getDefaultProcessEngine()
static ProcessEngine
getDefaultProcessEngine(boolean forceCreate)
static ProcessEngine
getProcessEngine(java.lang.String processEngineName)
static ProcessEngine
getProcessEngine(java.lang.String processEngineName, boolean forceCreate)
obtain a process engine by name.static ProcessEngineInfo
getProcessEngineInfo(java.lang.String processEngineName)
Get initialization results.static java.util.List<ProcessEngineInfo>
getProcessEngineInfos()
Get initialization results.static java.util.Map<java.lang.String,ProcessEngine>
getProcessEngines()
provides access to process engine to application clients in a managed server environment.static void
init()
static void
init(boolean forceCreate)
Initializes all process engines that can be found on the classpath for resourcescamunda.cfg.xml
(plain Activiti style configuration) and for resourcesactiviti-context.xml
(Spring style configuration).protected static void
initProcessEngineFromSpringResource(java.net.URL resource)
static void
registerProcessEngine(ProcessEngine processEngine)
Registers the given process engine.static ProcessEngineInfo
retry(java.lang.String resourceUrl)
retries to initialize a process engine that previously failed.static void
unregister(ProcessEngine processEngine)
Unregisters the given process engine.
-
-
-
Field Detail
-
NAME_DEFAULT
public static final java.lang.String NAME_DEFAULT
- See Also:
- Constant Field Values
-
isInitialized
protected static boolean isInitialized
-
processEngines
protected static java.util.Map<java.lang.String,ProcessEngine> processEngines
-
processEngineInfosByName
protected static java.util.Map<java.lang.String,ProcessEngineInfo> processEngineInfosByName
-
processEngineInfosByResourceUrl
protected static java.util.Map<java.lang.String,ProcessEngineInfo> processEngineInfosByResourceUrl
-
processEngineInfos
protected static java.util.List<ProcessEngineInfo> processEngineInfos
-
-
Method Detail
-
init
public static void init()
-
init
public static void init(boolean forceCreate)
Initializes all process engines that can be found on the classpath for resourcescamunda.cfg.xml
(plain Activiti style configuration) and for resourcesactiviti-context.xml
(Spring style configuration).
-
initProcessEngineFromSpringResource
protected static void initProcessEngineFromSpringResource(java.net.URL resource)
-
registerProcessEngine
public static void registerProcessEngine(ProcessEngine processEngine)
Registers the given process engine. NoProcessEngineInfo
will be available for this process engine. An engine that is registered will be closed when thedestroy()
is called.
-
unregister
public static void unregister(ProcessEngine processEngine)
Unregisters the given process engine.
-
getProcessEngineInfos
public static java.util.List<ProcessEngineInfo> getProcessEngineInfos()
Get initialization results.
-
getProcessEngineInfo
public static ProcessEngineInfo getProcessEngineInfo(java.lang.String processEngineName)
Get initialization results. Only info will we available for process engines which were added in theinit()
. NoProcessEngineInfo
is available for engines which were registered programatically.
-
getDefaultProcessEngine
public static ProcessEngine getDefaultProcessEngine()
-
getDefaultProcessEngine
public static ProcessEngine getDefaultProcessEngine(boolean forceCreate)
-
getProcessEngine
public static ProcessEngine getProcessEngine(java.lang.String processEngineName)
-
getProcessEngine
public static ProcessEngine getProcessEngine(java.lang.String processEngineName, boolean forceCreate)
obtain a process engine by name.- Parameters:
processEngineName
- is the name of the process engine or null for the default process engine.
-
retry
public static ProcessEngineInfo retry(java.lang.String resourceUrl)
retries to initialize a process engine that previously failed.
-
getProcessEngines
public static java.util.Map<java.lang.String,ProcessEngine> getProcessEngines()
provides access to process engine to application clients in a managed server environment.
-
destroy
public static void destroy()
closes all process engines. This method should be called when the server shuts down.
-
-