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.
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 >
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
JavaDelegate
implementations using the classloader
of the process applicationSet TCCL of Process Application | | +--------------------+ | |Process Application | invoke v | | ProcessEngine -----------------O--|--> Java Delegate | | | | | +--------------------+
The process engine holds a WeakReference
to the ServletProcessApplication
and does not cache any
classes loaded using the Process Application classloader.
Modifier and Type | Field and Description |
---|---|
protected ClassLoader |
processApplicationClassloader |
protected ProcessApplicationReferenceImpl |
reference |
protected javax.servlet.ServletContext |
servletContext |
protected String |
servletContextName |
protected String |
servletContextPath |
defaultDeployToEngineName, isDeployed, processApplicationBeanElResolver, processApplicationElResolver, processApplicationScriptEnvironment, variableSerializers
Constructor and Description |
---|
ServletProcessApplication() |
Modifier and Type | Method and Description |
---|---|
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) |
createDeployment, deploy, execute, execute, getBeanElResolver, getDefaultDeployToEngineName, getElResolver, getEnvironmentScripts, getExecutionListener, getName, getProcessApplicationScriptEnvironment, getRawObject, getScriptEngineForName, getTaskListener, getVariableSerializers, initProcessApplicationElResolver, setDefaultDeployToEngineName, setVariableSerializers, undeploy
protected String servletContextName
protected String servletContextPath
protected ProcessApplicationReferenceImpl reference
protected ClassLoader processApplicationClassloader
protected javax.servlet.ServletContext servletContext
protected String autodetectProcessApplicationName()
AbstractProcessApplication
ProcessApplication
annotation was used but without parameter.autodetectProcessApplicationName
in class AbstractProcessApplication
public ProcessApplicationReference getReference()
ProcessApplicationInterface
Returns a globally sharable reference to this process application. This reference may be safely passed to the process engine. And other applications.
getReference
in interface ProcessApplicationInterface
public void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized
in interface javax.servlet.ServletContextListener
protected ClassLoader initProcessApplicationClassloader(javax.servlet.ServletContextEvent sce)
public ClassLoader getProcessApplicationClassloader()
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
.
getProcessApplicationClassloader
in interface ProcessApplicationInterface
getProcessApplicationClassloader
in class AbstractProcessApplication
ClassLoader
that can be used to load classes and resources from this process application.public void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed
in interface javax.servlet.ServletContextListener
public Map<String,String> getProperties()
ProcessApplicationInterface
override this method in order to provide a map of properties.
The properties are made available globally through the ProcessApplicationService
getProperties
in interface ProcessApplicationInterface
getProperties
in class AbstractProcessApplication
ProcessApplicationService
,
ProcessApplicationInfo.getProperties()
public javax.servlet.ServletContext getServletContext()
Copyright © 2021. All rights reserved.