public class TransactionalFormHandler extends GenericFormHandler
setPropertyValue
call unless a transaction
is already in place. This can lead to significant performance problems and inconsistent
data, from the application's perspective, because one set could succeed and another
might fail. If the ensureTransaction
property is true, then transactions
are created, if necessary, in the beforeSet
operation and committed or rolledback
in the afterSet
method. Instances of this form handler should be request scoped,
or if session scoped, the component should be synchronized.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
TransactionalFormHandler()
Constructs an instanceof TransactionalFormHandler
|
Modifier and Type | Method and Description |
---|---|
boolean |
afterSet(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
If the TransactionDemarcation is not null, then the transaction is ended.
|
boolean |
beforeSet(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
Creates a new TransactionDemarcation and then begins the transaction.
|
boolean |
checkFormRedirect(java.lang.String pSuccessURL,
java.lang.String pFailureURL,
DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
If the transaction is marked as rollback, then redirect to the FailureURL,
otherwise allow the super-class behavior to perform.
|
void |
commitTransaction()
This method commits the current transaction (or rolls it back if
you have called setRollbackTransaction(true) since the transaction
started).
|
protected TransactionDemarcation |
getTransactionDemarcation()
Returns property TransactionDemarcation.
|
protected int |
getTransactionStatus()
Obtain the status of the transaction associated with the current thread.
|
boolean |
isEnsureTransaction()
Returns property EnsureTransaction, if false then no transaction management is performed
|
protected boolean |
isRollbackTransaction()
Returns property RollbackTransaction.
|
boolean |
isRollbackTransactionOnUnhandledException()
Gets the value of the isRollbackTransactionOnUnhandledException property.
|
protected boolean |
isTransactionMarkedAsRollback()
Returns true if the transaction associated with the current thread
is marked for rollback.
|
void |
setEnsureTransaction(boolean pEnsureTransaction)
Sets property EnsureTransaction
|
protected void |
setRollbackTransaction(boolean pRollbackTransaction)
Sets property RollbackTransaction
|
void |
setRollbackTransactionOnUnhandledException(boolean pRollbackTransactionOnUnhandledException)
Sets the value of the isRollbackTransactionOnUnhandledException property.
|
protected void |
setTransactionDemarcation(TransactionDemarcation pTransactionDemarcation)
Sets property TransactionDemarcation
Previously, this method stored the TransactionDemarcation
object as a member variable.
|
addFormException, addUncheckedFormException, createFormSubmissionMessage, getCancelURL, getCheckForValidSession, getFormError, getFormExceptions, getFormName, getMessagePort, getMessageSource, getMessageType, getPropertyExceptions, getSendMessages, getUncheckedFormExceptions, handleCancel, handleFormException, handleUncheckedFormException, hasUncheckedFormExceptions, isDeferForwardsAndRedirects, isRestorableForm, isUseForwards, isValidSession, redirectOrForward, resetFormExceptions, setCancelURL, setCheckForValidSession, setDeferForwardsAndRedirects, setFormName, setMessagePort, setMessageSource, setMessageType, setRestorableForm, setSendMessages, setUseForwards
afterGet, beforeGet
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, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public TransactionalFormHandler()
public void setEnsureTransaction(boolean pEnsureTransaction)
public boolean isEnsureTransaction()
protected void setTransactionDemarcation(TransactionDemarcation pTransactionDemarcation)
protected TransactionDemarcation getTransactionDemarcation()
beforeSet
and afterSet
methods. This is created in the
beforeSet
method and set to null in afterSet
.protected void setRollbackTransaction(boolean pRollbackTransaction)
protected boolean isRollbackTransaction()
afterSet
method. This defaults to false and is
reset to false in afterSet
.public boolean beforeSet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws DropletFormException
ensureTransaction
property is false then no transacation management
is performed.beforeSet
in interface DropletFormHandler
beforeSet
in class GenericFormHandler
DropletFormException
public boolean afterSet(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws DropletFormException
rollbackTransaction
is set to true, otherwise the transaction is committed. If the ensureTransaction
property is false then no transacation management is performed. The transactionDemarcation
property is set to null and rollbackTransaction
property is set to false in the finally
clause of this method after the super.afterSet
method is called.afterSet
in interface DropletFormHandler
afterSet
in class GenericFormHandler
DropletFormException
protected boolean isTransactionMarkedAsRollback()
protected int getTransactionStatus()
TransactionManager.getStatus()
throws a SystemException.public boolean checkFormRedirect(java.lang.String pSuccessURL, java.lang.String pFailureURL, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
checkFormRedirect
in class GenericFormHandler
pSuccessURL
- The URL to redirect to if there were no form errors.
If a null value is passed in, no redirect occurs.pFailureURL
- The URL to redirect to if form errors were found.
If a null value is passed in, no redirect occurs.pRequest
- the servlet's requestpResponse
- the servlet's responsejavax.servlet.ServletException
- if there was an error while executing the codejava.io.IOException
- if there was an error with servlet iopublic void commitTransaction()
public boolean isRollbackTransactionOnUnhandledException()
public void setRollbackTransactionOnUnhandledException(boolean pRollbackTransactionOnUnhandledException)
pRollbackTransactionOnUnhandledException
- true if the transaction should rollback if there was an
unhandled exception thrown from a handle method.