|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectatg.nucleus.logging.VariableArgumentApplicationLoggingImpl
atg.nucleus.GenericService
atg.commerce.util.RepeatingRequestMonitor
public class RepeatingRequestMonitor
The class 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).
Form handlers should use this by calling the
RepeatingRequestMonitor.isUniqueRequestEntry() method. The boolean return value indicates
whether the handler is free to proceed execution, or whether another request scoped
component has recently been executing the same method for this session. The handler may
specify a timeout duration for this entry, or use the configurable default timeout. After
the critical execution, the handler may remove the request entry or have these otherwise
expire after the timeout.
For example, a request scoped formhandler may use this in handler methods as follows:
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
}
| Field Summary | |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string |
| Fields inherited from class atg.nucleus.GenericService |
|---|
SERVICE_INFO_KEY |
| Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging |
|---|
DEFAULT_LOG_TRACE_STATUS |
| Fields inherited from interface atg.nucleus.logging.ApplicationLogging |
|---|
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS |
| Constructor Summary | |
|---|---|
RepeatingRequestMonitor()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl |
|---|
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CLASS_VERSION
| Constructor Detail |
|---|
public RepeatingRequestMonitor()
| Method Detail |
|---|
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 value
boolean 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 value
boolean 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 value
protected boolean isPreviousRequestEntry(java.lang.String pRequestEntry,
long pCurrentTimeMillis)
protected void addRequestEntry(java.lang.String pRequestEntry,
long pExpirationTimeMillis)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||