com.softwareag.tamino.db.api.invocation
Class TAbstractInvocation

java.lang.Object
  extended by com.softwareag.tamino.db.api.invocation.TAbstractInvocation
All Implemented Interfaces:
TInvocation, TRetryInvocation
Direct Known Subclasses:
THTTPInvocation, TWSLInvocation

public abstract class TAbstractInvocation
extends java.lang.Object
implements TInvocation, TRetryInvocation

This class provides a skeletal implementation of the TCommandInvocation interface. It is mainly responsible to manage the URL information and the session state that might be command given by a TCommandStatement instance on a Tamino database.

Version:
$Revision: 1.51 $
Author:
Marcus Schreyer

Field Summary
static java.lang.String PROP_RETRY
           
 
Constructor Summary
TAbstractInvocation(TUri databaseUri)
          Initializes the invocation with the given database uri.
TAbstractInvocation(TUri databaseUri, SecurityToken token)
           
TAbstractInvocation(TUri databaseUri, java.lang.String userId, java.lang.String password)
          Initializes the invocation with the given database uri, userId and password.
TAbstractInvocation(TUri databaseUri, java.lang.String domain, java.lang.String userId, java.lang.String password)
          Initializes the invocation with the given database uri, domain, userId and password.
 
Method Summary
 void addRetryHandler(TInvocationRetryHandler retryHandler)
          Add a retry handler on this invocation.
 void checkServerAvailabilityAndVersion()
          Check if there is an available Tamino database server and what version does it have? If the server is available and responses adequate this method returns null.
 void close()
          Closes the invocation capability on Tamino.
protected abstract  void doClose()
          Plug in method for closing the invocation connection.
abstract  TInputStream doInvoke(TCommandStatement commandStatement, java.lang.String collection, java.lang.String doctype, java.lang.String docname, boolean useTransactionState)
          Invokes a Tamino specific command given by a TCommandStatement on an underlying Tamino database.
 TUri getDatabaseUri()
          Gets the database uri of this invocation.
protected  java.lang.String getDomain()
          Gets the domain that is currently set for the authentication.
 TCommandStatement getLastExecutedCommandStatement()
          Gets the last executed command statement!
 long getLastNonActivityTimeoutRelevantInvokeTimeMillis()
          Gets the time of the last session relevant invoke.
 java.util.Locale getLocale()
          Gets the locale.
protected  java.lang.String getPassword()
          Gets the password that is currently set for the authentication.
 TPooledConnectionReconnectHandler getPooledConnectionReconnectHandler()
          Gets the handler for automatic reconnects of pooled connections
protected  SecurityToken getSecurityToken()
          Gets the SecurityToken that is currently set for the authentication.
 TTransactionModeCoordinator getTransactionModeCoordinator()
          Gets the current transaction mode coordinator.
protected  java.lang.String getUserId()
          Gets the userId that is currently set for the authentication.
 TInputStream invoke(TCommandStatement commandStatement)
          Invokes a specific command given by a TCommandStatement on an underlying Tamino database.
 TInputStream invoke(TCommandStatement commandStatement, java.lang.String collection)
          Invokes a specific command given by a TCommandStatement on an underlying Tamino database.
 TInputStream invoke(TCommandStatement commandStatement, java.lang.String collection, java.lang.String doctype, java.lang.String docname)
          Invokes a specific command given by a TCommandStatement on an underlying Tamino database.
 boolean isClosed()
          Indicates if the invocation is closed.
 void setLocale(java.util.Locale locale)
          Sets the locale.
 void setPooledConnectionReconnectHandler(TPooledConnectionReconnectHandler handler)
          Sets the handler for automatic reconnects of pooled connections
 void setTransactionModeCoordinator(TTransactionModeCoordinator transactionModeCoordinator)
          Sets a TTransactionModeCoordinator on the instance.
 boolean supports(TCommand command)
          Indicates if the given command is supported for invocation in the current state.
protected  void updateStreamHeader(TInputStream inputStream, java.lang.String collection, java.lang.String doctype)
          Update the streams header, so that the information for collection, doctype and more is included.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.softwareag.tamino.db.api.invocation.TInvocation
getSocketTimeout, setSocketTimeout
 

Field Detail

PROP_RETRY

public static final java.lang.String PROP_RETRY
See Also:
Constant Field Values
Constructor Detail

TAbstractInvocation

