org.apache.ojb.broker.core
Class PersistenceBrokerFactoryDefaultImpl

java.lang.Object
  extended by org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl
      extended by org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl
All Implemented Interfaces:
PersistenceBrokerFactoryIF, org.apache.ojb.broker.util.configuration.Configurable
Direct Known Subclasses:
PersistenceBrokerFactorySyncImpl

public class PersistenceBrokerFactoryDefaultImpl
extends PersistenceBrokerFactoryBaseImpl

This is the default implementation of the PersistenceBrokerFactoryIF interface.

This implementation use a pool of PersistenceBroker instances [abbr. PB]. Each pooled PB instance (the implementation class was specified in OJB configuration file) is wrapped by PoolablePersistenceBroker class before add to pool.

When calling createPersistenceBroker(org.apache.ojb.broker.PBKey) or PersistenceBrokerFactoryBaseImpl.defaultPersistenceBroker() the pooled-PB instance (PoolablePersistenceBroker) on its part was wrapped with PersistenceBrokerHandle handle.

When a client do a PB.close() call on the handle the wrapped PoolablePersistenceBroker will be closed and returned to pool. All further method calls on the handle (except PB.isClosed() and PB.isInTransaction()) result in an exception.

Each different PBKey (based on PBKey.equals(...) method) get its own PB-pool.

Version:
$Id: PersistenceBrokerFactoryDefaultImpl.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Thomas Mahler, Armin Waibel
See Also:
PersistenceBrokerFactoryBaseImpl

Constructor Summary
PersistenceBrokerFactoryDefaultImpl()
           
 
Method Summary
 int activePersistenceBroker()
          Not implemented!
 PersistenceBrokerInternal createPersistenceBroker(PBKey pbKey)
          Return broker instance from pool.
 java.util.Properties getPoolConfiguration()
          could be used for monitoring TODO: is this useful?
 void releaseAllInstances()
          release all broker instances pooled by the factory.
 void setPoolConfiguration(java.util.Properties prop)
          could be used for runtime configuration TODO: is this useful?
 void shutdown()
          Shutdown method for OJB, kills all running processes within OJB - after shutdown OJB can no longer be used.
 
Methods inherited from class org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl
configure, createPersistenceBroker, defaultPersistenceBroker, getDefaultKey, setDefaultKey
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceBrokerFactoryDefaultImpl

public PersistenceBrokerFactoryDefaultImpl()
Method Detail

createPersistenceBroker

public PersistenceBrokerInternal createPersistenceBroker(PBKey pbKey)
                                                  throws PBFactoryException
Return broker instance from pool. If given PBKey was not found in pool a new pool for given

Specified by:
createPersistenceBroker in interface PersistenceBrokerFactoryIF
Overrides:
createPersistenceBroker in class PersistenceBrokerFactoryBaseImpl
Parameters:
pbKey -
Returns:
Throws:
PBFactoryException

releaseAllInstances

public void releaseAllInstances()
Description copied from interface: PersistenceBrokerFactoryIF
release all broker instances pooled by the factory. each broker instance is closed before release.

Specified by:
releaseAllInstances in interface PersistenceBrokerFactoryIF
Overrides:
releaseAllInstances in class PersistenceBrokerFactoryBaseImpl
See Also:
PersistenceBrokerFactoryIF.releaseAllInstances()

shutdown

public void shutdown()
Description copied from interface: PersistenceBrokerFactoryIF
Shutdown method for OJB, kills all running processes within OJB - after shutdown OJB can no longer be used.
This method is introduced to solve hot/redeployment problems (memory leaks) caused by the usage of ThreadLocal instances in OJB source and the reuse of threads by the container (e.g. servlet- or ejb-container).

Specified by:
shutdown in interface PersistenceBrokerFactoryIF
Overrides:
shutdown in class PersistenceBrokerFactoryBaseImpl

activePersistenceBroker

public int activePersistenceBroker()
Description copied from class: PersistenceBrokerFactoryBaseImpl
Not implemented!

Specified by:
activePersistenceBroker in interface PersistenceBrokerFactoryIF
Overrides:
activePersistenceBroker in class PersistenceBrokerFactoryBaseImpl
Returns:
always 0

getPoolConfiguration

public java.util.Properties getPoolConfiguration()
could be used for monitoring TODO: is this useful?


setPoolConfiguration

public void setPoolConfiguration(java.util.Properties prop)
could be used for runtime configuration TODO: is this useful?



(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30