Oracle

weblogic.transaction
Interface Transaction


public interface Transaction

This interface provides extensions to the javax.transaction.Transaction object for application or system use.

Transaction Properties

Transaction properties are key/value pairs. Once set, they remain associated with a transaction during its entire lifetime. They are propagated between machines as the transaction travels through the system. They also are saved in the transaction log, and restored during crash recovery processing.

If a transaction property is set more than once the latest value is retained. However, in some threaded and/or multi-server situations, this behavior may not be predictable.

Key names prefixed with "weblogic.transaction" are reserved for use by BEA Systems.

Transaction Status

Recovery and audit-trail procedures require more information about a transaction than the JTA Transaction interface furnishes; information such as the transaction identifier, the specific reason for a rollback, and any heuristic error messages. In addition, the time taken by the transaction and the amount of time left can be used as limits on certain operations.

See Also:
Transaction

Field Summary
static String TRANSACTION_NAME_PROPERTY_KEY
          The transaction property key that is used internally to store the name associated with a transaction.
 
Method Summary
 void addProperties(Map props)
          Adds a set of properties to a transaction by calling setProperty for all elements of props.
 boolean enlistResource(NonXAResource nxar)
          Enlist a Non-XA Resource in the transaction.
 String getHeuristicErrorMessage()
          Returns the heuristic error message (if any) associated with the transaction.
 long getMillisSinceBegin()
          Returns the amount of time, in milliseconds, that the transaction has been in existence.
 String getName()
          Retrieves the name previously associated with a transaction.
 Map getProperties()
          Gets all properties currently associated with a transaction.
 Serializable getProperty(String key)
          Gets the value of a specific property.
 Throwable getRollbackReason()
          Retrieves the rollback reason (if any) associated with the transaction.
 String getStatusAsString()
          Returns the status of the transaction as a string.
 long getTimeToLiveMillis()
          Returns the amount of time, in milliseconds, that the transaction has left to go.
 Xid getXid()
           
 Xid getXID()
          Gets the transaction identifier.
 boolean isTimedOut()
          Returns true if the transaction has timed out, false otherwise.
 void setName(String n)
          Associates a name with a transaction.
 void setProperty(String key, Serializable value)
          Sets a property value to be associated with a transaction.
 void setRollbackOnly(String msg, Throwable reason)
          Wraps the rollback string message and the exception into a weblogic.utils.NestedException instance and calls setRollbackOnly with this new exception.
 void setRollbackOnly(Throwable reason)
          Provides a reason for the rollback.
 

Field Detail

TRANSACTION_NAME_PROPERTY_KEY

static final String TRANSACTION_NAME_PROPERTY_KEY
The transaction property key that is used internally to store the name associated with a transaction. A transaction name (a String) may be assigned to a transaction using either the setName or setProperty methods.

See Also:
Transaction.setName(java.lang.String), Transaction.setProperty(java.lang.String, java.io.Serializable), Constant Field Values
Method Detail

setName

void setName(String n)
Associates a name with a transaction. The name is typically used to describe a type of transaction and is not meant for describing each individual transaction. All internally generated error reports incorporate the name if present. Once set, the name cannot be changed.


getName

String getName()
Retrieves the name previously associated with a transaction.

Returns:
Transaction name

setProperty

void setProperty(String key,
                 Serializable value)
Sets a property value to be associated with a transaction.

Parameters:
key - A string key
value - Property value, null means delete

addProperties

void addProperties(Map props)
Adds a set of properties to a transaction by calling setProperty for all elements of props.

Parameters:
props - Set of key/value pairs to add

getProperty

Serializable getProperty(String key)
Gets the value of a specific property.

Parameters:
key - Property name
Returns:
Value of property or null if unset

getProperties

Map getProperties()
Gets all properties currently associated with a transaction.

Returns:
Map containing all key/value pairs

setRollbackOnly

void setRollbackOnly(Throwable reason)
Provides a reason for the rollback. All rollbacks triggered inside the transaction service set the reason (timeouts, XA errors, unchecked exceptions in beforeCompletion, inability to contact the coordinator, etc.) Once set, the reason cannot be overwritten.

Parameters:
reason - the reason behind the rollback.

setRollbackOnly

void setRollbackOnly(String msg,
                     Throwable reason)
Wraps the rollback string message and the exception into a weblogic.utils.NestedException instance and calls setRollbackOnly with this new exception.

Parameters:
reason - the reason behind the rollback.
See Also:
Transaction.setRollbackOnly(Throwable)

getRollbackReason

Throwable getRollbackReason()
Retrieves the rollback reason (if any) associated with the transaction.

Returns:
the rollback reason (if any) associated with the transaction.
See Also:
Transaction.setRollbackOnly(Throwable reason)

getHeuristicErrorMessage

String getHeuristicErrorMessage()
Returns the heuristic error message (if any) associated with the transaction.

Returns:

getXID

Xid getXID()
Gets the transaction identifier. It is important to know that the transaction adds some extra information to the Xid's gtrid and branch qualifier (bqual) when it calls a resource, so calls to tx.getXID().getGlobalTransactionId() before calling a resource (for the first time) and then subsequently differ in what is returned. There are two guarantees provided: 1. xid.equals() is not affected. An xid obtained from tx.getXID() and another obtained at a subsequent time are considered equal (for the same tx, of course). As mentioned earlier, this guarantee is not extended to the constituents of the xid, namely the gtrid and the bqual. 2. An XA resource will always be supplied the same xid (with the same gtrid and bqual) for a given transaction, in all its XAResource methods.

Returns:
Transaction identifier

getXid

Xid getXid()
See Also:
Transaction.getXID()

getStatusAsString

String getStatusAsString()
Returns the status of the transaction as a string. The string contains the major state as specified in javax.transaction.Status, further embellished with a minor state (such as "logging", "pre-preparing", etc.)

Returns:
Transaction status in string form

getMillisSinceBegin

long getMillisSinceBegin()
Returns the amount of time, in milliseconds, that the transaction has been in existence. This value may not include network propagation time because there is no expectation of synchronized clocks.

Returns:
Existence time of transaction, in milliseconds

getTimeToLiveMillis

long getTimeToLiveMillis()
Returns the amount of time, in milliseconds, that the transaction has left to go. This time is meaningful only when the transaction is active, not when it is retrying commit or rollback.

Returns:
Time remaining for transaction, in milliseconds

isTimedOut

boolean isTimedOut()
Returns true if the transaction has timed out, false otherwise.


enlistResource

boolean enlistResource(NonXAResource nxar)
                       throws RollbackException,
                              IllegalStateException,
                              SystemException
Enlist a Non-XA Resource in the transaction.

Throws:
RollbackException
IllegalStateException
SystemException

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs103
Copyright 1996,2008, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.