/** * Notify all listeners that a rollback is about to occur. If a listener throws an exception then * no further listeners will be notified and a StandardException with shutdown database(?) * severity will be thrown. * * @throws StandardException */ public void preRollbackNotify() throws StandardException { if (listeners.isEmpty()) return; for (Iterator i = listeners.iterator(); i.hasNext(); ) { TransactionListener listener = (TransactionListener) i.next(); try { listener.preRollback(); i.remove(); } catch (StandardException se) { // TODO: Define behaviour on exception during rollback. if (se.getSeverity() < ExceptionSeverity.TRANSACTION_SEVERITY) {} throw se; } } }
/** * Convert this page to requested type, as defined by input format id. * * <p>The current cache entry is a different format id than the requested type, change it. This * object is instantiated to the wrong subtype of cachedPage, this routine will create an object * with the correct subtype, and transfer all pertinent information from this to the new correct * object. * * <p> * * @return The new object created with the input fid and transfered info. * @param fid The format id of the new page. * @param newIdentity The key of the new page. * @exception StandardException Standard exception policy. */ private CachedPage changeInstanceTo(int fid, PageKey newIdentity) throws StandardException { CachedPage realPage; try { realPage = (CachedPage) Monitor.newInstanceFromIdentifier(fid); } catch (StandardException se) { if (se.getSeverity() > ExceptionSeverity.STATEMENT_SEVERITY) { throw se; } else { throw StandardException.newException( SQLState.DATA_UNKNOWN_PAGE_FORMAT_2, newIdentity, org.apache.derby.iapi.util.StringUtil.hexDump(pageData)); } } realPage.setFactory(dataFactory); // avoid creating the data buffer if possible, transfer it to the new // page if this is the first time the page buffer is used, then // createPage will create the page array with the correct page size if (this.pageData != null) { realPage.alreadyReadPage = true; realPage.usePageBuffer(this.pageData); } // RESOLVE (12/15/06) - the following code is commented out, but // not sure why. // this page should not be used any more, null out all its content and // wait for GC to clean it up // destroyPage();// let this subtype have a chance to get rid of stuff // this.pageData = null; // this instance no longer own the data array // this.pageCache = null; // this.dataFactory = null; // this.containerCache = null; return realPage; }
/** * Notify all listeners that a commit is about to occur. If a listener throws an exception then no * further listeners will be notified and a StandardException with rollback severity will be * thrown. * * @throws StandardException */ public void preCommitNotify() throws StandardException { if (listeners.isEmpty()) return; for (Iterator i = listeners.iterator(); i.hasNext(); ) { TransactionListener listener = (TransactionListener) i.next(); try { if (listener.preCommit()) i.remove(); } catch (StandardException se) { // This catches any exceptions that have Transaction severity // or less (e.g. Statement exception). // If we received any lesser // error then we abort the transaction anyway. if (se.getSeverity() < ExceptionSeverity.TRANSACTION_SEVERITY) { throw StandardException.newException(SQLState.XACT_COMMIT_EXCEPTION, se); } throw se; } } }