org.camunda.bpm.application.impl
Class ServletProcessApplication

java.lang.Object
  extended by org.camunda.bpm.application.AbstractProcessApplication
      extended by org.camunda.bpm.application.impl.ServletProcessApplication
All Implemented Interfaces:
EventListener, javax.servlet.ServletContextListener, ProcessApplicationInterface

public class ServletProcessApplication
extends AbstractProcessApplication
implements javax.servlet.ServletContextListener

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

                        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
protected  ClassLoader processApplicationClassloader
           
protected  ProcessApplicationReferenceImpl reference
           
protected  javax.servlet.ServletContext servletContext
           
protected  String servletContextName
           
protected  String servletContextPath
           
 
Fields inherited from class org.camunda.bpm.application.AbstractProcessApplication
isDeployed, processApplicationBeanElResolver, processApplicationElResolver, processApplicationScriptEnvironment, variableSerializers
 
Constructor Summary
ServletProcessApplication()
           
 
Method Summary
protected  String autodetectProcessApplicationName()
          Override this method to autodetect an application name in case the ProcessApplication annotation was used but without parameter.
 void contextDestroyed(javax.servlet.ServletContextEvent sce)
           
 void contextInitialized(javax.servlet.ServletContextEvent sce)
           
 ClassLoader getProcessApplicationClassloader()
          Override this method to provide an environment-specific ClassLoader to be used by the process engine for loading resources from the process application
 Map<String,String> getProperties()
          override this method in order to provide a map of properties.
 ProcessApplicationReference getReference()
          Returns a globally sharable reference to this process application.
 javax.servlet.ServletContext getServletContext()
           
protected  ClassLoader initProcessApplicationClassloader(javax.servlet.ServletContextEvent sce)
           
 
Methods inherited from class org.camunda.bpm.application.AbstractProcessApplication
createDeployment, deploy, execute, execute, getBeanElResolver, getElResolver, getEnvironmentScripts, getExecutionListener, getName, getProcessApplicationScriptEnvironment, getRawObject, getScriptEngineForName, getTaskListener, getVariableSerializers, initProcessApplicationElResolver, setVariableSerializers, undeploy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servletContextName

protected String servletContextName

servletContextPath

protected String servletContextPath

reference

protected ProcessApplicationReferenceImpl reference

processApplicationClassloader

protected ClassLoader processApplicationClassloader

servletContext

protected javax.servlet.ServletContext servletContext
Constructor Detail

ServletProcessApplication

public ServletProcessApplication()
Method Detail

autodetectProcessApplicationName

protected String autodetectProcessApplicationName()
Description copied from class: AbstractProcessApplication
Override this method to autodetect an application name in case the ProcessApplication annotation was used but without parameter.

Specified by:
autodetectProcessApplicationName in class AbstractProcessApplication

getReference

public ProcessApplicationReference getReference()
Description copied from interface: ProcessApplicationInterface

Returns a globally sharable reference to this process application. This reference may be safely passed to the process engine. And other applications.

Specified by:
getReference in interface ProcessApplicationInterface
Returns:
a globally sharable reference to this process application.

contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent sce)
Specified by:
contextInitialized in interface javax.servlet.ServletContextListener

initProcessApplicationClassloader

protected ClassLoader initProcessApplicationClassloader(javax.servlet.ServletContextEvent sce)

getProcessApplicationClassloader

public ClassLoader getProcessApplicationClassloader()
Description copied from interface: ProcessApplicationInterface

Override this method to provide an environment-specific ClassLoader to be used by the process engine for loading resources from the process application

NOTE: the process engine must never cache any references to this ClassLoader or to classes obtained through this ClassLoader.

Specified by:
getProcessApplicationClassloader in interface ProcessApplicationInterface
Overrides:
getProcessApplicationClassloader in class AbstractProcessApplication
Returns:
the ClassLoader that can be used to load classes and resources from this process application.

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent sce)
Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener

getProperties

public Map<String,String> getProperties()
Description copied from interface: ProcessApplicationInterface

override this method in order to provide a map of properties.

The properties are made available globally through the ProcessApplicationService

Specified by:
getProperties in interface ProcessApplicationInterface
Overrides:
getProperties in class AbstractProcessApplication
See Also:
ProcessApplicationService, ProcessApplicationInfo.getProperties()

getServletContext

public javax.servlet.ServletContext getServletContext()


Copyright © 2017 camunda services GmbH. All rights reserved.