public class RepeatingRequestMonitor extends GenericService
RepeatingRequestMonitor is designed for use as a session scoped
component. It is used to track request threads that register themselves as executing by
name and for a designated time period, to ensure that the same request handler is not
executed by two request scoped components concurrently (as happens when a user clicks a
submit button multiple times).
if (RepeatingRequestMonitor.isUniqueRequestEntry("YourFormHandler.handleSubmit")) {
try {
// proceed executing method functionality
}
finally {
// when done executing functionality, remove this request entry
RepeatingRequestMonitor.removeRequestEntry("YourFormHandler.handleSubmit");
}
} else {
// handle case, perhaps create DropletFormException and return
}
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
SERVICE_INFO_KEYDEFAULT_LOG_TRACE_STATUSDEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS| Constructor and Description |
|---|
RepeatingRequestMonitor() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addRequestEntry(java.lang.String pRequestEntry,
long pExpirationTimeMillis) |
long |
getDefaultRequestTimeout()
Returns the default timeout for a request entry.
|
protected java.util.Map |
getRequestEntries()
Returns the Map of request entries.
|
protected boolean |
isPreviousRequestEntry(java.lang.String pRequestEntry,
long pCurrentTimeMillis) |
boolean |
isUniqueRequestEntry(java.lang.String pRequestEntry)
The
isUniqueRequestEntry method attempts ro register a request entry by the
supplied name. |
boolean |
isUniqueRequestEntry(java.lang.String pRequestEntry,
long pTimeoutRequested)
The
isUniqueRequestEntry method attempts to register a request entry by the
supplied name and for the supplied timeout. |
void |
removeRequestEntry(java.lang.String pRequestEntry)
The
removeRequestEntry method removes any request entry that exists with the
supplied name. |
void |
setDefaultRequestTimeout(long pDefaultRequestTimeout)
Specifies the default timeout for a request entry in milliseconds.
|
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopServicevlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarningpublic static final java.lang.String CLASS_VERSION
public void setDefaultRequestTimeout(long pDefaultRequestTimeout)
pDefaultRequestTimeout - a long valuepublic long getDefaultRequestTimeout()
3000ms or 3
seconds.long valueprotected java.util.Map getRequestEntries()
Map valuepublic boolean isUniqueRequestEntry(java.lang.String pRequestEntry)
isUniqueRequestEntry method attempts ro register a request entry by the
supplied name. The timeout period is that given by getDefaultRequestTimeout.
pRequestEntry - a String valueboolean value indicating whether this request entry is unique and
has been registered.public boolean isUniqueRequestEntry(java.lang.String pRequestEntry,
long pTimeoutRequested)
isUniqueRequestEntry method attempts to register a request entry by the
supplied name and for the supplied timeout.
pRequestEntry - a String valuepTimeoutRequested - a long valueboolean value indicating whether this request entry is unique and
has been registered.public void removeRequestEntry(java.lang.String pRequestEntry)
removeRequestEntry method removes any request entry that exists with the
supplied name.pRequestEntry - a String valueprotected boolean isPreviousRequestEntry(java.lang.String pRequestEntry,
long pCurrentTimeMillis)
protected void addRequestEntry(java.lang.String pRequestEntry,
long pExpirationTimeMillis)