Oracle Fusion Middleware Java API Reference for Oracle ADF Model
11g Release 1 (11.1.1)

E10653-04

oracle.adfinternal.model.adapter.toplink
Class TransactionBroker

java.lang.Object
  extended by oracle.adfinternal.model.adapter.toplink.TransactionBroker
Direct Known Subclasses:
IsolatedTransactionBroker, JTATransactionBroker

public abstract class TransactionBroker
extends java.lang.Object

Purpose: Transactional unti used by all TopLinkDataControls that share common deployment resources in a given application context

Description: Defines the transactional behavior and boundaries for a given instance of a TopLink application in ADF and brokers these transactional properties between all TopLinkDataControls in this application instance. This transactional behavior includes operations such as: create, delete, update, query execution, commit, and rollback. The transactional boundaries of a given application are defined by the application BindingContext instance and extend to all TopLinDataControl which share a common binding context and TopLink deployment and data access resources.

See Also:
oracle.adf.model.adapter.toplink.TopLinkDataControl

Field Summary
protected static int CLIENT_SESSION_BROKER_TYPE
          Defines this instance as a three tier user of a TopLink Client SessionBroker per application instance.
protected static int CLIENT_SESSION_TYPE
          Defines this TransactionBroker as three tier user of a TopLink ClientSession per application instance.
protected static int ISOLATED_DATABASE_SESSION_TYPE
          Defines this TransactionBroker as using a DatabaseSession per application instance.
protected static int SHARED_DATABASE_SESSION_TYPE
          Defines this TransactionBroker as using a shared DatabaseSession across all application instances.
protected static int SHARED_SESSION_BROKER_TYPE
          Defines this TransactionBroker as using a shared SessionBroker across all application instances.
protected  boolean shouldPerformDeletesFirst
          determine if deletes should be performed first upon commit
 
Constructor Summary
protected TransactionBroker(oracle.toplink.sessions.Session session, int brokerType, boolean shouldPerformDeletesFirst, boolean shouldSequenceOnCreate)
          Creates a new TransactionBroker instance.
 
Method Summary
protected  void commitTransaction()
          Commits the UnitOfWork and all changes associated with this TransactionBroker.
 java.lang.Object createEntity(java.lang.Class objectType)
          Creates a new object instance based upon the given class type to be created in this transaction.
 java.lang.Object createEntity(java.lang.Class objectType, boolean assignSequenceNumber)
          Creates a new object instance based upon the given class type to be created in this transaction.
 java.lang.Object deleteEntity(java.lang.Object entity)
          Marks the given object to be deleted in this transaction.
protected  java.lang.Object executeQuery(java.lang.String queryName, java.util.Map parameters)
          Executes the defined TopLink query based upon the given class, query name, and parameters.
protected  java.lang.Object executeQuery(java.lang.String beanClass, java.lang.String queryName, java.util.Vector queryParameters)
          Executes the defined TopLink query based upon the given class, query name, and parameters.
 oracle.toplink.sessions.Session getSession()
          Returns the Session associated with this transaction.
abstract  oracle.toplink.sessions.UnitOfWork getUnitOfWork()
          Returns the UnitOfWork associated with this transaction.
protected  void initialize(oracle.toplink.sessions.Session session, int brokerType, boolean shouldPerformDeletesFirst, boolean shouldSequenceOnCreate)
          Initializes based constructor parameters.
protected  boolean isQuery(java.lang.String operationName)
          Indicates whether the given operation name represents a query defined in the TopLink Project.
protected  boolean isTransactionDirty()
          Returns true if the underlying UnitOfWork has ChangeSets.
 java.lang.Object registerEntity(java.lang.Object entity)
          Registers the given object in this transaction.
 java.lang.Object registerNewEntity(java.lang.Object entity)
          Registers the new Entity with the UnitOfWork.
 java.lang.Object registerNewEntity(java.lang.Object entity, boolean assignSequence)
          Registers the new Entity with the UnitOfWork.
protected  void release()
          Handles the releasing behavior that occurs when associated TopLinkDataControls are released from the binding container and subsequent application server (typically during application timeout or shutdown).
protected  void releaseSession()
          Releases the TL Session and performs a logout if necessary.
protected abstract  void releaseUnitOfWork()
          Releases the UnitOfWork for this broker.
protected  void resetState()
          Resets the transaction for all TopLinkDataControls associated with this TransactionBroker.
protected  void resetTransaction()
          Resets the transactional resources for this TransactionalBroker instance and notifies all associated TopLinkDataControls of that the transactional state has been reset.
protected abstract  void resetUnitOfWork()
          Creates and configures a the UnitOfWork used by this TransactionBrokers.
protected  void rollbackTransaction()
          Rollback the transaction for all TopLinkDataControls associated with this TransactionBroker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_SESSION_TYPE

protected static final int CLIENT_SESSION_TYPE
Defines this TransactionBroker as three tier user of a TopLink ClientSession per application instance.

See Also:
Constant Field Values

CLIENT_SESSION_BROKER_TYPE

protected static final int CLIENT_SESSION_BROKER_TYPE
Defines this instance as a three tier user of a TopLink Client SessionBroker per application instance.

See Also:
Constant Field Values

SHARED_SESSION_BROKER_TYPE

protected static final int SHARED_SESSION_BROKER_TYPE
Defines this TransactionBroker as using a shared SessionBroker across all application instances.

See Also:
Constant Field Values

SHARED_DATABASE_SESSION_TYPE

protected static final int SHARED_DATABASE_SESSION_TYPE
Defines this TransactionBroker as using a shared DatabaseSession across all application instances.

See Also:
Constant Field Values

ISOLATED_DATABASE_SESSION_TYPE

