Class ServletProcessApplication
- java.lang.Object
-
- org.camunda.bpm.application.AbstractProcessApplication
-
- org.camunda.bpm.application.impl.ServletProcessApplication
-
- All Implemented Interfaces:
java.util.EventListener,javax.servlet.ServletContextListener,ProcessApplicationInterface
- Direct Known Subclasses:
Application,InvoiceProcessApplication
public class ServletProcessApplication extends AbstractProcessApplication implements javax.servlet.ServletContextListener
A
AbstractProcessApplicationImplementation to be used in a Servlet container environment.This class implements the
ServletContextListenerinterface and can thus participate in the deployment lifecycle of your web application.Usage
In a Servlet 3.0 container it is sufficient adding a custom subclass of
ServletProcessApplicationannotated with@ProcessApplicationto your application:@ProcessApplication("Loan Approval App") public class LoanApprovalApplication extends ServletProcessApplication { // empty implementation }This, in combination with aMETA-INF/processes.xmlfile is sufficient for making sure that the process application class is picked up at runtime.In a Servlet 2.5 container, the process application can be added as a web listener to your project's
web.xml<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <listener> <listener-class>org.my.project.MyProcessApplication</listener-class> </listener> </web-app>Invocation Semantics
When the
AbstractProcessApplication.execute(java.util.concurrent.Callable)method is invoked, the servlet process application modifies the context classloader of the current Thread to the classloader that loaded the application-provided subclass of this class. This allows- the process engine to resolve
JavaDelegateimplementations using the classloader of the process application - In apache tomcat this allows you to resolve Naming Resources (JNDI) form the naming context of the process application. JNDI name resolution is based on the TCCL in Apache Tomcat.
Set TCCL of Process Application | | +--------------------+ | |Process Application | invoke v | | ProcessEngine -----------------O--|--> Java Delegate | | | | | +--------------------+Process Application Reference
The process engine holds a
WeakReferenceto theServletProcessApplicationand does not cache any classes loaded using the Process Application classloader.- Author:
- Daniel Meyer, Thorben Lindhauer
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.ClassLoaderprocessApplicationClassloaderprotected ProcessApplicationReferenceImplreferenceprotected javax.servlet.ServletContextservletContextprotected java.lang.StringservletContextNameprotected java.lang.StringservletContextPath-
Fields inherited from class org.camunda.bpm.application.AbstractProcessApplication
defaultDeployToEngineName, isDeployed, processApplicationBeanElResolver, processApplicationElResolver, processApplicationScriptEnvironment, variableSerializers
-
-
Constructor Summary
Constructors Constructor Description ServletProcessApplication()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringautodetectProcessApplicationName()Override this method to autodetect an application name in case theProcessApplicationannotation was used but without parameter.voidcontextDestroyed(javax.servlet.ServletContextEvent sce)voidcontextInitialized(javax.servlet.ServletContextEvent sce)java.lang.ClassLoadergetProcessApplicationClassloader()Override this method to provide an environment-specificClassLoaderto be used by the process engine for loading resources from the process applicationjava.util.Map<java.lang.String,java.lang.String>getProperties()override this method in order to provide a map of properties.ProcessApplicationReferencegetReference()Returns a globally sharable reference to this process application.javax.servlet.ServletContextgetServletContext()protected java.lang.ClassLoaderinitProcessApplicationClassloader(javax.servlet.ServletContextEvent sce)-
Methods inherited from class org.camunda.bpm.application.AbstractProcessApplication
createDeployment, deploy, execute, execute, getBeanElResolver, getDefaultDeployToEngineName, getElResolver, getEnvironmentScripts, getExecutionListener, getName, getProcessApplicationScriptEnvironment, getRawObject, getScriptEngineForName, getTaskListener, getVariableSerializers, initProcessApplicationElResolver, setDefaultDeployToEngineName, setVariableSerializers, undeploy
-
-
-
-
Field Detail
-
servletContextName
protected java.lang.String servletContextName
-
servletContextPath
protected java.lang.String servletContextPath
-
reference
protected ProcessApplicationReferenceImpl reference
-
processApplicationClassloader
protected java.lang.ClassLoader processApplicationClassloader
-
servletContext
protected javax.servlet.ServletContext servletContext
-
-
Method Detail
-
autodetectProcessApplicationName
protected java.lang.String autodetectProcessApplicationName()
Description copied from class:AbstractProcessApplicationOverride this method to autodetect an application name in case theProcessApplicationannotation was used but without parameter.- Specified by:
autodetectProcessApplicationNamein classAbstractProcessApplication
-
getReference
public ProcessApplicationReference getReference()
Description copied from interface:ProcessApplicationInterfaceReturns a globally sharable reference to this process application. This reference may be safely passed to the process engine. And other applications.
- Specified by:
getReferencein interfaceProcessApplicationInterface- Returns:
- a globally sharable reference to this process application.
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent sce)
- Specified by:
contextInitializedin interfacejavax.servlet.ServletContextListener
-
initProcessApplicationClassloader
protected java.lang.ClassLoader initProcessApplicationClassloader(javax.servlet.ServletContextEvent sce)
-
getProcessApplicationClassloader
public java.lang.ClassLoader getProcessApplicationClassloader()
Description copied from interface:ProcessApplicationInterfaceOverride this method to provide an environment-specific
ClassLoaderto be used by the process engine for loading resources from the process applicationNOTE: the process engine must never cache any references to this
ClassLoaderor to classes obtained through thisClassLoader.- Specified by:
getProcessApplicationClassloaderin interfaceProcessApplicationInterface- Overrides:
getProcessApplicationClassloaderin classAbstractProcessApplication- Returns:
- the
ClassLoaderthat can be used to load classes and resources from this process application.
-
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent sce)
- Specified by:
contextDestroyedin interfacejavax.servlet.ServletContextListener
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
Description copied from interface:ProcessApplicationInterfaceoverride this method in order to provide a map of properties.
The properties are made available globally through the
ProcessApplicationService- Specified by:
getPropertiesin interfaceProcessApplicationInterface- Overrides:
getPropertiesin classAbstractProcessApplication- See Also:
ProcessApplicationService,ProcessApplicationInfo.getProperties()
-
getServletContext
public javax.servlet.ServletContext getServletContext()
-
-