org.springframework.orm.ojb
Class OjbFactoryUtils

java.lang.Object
  extended by org.springframework.orm.ojb.OjbFactoryUtils

public abstract class OjbFactoryUtils
extends Object

Helper class featuring methods for OJB PersistenceBroker handling, allowing for reuse of PersistenceBroker instances within transactions.

Used by PersistenceBrokerTemplate and PersistenceBrokerTransactionManager. Can also be used directly in application code.

Since:
1.1
Author:
Juergen Hoeller
See Also:
PersistenceBrokerTemplate, PersistenceBrokerTransactionManager, JtaTransactionManager

Field Summary
static int PERSISTENCE_BROKER_SYNCHRONIZATION_ORDER
          Order value for TransactionSynchronization objects that clean up OJB PersistenceBrokers.
 
Constructor Summary
OjbFactoryUtils()
           
 
Method Summary
static void closePersistenceBrokerIfNecessary(org.apache.ojb.broker.PersistenceBroker pb, org.apache.ojb.broker.PBKey pbKey)
          Deprecated. in favor of releasePersistenceBroker
static org.apache.ojb.broker.PersistenceBroker getPersistenceBroker(org.apache.ojb.broker.PBKey pbKey, boolean allowCreate)
          Get an OJB PersistenceBroker for the given PBKey.
static void releasePersistenceBroker(org.apache.ojb.broker.PersistenceBroker pb, org.apache.ojb.broker.PBKey pbKey)
          Close the given PersistenceBroker, created for the given PBKey, if it is not managed externally (i.e. not bound to the thread).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERSISTENCE_BROKER_SYNCHRONIZATION_ORDER

public static final int PERSISTENCE_BROKER_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up OJB PersistenceBrokers. Return DataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER - 100 to execute PersistenceBroker cleanup before JDBC Connection cleanup, if any.

See Also:
DataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER, Constant Field Values
Constructor Detail

OjbFactoryUtils

public OjbFactoryUtils()
Method Detail

getPersistenceBroker

public static org.apache.ojb.broker.PersistenceBroker getPersistenceBroker(org.apache.ojb.broker.PBKey pbKey,
                                                                           boolean allowCreate)
                                                                    throws DataAccessResourceFailureException,
                                                                           IllegalStateException
Get an OJB PersistenceBroker for the given PBKey. Is aware of a corresponding PersistenceBroker bound to the current thread, for example when using PersistenceBrokerTransactionManager. Will create a new PersistenceBroker else, if allowCreate is true.

Parameters:
pbKey - PBKey to create the PersistenceBroker for
allowCreate - if a non-transactional PersistenceBroker should be created when no transactional PersistenceBroker can be found for the current thread
Returns:
the PersistenceBroker
Throws:
DataAccessResourceFailureException - if the PersistenceBroker couldn't be created
IllegalStateException - if no thread-bound PersistenceBroker found and allowCreate false

closePersistenceBrokerIfNecessary

public static void closePersistenceBrokerIfNecessary(org.apache.ojb.broker.PersistenceBroker pb,
                                                     org.apache.ojb.broker.PBKey pbKey)
Deprecated. in favor of releasePersistenceBroker

Close the given PersistenceBroker, created for the given PBKey, if it isn't bound to the thread.

See Also:
releasePersistenceBroker(org.apache.ojb.broker.PersistenceBroker, org.apache.ojb.broker.PBKey)

releasePersistenceBroker

public static void releasePersistenceBroker(org.apache.ojb.broker.PersistenceBroker pb,
                                            org.apache.ojb.broker.PBKey pbKey)
Close the given PersistenceBroker, created for the given PBKey, if it is not managed externally (i.e. not bound to the thread).

Parameters:
pb - PersistenceBroker to close
pbKey - PBKey that the PersistenceBroker was created with


Copyright (c) 2002-2006 The Spring Framework Project.