Package org.apache.cayenne.access.util
Class DefaultOperationObserver
- java.lang.Object
-
- org.apache.cayenne.access.util.DefaultOperationObserver
-
- All Implemented Interfaces:
OperationHints
,OperationObserver
- Direct Known Subclasses:
IteratedSelectObserver
public class DefaultOperationObserver extends Object implements OperationObserver
Simple implementation of OperationObserver interface. Useful as a superclass of other implementations of OperationObserver. This implementation only tracks transaction events and exceptions.This operation observer is unsafe to use in application, since it doesn't rethrow the exceptions immediately, and may cause the database to hang.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Throwable>
globalExceptions
protected Map<Query,Throwable>
queryExceptions
-
Constructor Summary
Constructors Constructor Description DefaultOperationObserver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Throwable>
getGlobalExceptions()
Returns a list of global exceptions that occured during data operation run.Map<Query,Throwable>
getQueryExceptions()
Returns a list of exceptions that occured during data operation run by query.boolean
hasExceptions()
Returnstrue
if at least one exception was registered during query execution.boolean
isIteratedResult()
Returnsfalse
.void
nextBatchCount(Query query, int[] resultCount)
Callback method invoked after a batch update is executed.void
nextCount(Query query, int resultCount)
Callback method invoked after an updating query is executed.void
nextGeneratedRows(Query query, ResultIterator<?> keys, List<ObjectId> idsToUpdate)
Closes ResultIterator without reading its data.void
nextGlobalException(Exception ex)
Callback method invoked on exceptions that are not tied to a specific query execution, such as JDBC connection exceptions, etc.void
nextQueryException(Query query, Exception ex)
Callback method invoked on exceptions that happen during an execution of a specific query.void
nextRows(Query query, List<?> dataRows)
Callback method invoked for each processed ResultSet.void
nextRows(Query query, ResultIterator it)
Closes ResultIterator without reading its data.void
printExceptions(PrintWriter out)
Prints the information about query and global exceptions.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cayenne.access.OperationObserver
nextGeneratedRows
-
-
-
-
Method Detail
-
printExceptions
public void printExceptions(PrintWriter out)
Prints the information about query and global exceptions.
-
getGlobalExceptions
public List<Throwable> getGlobalExceptions()
Returns a list of global exceptions that occured during data operation run.
-
getQueryExceptions
public Map<Query,Throwable> getQueryExceptions()
Returns a list of exceptions that occured during data operation run by query.
-
hasExceptions
public boolean hasExceptions()
Returnstrue
if at least one exception was registered during query execution.
-
nextCount
public void nextCount(Query query, int resultCount)
Description copied from interface:OperationObserver
Callback method invoked after an updating query is executed.- Specified by:
nextCount
in interfaceOperationObserver
-
nextBatchCount
public void nextBatchCount(Query query, int[] resultCount)
Description copied from interface:OperationObserver
Callback method invoked after a batch update is executed.- Specified by:
nextBatchCount
in interfaceOperationObserver
-
nextRows
public void nextRows(Query query, List<?> dataRows)
Description copied from interface:OperationObserver
Callback method invoked for each processed ResultSet.- Specified by:
nextRows
in interfaceOperationObserver
-
nextRows
public void nextRows(Query query, ResultIterator it)
Closes ResultIterator without reading its data. If you implement a custom subclass, only call super if closing the iterator is what you need.- Specified by:
nextRows
in interfaceOperationObserver
-
nextGeneratedRows
public void nextGeneratedRows(Query query, ResultIterator<?> keys, List<ObjectId> idsToUpdate)
Closes ResultIterator without reading its data. If you implement a custom subclass, only call super if closing the iterator is what you need.- Specified by:
nextGeneratedRows
in interfaceOperationObserver
- Since:
- 4.0
-
nextQueryException
public void nextQueryException(Query query, Exception ex)
Description copied from interface:OperationObserver
Callback method invoked on exceptions that happen during an execution of a specific query.- Specified by:
nextQueryException
in interfaceOperationObserver
-
nextGlobalException
public void nextGlobalException(Exception ex)
Description copied from interface:OperationObserver
Callback method invoked on exceptions that are not tied to a specific query execution, such as JDBC connection exceptions, etc.- Specified by:
nextGlobalException
in interfaceOperationObserver
-
isIteratedResult
public boolean isIteratedResult()
Returnsfalse
.- Specified by:
isIteratedResult
in interfaceOperationHints
-
-