org.apache.ojb.broker.core
Class PersistenceBrokerFactorySyncImpl

java.lang.Object
  extended byorg.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl
      extended byorg.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl
          extended byorg.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl
All Implemented Interfaces:
Configurable, PersistenceBrokerFactoryIF

public class PersistenceBrokerFactorySyncImpl
extends PersistenceBrokerFactoryDefaultImpl

Workaround for participate the PB-api in JTA transaction by implementing the Synchronization interface.
This may will be deprecated when we implemented a full JCA compliant connector.
When a new PersistenceBroker instance is created in method wrapBrokerWithPoolingHandle(org.apache.ojb.broker.PersistenceBroker, org.apache.commons.pool.KeyedObjectPool) the given PB instance is wrapped with PersistenceBrokerFactorySyncImpl.PersistenceBrokerSyncImpl before it was put to the PB-pool. When a PB instance was requested class try to lookup the current JTA transaction in wrapRequestedBrokerInstance(org.apache.ojb.broker.PersistenceBroker) before the pooled PB instance was wrapped with the PB handle. If a running tx was found the PB instance was registered with the transaction using the Synchronization interface.

Version:
$Id: PersistenceBrokerFactorySyncImpl.java,v 1.2 2004/02/18 19:39:59 arminw Exp $
Author:
Armin Waibel

Nested Class Summary
static class PersistenceBrokerFactorySyncImpl.PersistenceBrokerSyncImpl
           
(package private)  class PersistenceBrokerFactorySyncImpl.TransactionBox
          This class collects all PB instances requested in the scope of one transaction
(package private)  class PersistenceBrokerFactorySyncImpl.TxRegistry
          Maps all TransactionBox instances based on Transaction object identity.
 
Nested classes inherited from class org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl
PersistenceBrokerFactoryDefaultImpl.PBKeyedPoolableObjectFactory
 
Constructor Summary
PersistenceBrokerFactorySyncImpl()
           
 
Method Summary
protected  PersistenceBroker wrapBrokerWithPoolingHandle(PersistenceBroker broker, org.apache.commons.pool.KeyedObjectPool pool)
          Each real pooled PersistenceBroker instance was wrapped by a pooling handle when a new instance was created.
protected  PersistenceBroker wrapRequestedBrokerInstance(PersistenceBroker broker)
          Wraps the requested pooled broker instance.
 
Methods inherited from class org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl
activePersistenceBroker, createPersistenceBroker, getPoolConfiguration, releaseAllInstances, setPoolConfiguration
 
Methods inherited from class org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl
configure, createNewBrokerInstance, createPersistenceBroker, defaultPersistenceBroker, getDefaultKey, setDefaultKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceBrokerFactorySyncImpl

public PersistenceBrokerFactorySyncImpl()
Method Detail

wrapBrokerWithPoolingHandle

protected PersistenceBroker wrapBrokerWithPoolingHandle(PersistenceBroker broker,
                                                        org.apache.commons.pool.KeyedObjectPool pool)
Description copied from class: PersistenceBrokerFactoryDefaultImpl
Each real pooled PersistenceBroker instance was wrapped by a pooling handle when a new instance was created.

Overrides:
wrapBrokerWithPoolingHandle in class PersistenceBrokerFactoryDefaultImpl
Parameters:
broker - real PersistenceBroker instance
pool - use KeyedObjectPool
Returns:
wrapped broker instance
See Also:
PoolablePersistenceBroker

wrapRequestedBrokerInstance

protected PersistenceBroker wrapRequestedBrokerInstance(PersistenceBroker broker)
Description copied from class: PersistenceBrokerFactoryDefaultImpl
Wraps the requested pooled broker instance. The returned handle warps a pooled broker instance to avoid corruption of already closed broker instances.

Overrides:
wrapRequestedBrokerInstance in class PersistenceBrokerFactoryDefaultImpl
Parameters:
broker -
Returns:
See Also:
PersistenceBrokerHandle


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14