com.objectwave.persist.broker
Class FileBroker

java.lang.Object
  |
  +--com.objectwave.persist.AbstractBroker
        |
        +--com.objectwave.persist.broker.FileBroker
All Implemented Interfaces:
Broker

public class FileBroker
extends AbstractBroker

A broker that will write persistent objects out to files. Requires that the persistent objects use the RDBPersistence as their interface.

Version:
$Id: FileBroker.java,v 2.6 2001/11/02 16:07:56 dave_hoag Exp $
Author:
Dave Hoag

Nested Class Summary
static class FileBroker.Test
          Unit tests.
 
Field Summary
protected  java.util.HashMap dbFiles
          Description of the Field
 
Fields inherited from class com.objectwave.persist.AbstractBroker
exceptionConverter, metrics, props, verbose
 
Constructor Summary
FileBroker()
          Initialize the local variables.
 
Method Summary
protected  java.lang.Object actualFind(DbFile file, SQLQuery query, Persistence p)
           
 void beginTransaction()
          Do transactions make sense?
 void close()
          Shutdown gracefully.
 void commit()
          Description of the Method
 void delete(Persistence obj)
          Remove the provided object from the persistence mechanism.
 void deleteAll(SQLQuery q)
          Description of the Method
 java.lang.Object find(SQLQuery query)
          The return type of object allows the support of multiple collection types.
 java.util.Vector findAttributes(SQLQuery q, java.lang.String[] at)
           
 Persistence findUnique(SQLQuery query)
           
protected  DbFile getFile(java.lang.String fileName)
           
static RDBPersistence getRDBAdapter(Persistence object)
          A utility method that simplifies code.
protected  java.lang.String getTargetFileName(java.lang.String fileName)
           
 void initialize()
          Establish the property settings for this object.
protected  void release(DbFile dbConnection)
          Make the 'dbConnection' available to other processes.
 void rollback()
           
 void save(Persistence obj)
          Write the change to the persistence store.
 void saveObjects(java.util.ArrayList saveList)
          Save all of the objects provided and be sure to take into account bidirectional relationships.
 
Methods inherited from class com.objectwave.persist.AbstractBroker
convertException, convertException, count, deleteObjects, getExceptionConverter, println, setBrokerProperty, setExceptionConverter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbFiles

protected java.util.HashMap dbFiles
Description of the Field

Constructor Detail

FileBroker

public FileBroker()
Initialize the local variables.

Method Detail

getRDBAdapter

public static final RDBPersistence getRDBAdapter(Persistence object)
A utility method that simplifies code. Users of this broker are expected to use an RDBPersistence implementation.

Parameters:
object - Description of Parameter
Returns:
The RDBAdapter value

getFile

protected DbFile getFile(java.lang.String fileName)
                  throws java.io.IOException
Parameters:
fileName - The name of the file to create.
Returns:
The File value
Throws:
java.io.IOException - Description of Exception

getTargetFileName

protected java.lang.String getTargetFileName(java.lang.String fileName)
Parameters:
fileName - A file name independent of extensions or pathing
Returns:
The TargetFileName value

initialize

public void initialize()
Establish the property settings for this object.


beginTransaction

public void beginTransaction()
                      throws QueryException
Do transactions make sense?

Throws:
QueryException - Description of Exception

commit

public void commit()
            throws QueryException
Description of the Method

Throws:
QueryException - Description of Exception

delete

public void delete(Persistence obj)
            throws QueryException
Remove the provided object from the persistence mechanism.

Parameters:
obj - A class to be deleted.
Throws:
QueryException - Description of Exception

close

public void close()
Shutdown gracefully.

Specified by:
close in interface Broker
Overrides:
close in class AbstractBroker

find

public java.lang.Object find(SQLQuery query)
                      throws QueryException
The return type of object allows the support of multiple collection types.

Parameters:
query - Description of Parameter
Returns:
Description of the Returned Value
Throws:
QueryException - Description of Exception

deleteAll

public void deleteAll(SQLQuery q)
               throws QueryException
Description of the Method

Parameters:
q - Description of Parameter
Throws:
QueryException - Description of Exception

findAttributes

public java.util.Vector findAttributes(SQLQuery q,
                                       java.lang.String[] at)
                                throws QueryException
Parameters:
q - Description of Parameter
at - Description of Parameter
Returns:
Description of the Returned Value
Throws:
QueryException - Description of Exception

findUnique

public Persistence findUnique(SQLQuery query)
                       throws QueryException
Parameters:
query - Description of Parameter
Returns:
Description of the Returned Value
Throws:
QueryException - Description of Exception

rollback

public void rollback()
              throws QueryException
Throws:
QueryException - Description of Exception

save

public void save(Persistence obj)
          throws QueryException
Write the change to the persistence store.

Parameters:
obj - Description of Parameter
Throws:
QueryException - Description of Exception

saveObjects

public void saveObjects(java.util.ArrayList saveList)
                 throws QueryException
Save all of the objects provided and be sure to take into account bidirectional relationships.

Parameters:
saveList - Description of Parameter
Throws:
QueryException - Description of Exception

release

protected void release(DbFile dbConnection)
                throws java.io.IOException
Make the 'dbConnection' available to other processes.

Parameters:
dbConnection - Description of Parameter
Throws:
java.io.IOException - Description of Exception

actualFind

protected java.lang.Object actualFind(DbFile file,
                                      SQLQuery query,
                                      Persistence p)
                               throws java.io.IOException,
                                      java.lang.InstantiationException,
                                      java.lang.IllegalAccessException
Parameters:
file - Description of Parameter
query - Description of Parameter
p - Description of Parameter
Returns:
Description of the Returned Value
Throws:
java.io.IOException - Description of Exception
java.lang.InstantiationException - Description of Exception
java.lang.IllegalAccessException - Description of Exception