com.objectwave.persist
Class AbstractBroker

java.lang.Object
  |
  +--com.objectwave.persist.AbstractBroker
All Implemented Interfaces:
Broker
Direct Known Subclasses:
FileBroker, NullBroker, RDBBroker

public abstract class AbstractBroker
extends java.lang.Object
implements Broker

Can assist with the basic implementation of a broker.

Version:
$Id: AbstractBroker.java,v 2.1 2002/02/08 22:41:28 dave_hoag Exp $
Author:
David Hoag

Field Summary
protected  SQLConvertExceptionIF exceptionConverter
           
protected static boolean metrics
           
protected  BrokerPropertyIF props
           
 boolean verbose
           
 
Constructor Summary
AbstractBroker()
           
 
Method Summary
 void close()
          Default of close is to do nothing
protected  QueryException convertException(QueryException ex)
          This will ALWAYS return an exception.
protected  QueryException convertException(java.sql.SQLException ex, java.lang.String additionalInfo)
          This will ALWAYS return an exception.
 int count(SQLQuery q)
          Get the number of objects that match this would be found by this query.
 void deleteObjects(java.util.ArrayList deleteList)
          This default implementation may not be the most efficient, but it should work.
 SQLConvertExceptionIF getExceptionConverter()
          A converter is used to generate application specific exceptions
static void println(java.lang.String str)
          Utility method to assist with migration to logger interface.
 void setBrokerProperty(BrokerPropertyIF b)
          A BrokerPropertyIF is the mechanism by which properties are set for the broker.
 void setExceptionConverter(SQLConvertExceptionIF aValue)
          A converter is used to generate application specific exceptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.objectwave.persist.Broker
beginTransaction, commit, delete, deleteAll, find, findAttributes, findUnique, rollback, save, saveObjects
 

Field Detail

metrics

protected static boolean metrics

verbose

public boolean verbose

props

protected BrokerPropertyIF props

exceptionConverter

protected SQLConvertExceptionIF exceptionConverter
Constructor Detail

AbstractBroker

public AbstractBroker()
Method Detail

println

public static void println(java.lang.String str)
Utility method to assist with migration to logger interface.

Parameters:
str - A String to display. Used for debugging and logging purposes.

setBrokerProperty

public void setBrokerProperty(BrokerPropertyIF b)
A BrokerPropertyIF is the mechanism by which properties are set for the broker. By default, these are simply System properties. But any implementation of the BrokerPropertyIF would be valid.

Specified by:
setBrokerProperty in interface Broker
Parameters:
b - The source of property information.

setExceptionConverter

public void setExceptionConverter(SQLConvertExceptionIF aValue)
A converter is used to generate application specific exceptions

Parameters:
aValue - The new ExceptionConverter value

getExceptionConverter

public SQLConvertExceptionIF getExceptionConverter()
A converter is used to generate application specific exceptions

Returns:
The ExceptionConverter value

count

public int count(SQLQuery q)
          throws QueryException
Get the number of objects that match this would be found by this query.

Specified by:
count in interface Broker
Parameters:
q - SQLQuery that abstracts the query conditions.
Returns:
int Number of objects matching query.
Throws:
QueryException

deleteObjects

public void deleteObjects(java.util.ArrayList deleteList)
                   throws QueryException
This default implementation may not be the most efficient, but it should work.

Specified by:
deleteObjects in interface Broker
Parameters:
deleteList -
Throws:
QueryException

close

public void close()
Default of close is to do nothing

Specified by:
close in interface Broker

convertException

protected QueryException convertException(java.sql.SQLException ex,
                                          java.lang.String additionalInfo)
This will ALWAYS return an exception. This allows an Exception converter to be installed into the broker. This converter can change exception to specific exception types based upon database error codes. This would, obviously, be database specific and hence why it is not part of RDBBroker.

Parameters:
ex -
additionalInfo -
Returns:

convertException

protected QueryException convertException(QueryException ex)
This will ALWAYS return an exception. This allows an Exception converter to be installed into the broker. This converter can change exception to specific exception types based upon database error codes. This would, obviously, be database specific and hence why it is not part of RDBBroker.

Parameters:
ex -
Returns: