|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sssw.rt.util.AgoDataUpdateRequest
This is an abstract base class implementing the AgiDataUpdateRequest interface. It's intended to be used as a base class for the use of updatable customer-written Data Source Objects. The DataUpdateRequest acts as a "basket" for gathering up rows to be updated, and then executing the entire batch as a single database transaction. A customer writing an updatable Data Source Object would actually implement 5 separate classes:
This class includes two fields to be used as parameters with class methods: AgoDataUpdateRequest.m_rowFactory
and AgoDataUpdateRequest.m_updateRows
.
AgiDataUpdateRequest
,
AgoDataUpdateRow
,
AgiDataRow
,
AgiDataRowFactory
,
AgiTransactionHandle
Field Summary | |
protected AgiDataRowFactory |
m_rowFactory
The factory for creating AgiDataRows; this factory must be used for creating any rows returned in the "server-modified rows" enumeration |
protected Vector |
m_updateRows
The vector of update rows, of type AgoDataUpdateRow. |
Constructor Summary | |
AgoDataUpdateRequest(AgiDataRowFactory rowFactory)
The constructor is normally called only from the business object's prepareUpdateRequest factory method. |
Method Summary | |
protected abstract void |
abortTransaction(AgiTransactionHandle transactionHandle)
Abort the transaction against the "database" associated with this data update request. |
protected abstract AgiTransactionHandle |
beginTransaction()
Start a transaction against the "database" associated with this data update request. |
protected void |
checkUpdates()
Check the update request(s) for validity. |
protected abstract void |
commitTransaction(AgiTransactionHandle transactionHandle)
Commit the transaction against the "database" associated with this data update request. |
protected abstract AgoDataUpdateRow |
createUpdateRow(char kind,
AgiDataSource dataSource,
AgiDataRow row)
Create a "row holder" object for the specified row. |
protected abstract AgoDataUpdateRow |
createUpdateRow(char kind,
AgiDataSource dataSource,
AgiDataRow oldRow,
AgiDataRow newRow)
Create a "row holder" object for the specified row. |
protected Enumeration |
executeUpdatesInTransaction(AgiTransactionHandle transactionHandle)
Execute the actual updates. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Methods implemented from interface com.sssw.rt.util.AgiDataUpdateRequest |
close,
deleteRow,
executeAllUpdates,
insertRow,
makePrimaryRow,
updateRow |
Field Detail |
protected AgiDataRowFactory m_rowFactory
protected Vector m_updateRows
Constructor Detail |
public AgoDataUpdateRequest(AgiDataRowFactory rowFactory)
rowFactory
- Data row factory for modified rows
For the parameter value, see Protected class variables.
Method Detail |
protected abstract AgoDataUpdateRow createUpdateRow(char kind, AgiDataSource dataSource, AgiDataRow row) throws AgoApiException
kind
- update kind (insert, delete, modify)dataSource
- the source of the rowrow
- the row itselfFor more information about the parameters, see Protected class variables.
protected AgoDataUpdateRow createUpdateRow(char kind, AgiDataSource dataSource, AgiDataRow row) throws AgoApiException { return new MyDataUpdateRow(kind, dataSource, m_rowFactory, row); }
protected abstract AgoDataUpdateRow createUpdateRow(char kind, AgiDataSource dataSource, AgiDataRow oldRow, AgiDataRow newRow) throws AgoApiException
kind
- update kind (always update)dataSource
- the source of the rowoldRow
- the old rownewRow
- the new rowFor more information about the parameters, see Protected class variables.
protected AgoDataUpdateRow createUpdateRow(char kind, AgiDataSource dataSource, AgiDataRow oldRow, AgiDataRow newRow) throws AgoApiException { return new MyDataUpdateRow(kind, dataSource, m_rowFactory, oldRow, newRow); }
protected void checkUpdates() throws AgoApiException
Normally, the default implementation of this method in AgoDataUpdateRequest, which calls the checkStatement() method of each row in the update, will suffice, but it is documented here in case the user-written derived class needs to override or augment it.
protected void checkUpdates() throws AgoApiException { super.checkUpdates(); // Perform some specific checks here ... }
protected abstract AgiTransactionHandle beginTransaction() throws AgoApiException
protected AgiTransactionHandle beginTransaction() throws AgoApiException { try { Connection conn = m_db.getConnection(true); conn.setAutoCommit(false); return new MyTransactionHandle(m_db, conn); } catch (SQLException ex) { throw new AgoSystemDatabaseException(ex, "Error trying to start transaction"); } }
protected abstract void commitTransaction(AgiTransactionHandle transactionHandle) throws AgoApiException
transactionHandle
- the handle returned from the beginTransactionprotected void commitTransaction(AgiTransactionHandle transactionHandle) throws AgoApiException { try { MyTransactionHandle hand = (MyTransactionHandle)transactionHandle; Connection conn = hand.getConnection(); conn.commit(); hand.releaseConnection(); } catch (SQLException ex) { throw new AgoSystemDatabaseException(ex, "Exception during commit"); } }
AgoDataUpdateRequest.beginTransaction()
protected abstract void abortTransaction(AgiTransactionHandle transactionHandle) throws AgoApiException
transactionHandle
- the handle returned from the beginTransactionprotected void commitTransaction(AgiTransactionHandle transactionHandle) throws AgoApiException { try { MyTransactionHandle hand = (MyTransactionHandle)transactionHandle; Connection conn = hand.getConnection(); conn.rollback(); hand.releaseConnection(); } catch (SQLException ex) { throw new AgoSystemDatabaseException(ex, "Exception during abort"); } }
AgoDataUpdateRequest.beginTransaction()
protected Enumeration executeUpdatesInTransaction(AgiTransactionHandle transactionHandle) throws AgoApiException
Most derived classes will NOT need to override this method; instead, they will depend on the prepareAndExecuteUpdate() method in the related subclass of AgoDataUpdateRow.
transactionHandle
- the handle returned from the beginTransactionprotected Enumeration executeUpdatesInTransaction(AgiTransactionHandle transactionHandle) throws AgoApiException { Enumeration enum = super.executeUpdatesInTransaction(transactionHandle); // Do some additional work here ... . . . return enum; }
AgoDataUpdateRequest.beginTransaction()
|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |