com.atomikos.icatch.jaxws
Class GenericImportingTransactionHandler

java.lang.Object
  extended by com.atomikos.icatch.jaxws.GenericImportingTransactionHandler
All Implemented Interfaces:
javax.xml.ws.handler.Handler<javax.xml.ws.handler.soap.SOAPMessageContext>, javax.xml.ws.handler.soap.SOAPHandler<javax.xml.ws.handler.soap.SOAPMessageContext>
Direct Known Subclasses:
ImportingTransactionHandler, ImportingTransactionHandler

public abstract class GenericImportingTransactionHandler
extends Object
implements javax.xml.ws.handler.soap.SOAPHandler<javax.xml.ws.handler.soap.SOAPMessageContext>

A generic superclass for common handler features. Subclasses inherit the following config parameters:

importPreference This parameter indicates the desired behaviour of the handler. The possible values are similar to the standard J2EE(TM) transaction attributes (i.e.: Mandatory, Required, RequiresNew, Supports, NotSupported, Never). For instance, if this parameter is set to Mandatory then every incoming SOAP message must have transaction headers, or the handler will reject the message by generating a SOAPFaultException. The default value is Required.

NOTE: the values of this parameter are case sensitive!

It is important to realize that the preferences that ignore the transaction headers of the incoming messages (like RequiresNew) may be impractical if the client message has a transaction context header with mustUnderstand set to true. Nevertheless, in the spirit of web service autonomy we do provide these preferences: the service provider (the party that installs the importing handler) is the one that decides what kind of transaction scope to allow.

newTransactionTimeout The timeout (in milliseconds) of new transactions that are started by this handler. Defaults to 60000. For imported transactions, the timeout is indicated in the headers of the message and limited by the com.atomikos.icatch.max_timeout init parameter set in the transaction service core.
commitOnHeuristicTimeout This parameter should be set to true or false. If true, then heuristic timeout will lead to positive termination (confirm or commit). If false, then heuristic timeout will lead to negative termination (rollback or cancel). Default is false.
checkOrphans This parameter should be set to true or false. If true, then extra checks will be performed by the transaction service in order to avoid anomalies that can be caused by lost response messages. This is a unique feature only offered by Atomikos, and can be set to make non-reliable messaging platforms safer from the transactional point of view. If enabled, your application can safely retry failed remote calls within the same transaction. If you don't retry any calls then you don't need to enable this feature. Default is false.


Field Summary
static String ATOMIKOS_ACTOR
          Constant indicating the ATOMIKOS actor URI.
protected  javax.xml.soap.SOAPFactory factory
           
protected  boolean heuristic_commit
           
static String IMPORT_PREFERENCE_MANDATORY
          Value of the import preference parameter to indicate that a transaction must be present in the incoming message.
static String IMPORT_PREFERENCE_NEVER
          Value of the import preference parameter to indicate that a transaction is not allowed.
static String IMPORT_PREFERENCE_NOT_SUPPORTED
          Value of the import preference parameter to indicate that a transaction is not supported (and ignored).
static String IMPORT_PREFERENCE_REQUIRED
          Value of the import preference parameter to indicate that a transaction is required.
static String IMPORT_PREFERENCE_REQUIRES_NEW
          Value of the import preference parameter to indicate that a new transaction should be created, even if a context is included in the incoming message.
static String IMPORT_PREFERENCE_SUPPORTS
          Value of the import preference parameter to indicate that a transaction is supported but not required.
protected  long new_transaction_timeout
           
protected  boolean orphan_check
           
protected  int preference
           
 
Constructor Summary
GenericImportingTransactionHandler()
           
 
Method Summary
 void close(javax.xml.ws.handler.MessageContext ctx)
           
static int convertPreference(String preference)
          Converts a string parameter value to a integer preference as needed by the API.
protected  javax.xml.ws.soap.SOAPFaultException createSOAPFaultException(String reason, QName code)
           
protected abstract  boolean getActiveRecovery()
          Checks if active transactions are recoverable.
 boolean getCheckOrphans()
           
 boolean getCommitOnHeuristicTimeout()
           
protected  CompositeTransaction getCompositeTransaction()
           
 int getImportPreference()
           
 long getNewTransactionTimeout()
           
protected abstract  SOAPImportingTransactionManager getSOAPImportingTransactionManager()
           
 boolean handleFault(javax.xml.ws.handler.soap.SOAPMessageContext ctx)
           
 boolean handleMessage(javax.xml.ws.handler.soap.SOAPMessageContext ctx)
          Extracts/inserts the protocol-specific transaction context (if any) and (re)creates a transaction in the local VM.
protected  boolean isRollbackOnly(CompositeTransaction ct)
           
 void setCheckOrphans(boolean value)
          Sets whether orphans should be checked or not.
 void setCommitOnHeuristicTimeout(boolean value)
          Sets if heuristic timeout means commit or rollback.
 void setImportPreference(String importPreference)
          Sets the desired import preference.
 void setNewTransactionTimeout(long milliseconds)
          Sets the timeout (in millis) of newly started transactions.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.xml.ws.handler.soap.SOAPHandler
getHeaders
 