public TAbstractInvocation(TUri databaseUri,
                           SecurityToken token)

TAbstractInvocation

public TAbstractInvocation(TUri databaseUri)
                    throws TInvocationException
Initializes the invocation with the given database uri. Authentication parameters are not considered.

Throws:
TInvocationException

TAbstractInvocation

public TAbstractInvocation(TUri databaseUri,
                           java.lang.String userId,
                           java.lang.String password)
                    throws TInvocationException
Initializes the invocation with the given database uri, userId and password.

Throws:
TInvocationException

TAbstractInvocation

public TAbstractInvocation(TUri databaseUri,
                           java.lang.String domain,
                           java.lang.String userId,
                           java.lang.String password)
                    throws TInvocationException
Initializes the invocation with the given database uri, domain, userId and password.

Throws:
TInvocationException
Method Detail

invoke

public TInputStream invoke(TCommandStatement commandStatement)
                    throws TInvocationException
Invokes a specific command given by a TCommandStatement on an underlying Tamino database. The result is handed back as a TInputStream instance. This version of invoke always uses a potential given transaction state. For a more explicit control whether a transaction state should be considered use the overloaded method with the additional useTransactionState method.

Specified by:
invoke in interface TInvocation
Parameters:
commandStatement - spcifies the concrete XML specific action that should be fullfilled.
Returns:
TInputStream representing Tamino's response as a core input stream.
Throws:
TInvocationException - due to any problems that can occur when performing the invocation on Tamino.

invoke

public TInputStream invoke(TCommandStatement commandStatement,
                           java.lang.String collection)
                    throws TInvocationException
Invokes a specific command given by a TCommandStatement on an underlying Tamino database. This version always uses a transaction state that might has been set. If this has to be omitted use the overloaded version of this method with the additional useTransactionState parameter. The result is handed back as a TInputStream instance.

Specified by:
invoke in interface TInvocation
Parameters:
commandStatement - spcifies the concrete action that should be fullfilled.
collection - is the collection of the Tamino DB where the object is contained in.
Returns:
TInputStream representing Tamino's response as a core input stream.
Throws:
TInvocationException - due to any problems that can occur when performing the invocation on Tamino.

invoke

public TInputStream invoke(TCommandStatement commandStatement,
                           java.lang.String collection,
                           java.lang.String doctype,
                           java.lang.String docname)
                    throws TInvocationException
Invokes a specific command given by a TCommandStatement on an underlying Tamino database. This version always uses a transaction state that might has been set. If this has to be omitted use the overloaded version of this method with the additional useTransactionState parameter. The result is handed back as a TInputStream instance.

Specified by:
invoke in interface TInvocation
Parameters:
commandStatement - spcifies the concrete action that should be fullfilled.
collection - is the collection of the Tamino DB where the object is contained in.
doctype - within a schema of a collection to which the statement is related.
docname - denotes the docname under which a specific document might be accessible.
Returns:
TInputStream representing Tamino's response as a core input stream.
Throws:
TInvocationException - due to any problems that can occur when performing the invocation on Tamino.

supports

public boolean supports(TCommand command)
Indicates if the given command is supported for invocation in the current state.

Specified by:
supports in interface TInvocation
Parameters:
command - is checked wheter it can be invoked the current state of the TInvocation instance.
Returns:
true if the given command can be invoked in the current state, false otherwise.

setTransactionModeCoordinator

public void setTransactionModeCoordinator(TTransactionModeCoordinator transactionModeCoordinator)
Sets a TTransactionModeCoordinator on the instance. TCommandInvocation probably needs this to update a transaction mode when transaction specific commands are invoked.

Specified by:
setTransactionModeCoordinator in interface TInvocation
Parameters:
TTransactionModeCoordinator - needed to update session state for session specific operations.

setLocale

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

Specified by:
setLocale in interface TInvocation

getLocale

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

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

close

public void close()
           throws TInvocationException
Closes the invocation capability on Tamino. As a result any internal resources needed for the invocation on Tamino are closed. This invocation instance can afterwards not be used any longer.

Specified by:
close in interface TInvocation
Throws:
TInvocationException - due to any problems that can occur when performing the invocation on Tamino.

isClosed

public boolean isClosed()
Indicates if the invocation is closed.

Specified by:
isClosed in interface TInvocation
Returns:
true if connection is closed, false otherwise.

getUserId

