Class ServletProcessApplication
- All Implemented Interfaces:
EventListener
,javax.servlet.ServletContextListener
,ProcessApplicationInterface
- Direct Known Subclasses:
Application
,InvoiceProcessApplication
A AbstractProcessApplication
Implementation to be used in a Servlet
container environment.
This class implements the ServletContextListener
interface 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 ServletProcessApplication
annotated with
@ProcessApplication
to your application:
@ProcessApplication("Loan Approval App") public class LoanApprovalApplication extends ServletProcessApplication { // empty implementation }This, in combination with a
META-INF/processes.xml
file 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
JavaDelegate
implementations 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 WeakReference
to the
ServletProcessApplication
and does not cache any classes loaded using
the Process Application classloader.
- Author:
- Daniel Meyer, Thorben Lindhauer
-
Field Summary
Fields inherited from class org.camunda.bpm.application.impl.AbstractServletProcessApplication
processApplicationClassloader, reference, servletContextName, servletContextPath
Fields inherited from class org.camunda.bpm.application.AbstractProcessApplication
defaultDeployToEngineName, isDeployed, processApplicationBeanElResolver, processApplicationElResolver, processApplicationScriptEnvironment, variableSerializers
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
contextDestroyed
(javax.servlet.ServletContextEvent sce) void
contextInitialized
(javax.servlet.ServletContextEvent sce) javax.servlet.ServletContext
protected ClassLoader
initProcessApplicationClassloader
(javax.servlet.ServletContextEvent sce) Methods inherited from class org.camunda.bpm.application.impl.AbstractServletProcessApplication
autodetectProcessApplicationName, getProcessApplicationClassloader, getProperties, getReference
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 Details
-
servletContext
protected javax.servlet.ServletContext servletContext
-
-
Constructor Details
-
ServletProcessApplication
public ServletProcessApplication()
-
-
Method Details
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent sce) - Specified by:
contextInitialized
in interfacejavax.servlet.ServletContextListener
-
initProcessApplicationClassloader
-
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent sce) - Specified by:
contextDestroyed
in interfacejavax.servlet.ServletContextListener
-
getServletContext
public javax.servlet.ServletContext getServletContext()
-