org.apache.ojb.broker.core
Class PersistenceBrokerThreadMapping

java.lang.Object
  extended by org.apache.ojb.broker.core.PersistenceBrokerThreadMapping

public class PersistenceBrokerThreadMapping
extends java.lang.Object

Helper class that tracks correspondence between PersistenceBroker instances and threads. The main task that this class solves is: to get current PersistenceBroker for the given thread. For internal use only.

Version:
$Id: PersistenceBrokerThreadMapping.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Oleg Nitz

Constructor Summary
PersistenceBrokerThreadMapping()
           
 
Method Summary
static PersistenceBrokerInternal currentPersistenceBroker(PBKey key)
          Return the current open PersistenceBroker instance for the given PBKey, if any.
static void setCurrentPersistenceBroker(PBKey key, PersistenceBrokerInternal broker)
          Mark a PersistenceBroker as preferred choice for current Thread
static void shutdown()
          Clean up static fields and any registered ThreadLocal contents to grant a clean shutdown/reload of OJB within re/hot-deployable applications.
static void unsetCurrentPersistenceBroker(PBKey key, PersistenceBrokerInternal broker)
          Unmark a PersistenceBroker as preferred choice for current Thread
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceBrokerThreadMapping

public PersistenceBrokerThreadMapping()
Method Detail

setCurrentPersistenceBroker

public static void setCurrentPersistenceBroker(PBKey key,
                                               PersistenceBrokerInternal broker)
                                        throws PBFactoryException
Mark a PersistenceBroker as preferred choice for current Thread

Parameters:
key - The PBKey the broker is associated to
broker - The PersistenceBroker to mark as current
Throws:
PBFactoryException

unsetCurrentPersistenceBroker

public static void unsetCurrentPersistenceBroker(PBKey key,
                                                 PersistenceBrokerInternal broker)
                                          throws PBFactoryException
Unmark a PersistenceBroker as preferred choice for current Thread

Parameters:
key - The PBKey the broker is associated to
broker - The PersistenceBroker to unmark
Throws:
PBFactoryException

currentPersistenceBroker

public static PersistenceBrokerInternal currentPersistenceBroker(PBKey key)
                                                          throws PBFactoryException,
                                                                 PersistenceBrokerException
Return the current open PersistenceBroker instance for the given PBKey, if any.

Parameters:
key -
Returns:
null if no open PersistenceBroker found.
Throws:
PBFactoryException
PersistenceBrokerException

shutdown

public static void shutdown()
Clean up static fields and any registered ThreadLocal contents to grant a clean shutdown/reload of OJB within re/hot-deployable applications.



(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