protected static final int ISOLATED_DATABASE_SESSION_TYPE
Defines this TransactionBroker as using a DatabaseSession per application instance.

See Also:
Constant Field Values

shouldPerformDeletesFirst

protected boolean shouldPerformDeletesFirst
determine if deletes should be performed first upon commit

Constructor Detail

TransactionBroker

protected TransactionBroker(oracle.toplink.sessions.Session session,
                            int brokerType,
                            boolean shouldPerformDeletesFirst,
                            boolean shouldSequenceOnCreate)
Creates a new TransactionBroker instance.

Parameters:
applicationBindingContext - - BindingContext unique to this application instance.
session - - TopLink Session for this application instance.
brokerType - - describes the mode of operation with regards to the underlying TL Session.
shouldPerformDeletesFirst - - determines whether the UnitOfWork in this TransactionBroker should perform deletes first pn commit.
Method Detail

initialize

protected void initialize(oracle.toplink.sessions.Session session,
                          int brokerType,
                          boolean shouldPerformDeletesFirst,
                          boolean shouldSequenceOnCreate)
Initializes based constructor parameters.


isTransactionDirty

protected boolean isTransactionDirty()
Returns true if the underlying UnitOfWork has ChangeSets.


commitTransaction

protected void commitTransaction()
Commits the UnitOfWork and all changes associated with this TransactionBroker.


rollbackTransaction

protected void rollbackTransaction()
Rollback the transaction for all TopLinkDataControls associated with this TransactionBroker. Also resets the transactional state as being rolled back for all TopLinkDataControls that are associated with this TransactionBroker.


resetState

protected void resetState()
Resets the transaction for all TopLinkDataControls associated with this TransactionBroker. Also resets the transactional state as being rolled back for all TopLinkDataControls that are associated with this TransactionBroker.


resetTransaction

protected void resetTransaction()
Resets the transactional resources for this TransactionalBroker instance and notifies all associated TopLinkDataControls of that the transactional state has been reset. Specifically, the TopLink UnitOfWork is reset to an initial state.


registerNewEntity

public java.lang.Object registerNewEntity(java.lang.Object entity)
Registers the new Entity with the UnitOfWork. If this TransactionBroker has been noted to sequence on create, then the new object is assigned its sequence field. Since the object is registered as a new instance, the original instance is returned by this method. Using the original versus the returned value is optional.

Parameters:
entity - - the entity to register as a new instance with the transaction.
Returns:
the registered entity.

registerNewEntity

public java.lang.Object registerNewEntity(java.lang.Object entity,
                                          boolean assignSequence)
Registers the new Entity with the UnitOfWork. If this TransactionBroker has been noted to sequence on create, then the new object is assigned its sequence field. Since the object is registered as a new instance, the original instance is returned by this method. Using the original versus the returned value is optional.

Parameters:
entity - - the entity to register as a new instance with the transaction.
assignSequence - - indicates whether to do sequencing assignment.
Returns:
the registered entity.

registerEntity

public java.lang.Object registerEntity(java.lang.Object entity)
Registers the given object in this transaction.

Returns:
- the working copy of the object.

createEntity

public java.lang.Object createEntity(java.lang.Class objectType)
Creates a new object instance based upon the given class type to be created in this transaction. This does not assign a sequence number in the case where the newly created object uses sequencing.

Returns:
the working copy of the newly created object.

createEntity

public java.lang.Object createEntity(java.lang.Class objectType,
                                     boolean assignSequenceNumber)
Creates a new object instance based upon the given class type to be created in this transaction.

Parameters:
objectType - - type of object.
assignSequenceNumber - - should assign a sequence number in the case where sequencing is used with the associated object type.
Returns:
the working copy of the newly created object.

deleteEntity

public java.lang.Object deleteEntity(java.lang.Object entity)
Marks the given object to be deleted in this transaction.

Returns:
the working copy of the deleted object.

release

protected void release()
Handles the releasing behavior that occurs when associated TopLinkDataControls are released from the binding container and subsequent application server (typically during application timeout or shutdown). For each TopLinkDataControl that this method is invoked on, they are disassociated with this TransactionBroker. Upon the last data control instance being released, the given TransactionBroker instance destroys its TL Session(in the Client Session case) and UnitOfWork as well as removing itself from the PersistenceManager.


releaseUnitOfWork

protected abstract void releaseUnitOfWork()
Releases the UnitOfWork for this broker.


releaseSession

protected void releaseSession()
Releases the TL Session and performs a logout if necessary.


executeQuery

protected java.lang.Object executeQuery(java.lang.String beanClass,
                                        java.lang.String queryName,
                                        java.util.Vector queryParameters)
                                 throws java.lang.ClassNotFoundException
Executes the defined TopLink query based upon the given class, query name, and parameters.

Returns:
results of the query.
Throws:
java.lang.ClassNotFoundException

executeQuery

protected java.lang.Object executeQuery(java.lang.String queryName,
                                        java.util.Map parameters)
Executes the defined TopLink query based upon the given class, query name, and parameters.

Returns:
results of the query.

resetUnitOfWork

protected abstract void resetUnitOfWork()
Creates and configures a the UnitOfWork used by this TransactionBrokers. The way in which the UnitOfWork is reset varies by user implementation.


getUnitOfWork

public abstract oracle.toplink.sessions.UnitOfWork getUnitOfWork()
Returns the UnitOfWork associated with this transaction.


getSession

public oracle.toplink.sessions.Session getSession()
Returns the Session associated with this transaction.


isQuery

protected boolean isQuery(java.lang.String operationName)
Indicates whether the given operation name represents a query defined in the TopLink Project.


Oracle Fusion Middleware Java API Reference for Oracle ADF Model
11g Release 1 (11.1.1)

E10653-04

Copyright © 1997, 2010, Oracle. All rights reserved.