com.objectwave.persist.broker
Class ObjectPoolBroker

java.lang.Object
  |
  +--com.objectwave.persist.broker.ObjectPoolBroker
All Implemented Interfaces:
Broker, java.io.Serializable

public class ObjectPoolBroker
extends java.lang.Object
implements Broker, java.io.Serializable

Will use the object pool as an 'object' database. ow.poolVerbose ow.defaultPoolSize ow.poolSize:

Version:
$Id: ObjectPoolBroker.java,v 2.1 2001/11/02 16:07:56 dave_hoag Exp $
Author:
Dave Hoag
See Also:
Serialized Form

Nested Class Summary
static class ObjectPoolBroker.Test
          Unit Testing - Reuse the tests from BasicTestBroker
 
Constructor Summary
ObjectPoolBroker()
           
ObjectPoolBroker(ObjectPool subject)
           
ObjectPoolBroker(ObjectPool subject, boolean connected)
           
 
Method Summary
 void beginTransaction()
           
 void close()
          Drop the object pool
 void commit()
           
 int count(SQLQuery q)
          Get the number of objects that match this would be found by this query.
 void delete(Persistence p)
           
 void deleteAll(SQLQuery q)
          Crude implementation.
 void deleteObjects(java.util.ArrayList deleteList)
           
 void dumpChanges()
           
 java.lang.Object find(SQLQuery q)
          The return type of object allows the support of multiple collection types.
 java.util.Vector findAttributes(SQLQuery q, java.lang.String[] paths)
           
protected  java.lang.Object findAttributeValue(Persistence p, java.lang.String path)
           
 Persistence findUnique(SQLQuery q)
           
 java.util.ArrayList getChangedObjects()
          Those objects which are believed to have been changed in the current transaction.
static ObjectPoolBroker getDefaultBroker()
           
 java.util.ArrayList getNewObjects()
          Any objects that have a primary key field of < 0 are considered new.
 ObjectPool getObjectPool()
          Return the pool upon which this class in manipulating.
protected  RDBPersistence getRDBAdapter(Persistence object)
          A utility method that simplifies code.
 boolean isTrackingChangedObjects()
          Gets the TrackingChangedObjects attribute of the ObjectPoolBroker object
static void main(java.lang.String[] args)
          Test routine
 void rollback()
          Discard any changes that have been made in the current transaction.
 void save(Persistence obj)
           
 void saveObjects(java.util.ArrayList saveList)
          Support the persistence api.
 void setBrokerProperty(BrokerPropertyIF b)
           
static void setDefaultBroker(ObjectPoolBroker b)
           
 void setObjectPool(ObjectPool p)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPoolBroker

public ObjectPoolBroker()

ObjectPoolBroker

public ObjectPoolBroker(ObjectPool subject,
                        boolean connected)
Parameters:
subject -
connected -

ObjectPoolBroker

public ObjectPoolBroker(ObjectPool subject)
Parameters:
subject -
Method Detail

setDefaultBroker

public static void setDefaultBroker(ObjectPoolBroker b)
Parameters:
b - The new DefaultBroker value

getDefaultBroker

public static ObjectPoolBroker getDefaultBroker()
Returns:
The DefaultBroker value

main

public static void main(java.lang.String[] args)
Test routine

Parameters:
args - The command line arguments

setBrokerProperty

public void setBrokerProperty(BrokerPropertyIF b)
Specified by:
setBrokerProperty in interface Broker
Parameters:
b - The new BrokerProperty value

setObjectPool

public void setObjectPool(ObjectPool p)
Parameters:
p - The new ObjectPool value

getRDBAdapter

protected final RDBPersistence getRDBAdapter(Persistence object)
A utility method that simplifies code.

Parameters:
object -
Returns:
The RDBAdapter value

getChangedObjects

public java.util.ArrayList getChangedObjects()
Those objects which are believed to have been changed in the current transaction.

Returns:
The ChangedObjects value

getNewObjects

public java.util.ArrayList getNewObjects()
Any objects that have a primary key field of < 0 are considered new. This supports object pools being used as temporary databases.

Returns:
The NewObjects value

getObjectPool

public ObjectPool getObjectPool()
Return the pool upon which this class in manipulating.

Returns:
The ObjectPool value

isTrackingChangedObjects

public final boolean isTrackingChangedObjects()
Gets the TrackingChangedObjects attribute of the ObjectPoolBroker object

Returns:
The TrackingChangedObjects value

beginTransaction

public void beginTransaction()
                      throws QueryException
Specified by:
beginTransaction in interface Broker
Throws:
QueryException

commit

public void commit()
            throws QueryException
Specified by:
commit in interface Broker
Throws:
QueryException

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

delete

public void delete(Persistence p)
            throws QueryException
Specified by:
delete in interface Broker
Parameters:
p -
Throws:
QueryException

deleteObjects

public void deleteObjects(java.util.ArrayList deleteList)
                   throws QueryException
Specified by:
deleteObjects in interface Broker
Parameters:
deleteList -
Throws:
QueryException

dumpChanges

public void dumpChanges()

deleteAll

public void deleteAll(SQLQuery q)
               throws QueryException
Crude implementation. Delete (remove from the pool) all objects that match the query constraint.

Specified by:
deleteAll in interface Broker
Parameters:
q -
Throws:
QueryException

find

public java.lang.Object find(SQLQuery q)
                      throws QueryException
Description copied from interface: Broker
The return type of object allows the support of multiple collection types.

Specified by:
find in interface Broker
Parameters:
q -
Returns:
The collection as mandated by the query. The default is a vector.
Throws:
QueryException

findAttributes

public java.util.Vector findAttributes(SQLQuery q,
                                       java.lang.String[] paths)
                                throws QueryException
Specified by:
findAttributes in interface Broker
Parameters:
q -
paths -
Returns:
A java.util.Vector of Object []
Throws:
QueryException

findAttributeValue

protected java.lang.Object findAttributeValue(Persistence p,
                                              java.lang.String path)
Parameters:
p - The source object from which the path statement will begin it's search.
path -
Returns:
The columnName to use in this query that will correspond to the 'path'.
See Also:
findAttributes(com.objectwave.persist.SQLQuery, java.lang.String[])

findUnique

public Persistence findUnique(SQLQuery q)
                       throws QueryException
Specified by:
findUnique in interface Broker
Parameters:
q -
Returns:
Throws:
QueryException

rollback

public void rollback()
              throws QueryException
Discard any changes that have been made in the current transaction.

Specified by:
rollback in interface Broker
Throws:
QueryException

save

public void save(Persistence obj)
          throws QueryException
Specified by:
save in interface Broker
Parameters:
obj -
Throws:
QueryException

saveObjects

public void saveObjects(java.util.ArrayList saveList)
                 throws QueryException
Support the persistence api. Just save every object in the collection.

Specified by:
saveObjects in interface Broker
Parameters:
saveList -
Throws:
QueryException

close

public void close()
Drop the object pool

Specified by:
close in interface Broker