|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectsf.qof.session.BaseSessionRunner<T>
sf.qof.session.RetrySessionRunner<T>
T - the type of the result of the TransactionRunnable. If
no result is returned this type should be Voidpublic class RetrySessionRunner<T>
RetrySessionRunner is an implementation of SessionRunner
that runs a TransactionRunnable in a session context and retries
if an error occured.
Calling execute starts a new session call the run
method of the TransactionRunnable and commits or rolls back
the transaction on success or failure. If an error occured it retries up to
numberOfRetries times. delayInMilliSeconds can be
used to wait a specified amount of time between the retries.
Typical usage is like this:
List<Person> personList = ... PersonUpdaterRunnable runnable = new PersonUpdaterRunnable(); Integer numberOfUpdates = new RetrySessionRunner<Integer>(runnable, "MY_CONTEXT_NAME").execute(personList, 3);
SessionRunner| Field Summary |
|---|
| Fields inherited from class sf.qof.session.BaseSessionRunner |
|---|
sessionContext |
| Constructor Summary | |
|---|---|
RetrySessionRunner(TransactionRunnable<T> runnable,
int numberOfRetries)
Creates a RetrySessionRunner that creates a session
from the default session context. |
|
RetrySessionRunner(TransactionRunnable<T> runnable,
int numberOfRetries,
long delayInMilliSeconds)
Creates a RetrySessionRunner that creates a session
from the default session context. |
|
RetrySessionRunner(TransactionRunnable<T> runnable,
String contextName,
int numberOfRetries)
Creates a RetrySessionRunner that creates a session
from the session context with the given name. |
|
RetrySessionRunner(TransactionRunnable<T> runnable,
String contextName,
int numberOfRetries,
long delayInMilliSeconds)
Creates a RetrySessionRunner that creates a session
from the session context with the given name. |
|
| Method Summary | |
|---|---|
T |
execute(Object... arguments)
A call to execute starts a new session and executes some code
in a transactional context. |
protected T |
run(Connection connection,
Object... arguments)
This method is called once during the call to execute. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RetrySessionRunner(TransactionRunnable<T> runnable,
int numberOfRetries)
RetrySessionRunner that creates a session
from the default session context.
runnable - a TransactionRunnablenumberOfRetries - max number of retries
public RetrySessionRunner(TransactionRunnable<T> runnable,
int numberOfRetries,
long delayInMilliSeconds)
RetrySessionRunner that creates a session
from the default session context.
runnable - a TransactionRunnablenumberOfRetries - max number of retriesdelayInMilliSeconds - delay inbetween retries in milli seconds
public RetrySessionRunner(TransactionRunnable<T> runnable,
String contextName,
int numberOfRetries)
RetrySessionRunner that creates a session
from the session context with the given name.
runnable - a TransactionRunnablecontextName - the context namenumberOfRetries - max number of retries
public RetrySessionRunner(TransactionRunnable<T> runnable,
String contextName,
int numberOfRetries,
long delayInMilliSeconds)
RetrySessionRunner that creates a session
from the session context with the given name.
runnable - a TransactionRunnablecontextName - the context namenumberOfRetries - max number of retriesdelayInMilliSeconds - delay inbetween retries in milli seconds| Method Detail |
|---|
public T execute(Object... arguments)
throws SystemException
SessionRunnerexecute starts a new session and executes some code
in a transactional context.
If an exception is thrown by the executed code the
transaction is rolled back otherwise it is commited.
execute in interface SessionRunner<T>execute in class BaseSessionRunner<T>arguments - arguments that are passed to the executed code
SystemException - thrown if an unexpected error occuredSessionRunner.execute(Object[])
protected T run(Connection connection,
Object... arguments)
throws SQLException
BaseSessionRunnerexecute.
It must be overridden and should contain the code that needs to be
run in a transaction context.
run in class BaseSessionRunner<T>connection - the thread's current database connectionarguments - arguments passed to the execute method
SQLException - throw this if an error occured. This will cause a rollback
of the current transaction.
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||