org.springframework.orm.ojb
Class OjbFactoryUtils

java.lang.Object
  extended byorg.springframework.orm.ojb.OjbFactoryUtils

public abstract class OjbFactoryUtils
extends java.lang.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:
02.07.2004
Author:
Juergen Hoeller
See Also:
PersistenceBrokerTemplate, PersistenceBrokerTransactionManager, JtaTransactionManager

Constructor Summary
OjbFactoryUtils()
           
 
Method Summary
static void closePersistenceBrokerIfNecessary(org.apache.ojb.broker.PersistenceBroker pb, org.apache.ojb.broker.PBKey pbKey)
          Close the given PersistenceBroker, created for the given PBKey, if it isn't bound to the thread.
static org.apache.ojb.broker.PersistenceBroker getPersistenceBroker(org.apache.ojb.broker.PBKey pbKey, boolean allowCreate)
          Get an OJB PersistenceBroker for the given PBKey.
static org.apache.ojb.broker.PersistenceBroker getPersistenceBroker(org.apache.ojb.broker.PBKey pbKey, boolean allowCreate, boolean allowSynchronization)
          Get an OJB PersistenceBroker for the given PBKey.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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,
                                                                           java.lang.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 new PersistenceBroker should be created if no thread-bound found
Returns:
the PersistenceBroker
Throws:
DataAccessResourceFailureException - if the PersistenceBroker couldn't be created
java.lang.IllegalStateException - if no thread-bound PersistenceBroker found and allowCreate false

getPersistenceBroker

public static org.apache.ojb.broker.PersistenceBroker getPersistenceBroker(org.apache.ojb.broker.PBKey pbKey,
                                                                           boolean allowCreate,
                                                                           boolean allowSynchronization)
                                                                    throws DataAccessResourceFailureException,
                                                                           java.lang.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.

Parameters:
pbKey - PBKey to create the PersistenceBroker for
allowCreate - if a new PersistenceBroker should be created if no thread-bound found
allowSynchronization - if a new OJB PersistenceBroker is supposed to be registered with transaction synchronization (if synchronization is active). This will always be true for typical data access code.
Returns:
the PersistenceBroker
Throws:
DataAccessResourceFailureException - if the PersistenceBroker couldn't be created
java.lang.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)
Close the given PersistenceBroker, created for the given PBKey, if it isn't bound to the thread.

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


Copyright (C) 2003-2004 The Spring Framework Project.