BEA Systems, Inc.

BEA WebLogic Server 9.1 API Reference


weblogic.transaction
Interface Transaction

All Superinterfaces:
Transaction

public interface Transaction
extends 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
Copyright © 2005 BEA Systems, Inc. All Rights Reserved.

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.
 
Methods inherited from interface javax.transaction.Transaction
commit, delistResource, enlistResource, getStatus, registerSynchronization, rollback, setRollbackOnly
 

Field Detail

TRANSACTION_NAME_PROPERTY_KEY

public 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:
setName(java.lang.String), setProperty(java.lang.String, java.io.Serializable), Constant Field Values
Method Detail

addProperties

public 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

enlistResource

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

Throws:
RollbackException
IllegalStateException
SystemException

getHeuristicErrorMessage

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

Returns:

getMillisSinceBegin

public 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

getName

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

Returns:
Transaction name

getProperties

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

Returns:
Map containing all key/value pairs

getProperty

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

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

getRollbackReason

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

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

getStatusAsString

public 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

getTimeToLiveMillis

public 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

getXid

public Xid getXid()
See Also:
getXID()

getXID

public 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

isTimedOut

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


setName

public 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.


setProperty

public 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

setRollbackOnly

public 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:
setRollbackOnly(Throwable)

setRollbackOnly

public 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.

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs91
Copyright 2005 BEA Systems Inc.