com.objectwave.persist
Class BrokerFactory

java.lang.Object
  |
  +--com.objectwave.persist.BrokerFactory

public class BrokerFactory
extends java.lang.Object

Factory may be an incorrect name. More like a BrokerManager. Here we initialize and contain references to the Persistence framework.

Version:
$Id: BrokerFactory.java,v 2.1 2002/02/13 21:36:18 dave_hoag Exp $
Author:
dhoag

Field Summary
static PersistLogIF logger
           
 
Constructor Summary
BrokerFactory()
           
 
Method Summary
static void addStaticBroker(java.lang.String name, Broker broker)
          This method is for adding a broker to the static list which is not an RBDBroker or is a special case thereof which cannot be handled by the lazy-initialization system.
static void addStaticBroker(java.lang.String name, java.lang.String connectUrl)
          Add a static broker type to the factory.
static void addStaticBroker(java.lang.String name, java.lang.String connectUrl, java.lang.String driver)
          Add a static broker type to the factory.
static Broker getBroker(java.lang.String name)
          Get any broker that's been registered via addStaticBroker.
static java.util.Hashtable getBrokerInstances()
          Gets the BrokerInstances attribute of the BrokerFactory class
static RDBBroker getDatabaseBroker()
          This will invoke the 'createBroker' method on the instance of RDBBroker (or a subclass).
static Broker getDefaultBroker()
          It is intedended that an Broker never be manually instantiated.
static BrokerPropertyIF getDefaultProperties()
           
static ObjectPoolBroker getObjectPoolBroker()
          Gets the ObjectPoolBroker attribute of the BrokerFactory class
static void println(java.lang.String str)
          Utility method to assist with migration to logger interface.
static void setDefaultBroker(Broker b)
           
static void setDefaultProperties(BrokerPropertyIF prop)
           
static void useDatabase()
          Convience method for setting up persistence to use RDBBroker.
static void useDatabase(boolean pool, ObjectPool p)
          Convience method for setting up persistence to use RDBBroker.
static void useObjectPoolBroker(ObjectPool p)
          Convience method for setting up persistence to use objectpool broker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static PersistLogIF logger
Constructor Detail

BrokerFactory

public BrokerFactory()
Method Detail

setDefaultBroker

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

setDefaultProperties

public static void setDefaultProperties(BrokerPropertyIF prop)
Parameters:
prop - The new DefaultProperties value

getBroker

public static Broker getBroker(java.lang.String name)
                        throws QueryException
Get any broker that's been registered via addStaticBroker. Check the static initializer block of this class to see what types are automatically registered.

Parameters:
name - String Some string to identify the broker. (ex. "jdbc:odbc:leasing")
Returns:
The Broker value
Throws:
QueryException

getBrokerInstances

public static java.util.Hashtable getBrokerInstances()
Gets the BrokerInstances attribute of the BrokerFactory class

Returns:
The BrokerInstances value

getDatabaseBroker

public static RDBBroker getDatabaseBroker()
This will invoke the 'createBroker' method on the instance of RDBBroker (or a subclass). The createBroker method will return an instance of the appropriate type.

Returns:
The DatabaseBroker value

getDefaultBroker

public static Broker getDefaultBroker()
It is intedended that an Broker never be manually instantiated. A single instance of Broker will need to be shared among many different aspects of the application, therefore an application should only obtain a handle to the broker with this factory method.

Returns:
The DefaultBroker value

getObjectPoolBroker

public static ObjectPoolBroker getObjectPoolBroker()
Gets the ObjectPoolBroker attribute of the BrokerFactory class

Returns:
The ObjectPoolBroker value

getDefaultProperties

public static BrokerPropertyIF getDefaultProperties()
Returns:
The DefaultProperties value

addStaticBroker

public static void addStaticBroker(java.lang.String name,
                                   Broker broker)
This method is for adding a broker to the static list which is not an RBDBroker or is a special case thereof which cannot be handled by the lazy-initialization system. ex.

  String db = System.getProperty("pooledBroker.databaseImpl",
  "com.objectwave.persist.OracleBroker"); try { Class c = Class.forName(db);
  RDBBroker broker = (RDBBroker) c.newInstance();
  broker.setBrokerProperty(props); broker.initialize();
  broker.setUsingObjectPool(true); BrokerFactory.addStaticBroker("pooledBroker",
  broker); } catch (Exception ex) { BrokerFactory.println(ex.toString()); }
  

Parameters:
name - The feature to be added to the StaticBroker attribute
broker - The feature to be added to the StaticBroker attribute

addStaticBroker

public static void addStaticBroker(java.lang.String name,
                                   java.lang.String connectUrl)
Add a static broker type to the factory. Also see addStaticBroker(String, Driver).

Parameters:
name - The feature to be added to the StaticBroker attribute
connectUrl - The feature to be added to the StaticBroker attribute

addStaticBroker

public static void addStaticBroker(java.lang.String name,
                                   java.lang.String connectUrl,
                                   java.lang.String driver)
Add a static broker type to the factory. The name should be the connect URL to use, and the Driver should be the proper driver for the given connection. If driver is null, then a default driver of type JdbcOdbcDriver is used.

Parameters:
name - The feature to be added to the StaticBroker attribute
connectUrl - The feature to be added to the StaticBroker attribute
driver - The feature to be added to the StaticBroker attribute

println

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

Parameters:
str -

useDatabase

public static void useDatabase()
Convience method for setting up persistence to use RDBBroker. No object pooling. This is probably the most likely means to initialize Persistence.


useDatabase

public static void useDatabase(boolean pool,
                               ObjectPool p)
Convience method for setting up persistence to use RDBBroker.

Parameters:
pool - Enable object pooling
p - The pool to use for object pooling.

useObjectPoolBroker

public static void useObjectPoolBroker(ObjectPool p)
Convience method for setting up persistence to use objectpool broker.

Parameters:
p -