com.softwareag.tamino.db.api.connection
Class TTransactionMode

java.lang.Object
  extended by com.softwareag.tamino.db.api.connection.TTransactionMode
All Implemented Interfaces:
TTransaction
Direct Known Subclasses:
TAutoCommitTransactionMode, TGlobalTransactionMode, TLocalTransactionMode

public abstract class TTransactionMode
extends java.lang.Object
implements TTransaction

TTransactionMode represents a general abstraction for a specific transaction state. A transaction mode needs to be changeable if transaction specific operations are invoked on Tamino. These state changes are implicitly contained either in a TStreamHeader or in the Tamino response document. This class provides all operations needed, so that the concrete TTransactionMode instance can update its state by itself. These operations are abstract and have to be implemented by a concrete transaction state which generally can be either autocommit, local or global TTransactionMode and its concrete subclasses implement the GOF state design pattern. Here each concrete transactions state implements the behaviour needed for a transparent update on the state. Furthermore this class implements the GOF template method design pattern. This is applied for the concrete update methods. All abstract update methods are according this pattern plug in methods. Additionaly this abstract class serves as a basic transaction (no commands).

Version:
$Revision: 1.30 $
Author:
Marcus Schreyer

Constructor Summary
TTransactionMode(TTransactionModeCoordinator transactionModeCoordinator)
          Initializes with the given session mode.
 
Method Summary
abstract  void begin()
          Begin this transaction mode.
protected abstract  void doUpdate(TStreamHeader header)
          Updates the transaction mode according to the transaction specific content of the stream header.
abstract  void end()
          End this transaction mode.
protected  TGenericAccessor getGenericAccessor()
          Gets the generic accessor
 java.util.Locale getLocale()
          Gets the locale.
 TSessionState getSessionState()
          Gets the session state.
protected  TTransactionModeCoordinator getTransactionModeCoordinator()
          Gets the transactional mode coordinator.
 TTransactionParameters getTransactionParameters()
          Gets the transactional parameters.
 TTransactionTimeoutParameters getTransactionTimeoutParameters()
          Gets the transaction timeout parameters.
protected  boolean isReleased()
          Indicates if this TTransaction instance has already been released at its TConnection instance.
abstract  boolean needsSessionState(TCommand command)
          Test whether the given command statement needs session state updating, i.e.
protected  void release()
          Releases the concrete transaction.
 void setLocale(java.util.Locale locale)
          Sets the locale.
abstract  boolean supports(TCommand command)
          Indicates if the given command is supported within the current transaction mode.
 void update(TInputStream inputStream)
          Updates the transaction mode according to the transaction specific content of the input stream.
protected  void use()
          Use the concrete transaction.
abstract  void writeTo(TCommandStatement commandStatement)
          Writes the current transaction mode to the given commandStatement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TTransactionMode

public TTransactionMode(TTransactionModeCoordinator transactionModeCoordinator)
Initializes with the given session mode.

Method Detail

update

public void update(TInputStream inputStream)
            throws TTransactionModeUpdateException
Updates the transaction mode according to the transaction specific content of the input stream. This method is a template method according the GOF template method design pattern. It defines the skeletal implementation for the mode update. All abstract update methods within this class are plug in methods.

Parameters:
inputStream - represents a Tamino response stream containing a Tamino response XML document.
Throws:
TTransactionModeUpdateException - if transactions mode cannot be updated.

doUpdate

protected abstract void doUpdate(TStreamHeader header)
                          throws TSessionStateUpdateException
Updates the transaction mode according to the transaction specific content of the stream header. Returns true if transaction mode has been updated, false otherwise.

Parameters:
header - is the TStreamHeader of a TInputStream instance.
Throws:
TSessionStateUpdateException - in case of a failure.

writeTo

public abstract void writeTo(TCommandStatement commandStatement)
Writes the current transaction mode to the given commandStatement.

Parameters:
commandStatement - gets the current transaction mode.

supports

public abstract boolean supports(TCommand command)
Indicates if the given command is supported within the current transaction mode. This is needed because there might be commands (currently only cursor specific commands) that cannot be used in a specific transaction mode.

Parameters:
command - is checked wheter it can be use with the current transaction mode.
Returns:
true if the given commandStatement can be used, false otherwise.

needsSessionState

public abstract boolean needsSessionState(TCommand command)
Test whether the given command statement needs session state updating, i.e. sending sessionId/Key and updating.

Parameters:
command - test for this command.
Returns:
true -> session state update is needed, otherwise false.

begin

public abstract void begin()
                    throws TAccessorException
Begin this transaction mode.

Throws:
TAccessorException

end

public abstract void end()
                  throws TAccessorException
End this transaction mode.

Throws:
TAccessorException

getTransactionModeCoordinator

protected TTransactionModeCoordinator getTransactionModeCoordinator()
Gets the transactional mode coordinator.

Returns:
the transactional mode coordinator

getTransactionParameters

public TTransactionParameters getTransactionParameters()
Gets the transactional parameters.

Returns:
the transactional parameters

getTransactionTimeoutParameters

public TTransactionTimeoutParameters getTransactionTimeoutParameters()
Gets the transaction timeout parameters.

Returns:
the transaction timeout parameters

getSessionState

public TSessionState getSessionState()
Gets the session state.

Returns:
the session state

getGenericAccessor

protected TGenericAccessor getGenericAccessor()
Gets the generic accessor

Returns:
the generic accessor

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale.

Specified by:
setLocale in interface TTransaction

getLocale

public java.util.Locale getLocale()
Gets the locale.

Specified by:
getLocale in interface TTransaction
Returns:
the locale.

use

protected void use()
Use the concrete transaction. This means that from this point on, the concrete transaction instance can be used.


release

protected void release()
Releases the concrete transaction. This means that from this point on, the concrete transaction instance cannot be used any longer.


isReleased

protected boolean isReleased()
Indicates if this TTransaction instance has already been released at its TConnection instance.



Copyright (c) 2013 Software AG. All Rights Reserved.