|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sormula.active.operation.ActiveOperation<R,T>
R
- record typeT
- execute return typepublic abstract class ActiveOperation<R extends ActiveRecord<R>,T>
Template for executing operate()
on an active table. Used by ActiveTable
for thread-safe and transaction based operation for a table (and any cascaded tables).
A database transaction will only be used if Connection.getAutoCommit()
returns false.
Constructor Summary | |
---|---|
ActiveOperation(ActiveTable<R> activeTable,
java.lang.String exceptionMessage)
Constructs for a table and fail message. |
Method Summary | |
---|---|
protected void |
attach(java.util.Collection<R> records)
Attaches a collection of active record to the active database used by this operation with ActiveRecord.attach(ActiveDatabase) . |
protected void |
attach(R record)
Attaches an active record to the active database used by this operation with ActiveRecord.attach(ActiveDatabase) . |
protected void |
close()
Cleans up any used resources. |
T |
execute()
Executes operate() within a try/catch and transaction. |
protected OperationDatabase |
getOperationDatabase()
Gets the database used in execute() . |
protected Table<R> |
getTable()
Gets the table used in execute() . |
boolean |
isLocalTransaction()
Reports type of transaction used. |
protected abstract T |
operate()
Invoked by execute() to perform the operation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ActiveOperation(ActiveTable<R> activeTable, java.lang.String exceptionMessage)
activeTable
- table to operate uponexceptionMessage
- exception message for ActiveException
if operation failsMethod Detail |
---|
public T execute() throws ActiveException
operate()
within a try/catch and transaction. If operate()
throws an exception, then transaction is rolled back.
operate()
ActiveException
- if errorpublic boolean isLocalTransaction()
execute()
is in progress.
execute()
protected abstract T operate() throws java.lang.Exception
execute()
to perform the operation. Subclasses must implement.
java.lang.Exception
protected OperationDatabase getOperationDatabase()
execute()
. Database is closed when
the transaction is closed.
protected Table<R> getTable()
execute()
. Table is obtained with
OperationDatabase.getTable(Class)
.
protected void attach(R record)
ActiveRecord.attach(ActiveDatabase)
.
record
- active record to be attachedprotected void attach(java.util.Collection<R> records)
ActiveRecord.attach(ActiveDatabase)
.
records
- active records to be attachedprotected void close() throws ActiveException
isLocalTransaction()
is true. Otherwise JDBC connection will
be closed when transaction completes.
ActiveException
- if error
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |