Package com.saperion.ngc.servlet.process
Class LongRunningProcess
- java.lang.Object
-
- java.lang.Thread
-
- com.saperion.ngc.servlet.process.LongRunningProcess
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
ExportProcess
,PdfRenderProcess
public abstract class LongRunningProcess extends java.lang.Thread
Abstract class for processes that might take a long time to run. The processes are executed by theLongRunningProcessServlet
. Because a LongRunningProcess is a thread, classes that extend this class must overrideThread.run()
.
-
-
Field Summary
Fields Modifier and Type Field Description protected LRPControlBean
bean
Control bean for this process.protected boolean
canceled
If the process was canceled.protected NewConnectionClassicConnectorProvider
connectionProvider
Connection provider that provides a new connection for this process.static java.lang.String
CONTROL_BEAN_SESSION_ATTR
Name of the session attribute used to store the control bean for long running processes.protected boolean
error
If an error occurred.protected int
progress
Current progress (percent).protected javax.servlet.http.HttpSession
session
Current session.
-
Constructor Summary
Constructors Constructor Description LongRunningProcess(LRPControlBean bean, javax.servlet.http.HttpSession session)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancels the process.int
getProgress()
boolean
isError()
protected void
updateProgress(int currentElement, int totalElements)
Updates the progress.abstract void
writeResult(javax.servlet.http.HttpServletResponse response)
Writes the result of the process to the output-stream.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
CONTROL_BEAN_SESSION_ATTR
public static final java.lang.String CONTROL_BEAN_SESSION_ATTR
Name of the session attribute used to store the control bean for long running processes.- See Also:
- Constant Field Values
-
bean
protected final LRPControlBean bean
Control bean for this process.
-
session
protected final javax.servlet.http.HttpSession session
Current session.
-
progress
protected int progress
Current progress (percent).
-
error
protected boolean error
If an error occurred.
-
canceled
protected boolean canceled
If the process was canceled.
-
connectionProvider
protected NewConnectionClassicConnectorProvider connectionProvider
Connection provider that provides a new connection for this process. Each process must take care of logging-off the connector when it is no longer in use.
-
-
Constructor Detail
-
LongRunningProcess
public LongRunningProcess(LRPControlBean bean, javax.servlet.http.HttpSession session)
- Parameters:
bean
- bean containing information for the processsession
- the current session
-
-
Method Detail
-
writeResult
public abstract void writeResult(javax.servlet.http.HttpServletResponse response) throws java.io.IOException, SystemException
Writes the result of the process to the output-stream.- Parameters:
response
- servlet response to write to- Throws:
java.io.IOException
- IO Exception when writingSystemException
- generic exception when writing
-
updateProgress
protected void updateProgress(int currentElement, int totalElements)
Updates the progress.- Parameters:
currentElement
- element currently being processedtotalElements
- total number of elements
-
getProgress
public int getProgress()
- Returns:
- the current progress
-
isError
public boolean isError()
- Returns:
- true if an error occurred
-
cancel
public void cancel()
Cancels the process.
-
-