protected java.lang.String getUserId()
Gets the userId that is currently set for the authentication.

Returns:
the userId if given, empty string otherwise.

getPassword

protected java.lang.String getPassword()
Gets the password that is currently set for the authentication.

Returns:
the password if given, empty string otherwise.

getDomain

protected java.lang.String getDomain()
Gets the domain that is currently set for the authentication.

Returns:
the domain if given, empty string otherwise.

getSecurityToken

protected SecurityToken getSecurityToken()
Gets the SecurityToken that is currently set for the authentication.

Returns:
the SecurityToken if given, null otherwise.

checkServerAvailabilityAndVersion

public void checkServerAvailabilityAndVersion()
                                       throws TCommunicationException
Check if there is an available Tamino database server and what version does it have? If the server is available and responses adequate this method returns null. As a side effect this method stores the version number.

Throws:
TCommunicationException

getDatabaseUri

public TUri getDatabaseUri()
Gets the database uri of this invocation.

Specified by:
getDatabaseUri in interface TInvocation
Returns:
the database uri.

doInvoke

public abstract TInputStream doInvoke(TCommandStatement commandStatement,
                                      java.lang.String collection,
                                      java.lang.String doctype,
                                      java.lang.String docname,
                                      boolean useTransactionState)
                               throws TInvocationException
Invokes a Tamino specific command given by a TCommandStatement on an underlying Tamino database. This abstract method serves as a plug in method (GOF) for the template various methods invoke, invokeForXML and invokeForNonXML. It has to be implemented by any concrete TInvocation class.

Specified by:
doInvoke in interface TRetryInvocation
Parameters:
commandStatement - spcifies the concrete Tamino specific action that should be fullfilled.
collection - is the collection of the Tamino DB to which the command statement might be related to.
doctype - within a schema of the given collection to which the command statement might be related to.
docname - is the name of the document to which the command statement might be related to.
useTransactionState - specifies whether the transaction state shall be considered.
Returns:
TInputStream representing Tamino's response as a core input stream.
Throws:
TInvocationException - due to any problems that can occur when performing the invocation on Tamino.

doClose

protected abstract void doClose()
                         throws TInvocationException
Plug in method for closing the invocation connection. Is invoked by template method close. Has to be implemented by concrete TInvocation class.

Throws:
TInvocationException

getTransactionModeCoordinator

public TTransactionModeCoordinator getTransactionModeCoordinator()
Gets the current transaction mode coordinator.

Specified by:
getTransactionModeCoordinator in interface TRetryInvocation
Returns:
the current transaction mode coordinator if given, null otherwise.

getLastExecutedCommandStatement

public TCommandStatement getLastExecutedCommandStatement()
Gets the last executed command statement!

Specified by:
getLastExecutedCommandStatement in interface TInvocation
Returns:
last executed command statement.

addRetryHandler

public void addRetryHandler(TInvocationRetryHandler retryHandler)
Add a retry handler on this invocation.

Parameters:
commandStatement - specifies the concrete Tamino specific action that should be fullfilled. Session information is written to the command statement.

getLastNonActivityTimeoutRelevantInvokeTimeMillis

public long getLastNonActivityTimeoutRelevantInvokeTimeMillis()
Gets the time of the last session relevant invoke.

Specified by:
getLastNonActivityTimeoutRelevantInvokeTimeMillis in interface TInvocation
Returns:
the time in milli seconds. A value of -1 indicates that a command has not yet been executed.

setPooledConnectionReconnectHandler

public void setPooledConnectionReconnectHandler(TPooledConnectionReconnectHandler handler)
Sets the handler for automatic reconnects of pooled connections

Specified by:
setPooledConnectionReconnectHandler in interface TInvocation

getPooledConnectionReconnectHandler

public TPooledConnectionReconnectHandler getPooledConnectionReconnectHandler()
Gets the handler for automatic reconnects of pooled connections

Specified by:
getPooledConnectionReconnectHandler in interface TInvocation
Returns:
the TPooledConnectionReconnectHandler for automatic reconnects of pooled connections.

updateStreamHeader

protected void updateStreamHeader(TInputStream inputStream,
                                  java.lang.String collection,
                                  java.lang.String doctype)
Update the streams header, so that the information for collection, doctype and more is included. If the information is not available from Tamino, we try to insert them. This helper may be used by concrete invocation components. Maybe we can later make it a feature of the abstract layer, but now ..



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