org.apache.cayenne.access.util
Class DefaultOperationObserver

java.lang.Object
  extended by org.apache.cayenne.access.util.DefaultOperationObserver
All Implemented Interfaces:
OperationHints, OperationObserver
Direct Known Subclasses:
ContextCommitObserver, IteratedSelectObserver, QueryResult, SelectObserver

public class DefaultOperationObserver
extends java.lang.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.

Author:
Andrei Adamchik

Field Summary
static org.apache.log4j.Level DEFAULT_LOG_LEVEL
          Deprecated. Unused since 1.2
protected  java.util.List globalExceptions
           
protected  java.util.Map queryExceptions
           
 
Constructor Summary
DefaultOperationObserver()
           
 
Method Summary
 java.util.List getGlobalExceptions()
          Returns a list of global exceptions that occured during data operation run.
 org.apache.log4j.Level getLoggingLevel()
          Deprecated. since 1.2
 java.util.Map getQueryExceptions()
          Returns a list of exceptions that occured during data operation run by query.
 boolean hasExceptions()
          Returns true if at least one exception was registered during query execution.
 boolean isIteratedResult()
          Returns false.
 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 nextDataRows(Query query, java.util.List dataRows)
          Callback method invoked for each processed ResultSet.
 void nextDataRows(Query query, ResultIterator it)
          Closes ResultIterator without reading its data.
 void nextGeneratedDataRows(Query query, ResultIterator keysIterator)
          Closes ResultIterator without reading its data.
 void nextGlobalException(java.lang.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, java.lang.Exception ex)
          Callback method invoked on exceptions that happen during an execution of a specific query.
 void printExceptions(java.io.PrintWriter out)
          Prints the information about query and global exceptions.
 void setLoggingLevel(org.apache.log4j.Level level)
          Deprecated. since 1.2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LOG_LEVEL

public static final org.apache.log4j.Level DEFAULT_LOG_LEVEL
Deprecated. Unused since 1.2

globalExceptions

protected java.util.List globalExceptions

queryExceptions

protected java.util.Map queryExceptions
Constructor Detail

DefaultOperationObserver

public DefaultOperationObserver()
Method Detail

printExceptions

public void printExceptions(java.io.PrintWriter out)
Prints the information about query and global exceptions.


getGlobalExceptions

public java.util.List getGlobalExceptions()
Returns a list of global exceptions that occured during data operation run.


getQueryExceptions

public java.util.Map getQueryExceptions()
Returns a list of exceptions that occured during data operation run by query.


hasExceptions

public boolean hasExceptions()
Returns true if at least one exception was registered during query execution.


getLoggingLevel

public org.apache.log4j.Level getLoggingLevel()
Deprecated. since 1.2

Returns a log level level that should be used when logging query execution.

Specified by:
getLoggingLevel in interface OperationHints

setLoggingLevel

public void setLoggingLevel(org.apache.log4j.Level level)
Deprecated. since 1.2

Sets log level that should be used for queries. If level argument is null, level is set to DEFAULT_LOG_LEVEL. If level is equal or higher than log level configured for QueryLogger, query SQL statements will be logged.


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 interface OperationObserver

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 interface OperationObserver

nextDataRows

public void nextDataRows(Query query,
                         java.util.List dataRows)
Description copied from interface: OperationObserver
Callback method invoked for each processed ResultSet.

Specified by:
nextDataRows in interface OperationObserver

nextDataRows

public void nextDataRows(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:
nextDataRows in interface OperationObserver

nextGeneratedDataRows

public void nextGeneratedDataRows(Query query,
                                  ResultIterator keysIterator)
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:
nextGeneratedDataRows in interface OperationObserver
Since:
1.2

nextQueryException

public void nextQueryException(Query query,
                               java.lang.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 interface OperationObserver

nextGlobalException

public void nextGlobalException(java.lang.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 interface OperationObserver

isIteratedResult

public boolean isIteratedResult()
Returns false.

Specified by:
isIteratedResult in interface OperationHints


Copyright © 2001-2006 Apache.org All Rights Reserved.