Field Detail

ATOMIKOS_ACTOR

public static final String ATOMIKOS_ACTOR
Constant indicating the ATOMIKOS actor URI.

See Also:
Constant Field Values

IMPORT_PREFERENCE_REQUIRES_NEW

public static final String IMPORT_PREFERENCE_REQUIRES_NEW
Value of the import preference parameter to indicate that a new transaction should be created, even if a context is included in the incoming message.

See Also:
Constant Field Values

IMPORT_PREFERENCE_REQUIRED

public static final String IMPORT_PREFERENCE_REQUIRED
Value of the import preference parameter to indicate that a transaction is required. If none is present in the message, it will be created.

See Also:
Constant Field Values

IMPORT_PREFERENCE_MANDATORY

public static final String IMPORT_PREFERENCE_MANDATORY
Value of the import preference parameter to indicate that a transaction must be present in the incoming message.

See Also:
Constant Field Values

IMPORT_PREFERENCE_NEVER

public static final String IMPORT_PREFERENCE_NEVER
Value of the import preference parameter to indicate that a transaction is not allowed.

See Also:
Constant Field Values

IMPORT_PREFERENCE_SUPPORTS

public static final String IMPORT_PREFERENCE_SUPPORTS
Value of the import preference parameter to indicate that a transaction is supported but not required.

See Also:
Constant Field Values

IMPORT_PREFERENCE_NOT_SUPPORTED

public static final String IMPORT_PREFERENCE_NOT_SUPPORTED
Value of the import preference parameter to indicate that a transaction is not supported (and ignored).

See Also:
Constant Field Values

heuristic_commit

protected boolean heuristic_commit

orphan_check

protected boolean orphan_check

preference

protected int preference

new_transaction_timeout

protected long new_transaction_timeout

factory

protected javax.xml.soap.SOAPFactory factory
Constructor Detail

GenericImportingTransactionHandler

public GenericImportingTransactionHandler()
Method Detail

convertPreference

public static int convertPreference(String preference)
Converts a string parameter value to a integer preference as needed by the API.

Parameters:
preference -
Returns:

createSOAPFaultException

protected javax.xml.ws.soap.SOAPFaultException createSOAPFaultException(String reason,
                                                                        QName code)

getCompositeTransaction

protected CompositeTransaction getCompositeTransaction()

isRollbackOnly

protected boolean isRollbackOnly(CompositeTransaction ct)

setCommitOnHeuristicTimeout

public void setCommitOnHeuristicTimeout(boolean value)
Sets if heuristic timeout means commit or rollback. Default is false.

Parameters:
value -

setCheckOrphans

public void setCheckOrphans(boolean value)
Sets whether orphans should be checked or not. Orphan transactions are pending (lost) invocations; i.e. invocations whose response was lost on its way to the client side. If not set, defaults to true.

Parameters:
value -

setNewTransactionTimeout

public void setNewTransactionTimeout(long milliseconds)
Sets the timeout (in millis) of newly started transactions. Defaults to 60000.

Parameters:
milliseconds -

setImportPreference

public void setImportPreference(String importPreference)
Sets the desired import preference.

Parameters:
importPreference -

getCommitOnHeuristicTimeout

public boolean getCommitOnHeuristicTimeout()
Returns:
The preference for heuristic decisions.

getNewTransactionTimeout

public long getNewTransactionTimeout()
Returns:
The timeout for new transactions. In millis.

getCheckOrphans

public boolean getCheckOrphans()
Returns:
Whether or not orphan checking is enabled.

getImportPreference

public int getImportPreference()
Returns:
The preference for importing transactions.
See Also:
SOAPImportingTransactionManager

getActiveRecovery

protected abstract boolean getActiveRecovery()
Checks if active transactions are recoverable.

Returns:

getSOAPImportingTransactionManager

protected abstract SOAPImportingTransactionManager getSOAPImportingTransactionManager()
Returns:
The protocol-specific importing transaction manager.

handleMessage

public boolean handleMessage(javax.xml.ws.handler.soap.SOAPMessageContext ctx)
                      throws javax.xml.ws.ProtocolException
Extracts/inserts the protocol-specific transaction context (if any) and (re)creates a transaction in the local VM. The exact behaviour depends on the import preference parameter: either the created transaction will be dependent on the remote transaction (represented in the message headers) or a new, independent local transaction will be created.

Specified by:
handleMessage in interface javax.xml.ws.handler.Handler<javax.xml.ws.handler.soap.SOAPMessageContext>
Throws:
javax.xml.ws.ProtocolException
javax.xml.ws.soap.SOAPFaultException

handleFault

public boolean handleFault(javax.xml.ws.handler.soap.SOAPMessageContext ctx)
                    throws javax.xml.ws.ProtocolException
Specified by:
handleFault in interface javax.xml.ws.handler.Handler<javax.xml.ws.handler.soap.SOAPMessageContext>
Throws:
javax.xml.ws.ProtocolException

close

public void close(javax.xml.ws.handler.MessageContext ctx)
Specified by:
close in interface javax.xml.ws.handler.Handler<javax.xml.ws.handler.soap.SOAPMessageContext>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.