net.jini.core.transaction.server
Interface TransactionParticipant


public abstract interface TransactionParticipant
extends java.rmi.Remote, TransactionConstants

The interface used for participants of the two-phase commit protocol. The methods on this interface are called by the transaction manager. Any class that wants to have operations wrapped in a transaction needs to support this interface. In conjunction with the TransactionManager interface, this interface allows a two-phase commit protocol to be used between objects in a distributed system.

See Also:
TransactionManager, NestableTransactionManager, ServerTransaction

Fields inherited from class net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
 
Method Summary
 void abort(TransactionManager mgr, long id)
          Requests that the participant roll back any changes for the specified transaction and unlock any resources locked by the transaction.
 void commit(TransactionManager mgr, long id)
          Requests that the participant make all of its PREPARED changes for the specified transaction visible outside of the transaction and unlock any resources locked by the transaction.
 int prepare(TransactionManager mgr, long id)
          Requests that the participant prepare itself to commit the transaction, and to vote on the outcome of the transaction.
 int prepareAndCommit(TransactionManager mgr, long id)
          A combination of prepare and commit, which can be used by the manager when there is just one participant left to prepare and all other participants (if any) have responded with NOTCHANGED.
 

Method Detail

prepare

public int prepare(TransactionManager mgr,
                   long id)
            throws UnknownTransactionException,
                   java.rmi.RemoteException
Requests that the participant prepare itself to commit the transaction, and to vote on the outcome of the transaction. The participant responds with either PREPARED, indicating that it is prepared; ABORT, indicating that it will abort, or NOTCHANGED, indicating that it did not have any state changed by the transaction (i.e., it was read-only). If the response is PREPARED, the participant must wait until it receives a commit or abort call from the transaction manager; it may query the transaction manager if needed as to the state of the transaction. If the response is ABORT, the participant should roll its state back to undo any changes that occurred due to operations performed under the transaction; it can then discard any information about the transaction. If the response is NOTCHANGED, the participant can immediately discard any knowledge of the transaction.
Parameters:
mgr - the manager of the transaction
id - the transaction id

commit

public void commit(TransactionManager mgr,
                   long id)
            throws UnknownTransactionException,
                   java.rmi.RemoteException
Requests that the participant make all of its PREPARED changes for the specified transaction visible outside of the transaction and unlock any resources locked by the transaction. All state associated with the transaction can then be discarded by the participant.
Parameters:
mgr - the manager of the transaction
id - the transaction id

abort

public void abort(TransactionManager mgr,
                  long id)
           throws UnknownTransactionException,
                  java.rmi.RemoteException
Requests that the participant roll back any changes for the specified transaction and unlock any resources locked by the transaction. All state associated with the transaction can then be discarded by the participant.
Parameters:
mgr - the manager of the transaction
id - the transaction id

prepareAndCommit

public int prepareAndCommit(TransactionManager mgr,
                            long id)
                     throws UnknownTransactionException,
                            java.rmi.RemoteException
A combination of prepare and commit, which can be used by the manager when there is just one participant left to prepare and all other participants (if any) have responded with NOTCHANGED. The participant's implementation of this method must be equivalent to:
	public int prepareAndCommit(TransactionManager mgr, long id)
	    throws UnknownTransactionException, RemoteException
	{
	    int result = prepare(mgr, id);
	    if (result == PREPARED) {
		commit(mgr, id);
		result = COMMITTED;
	    }
	    return result;
	}
 
Parameters:
mgr - the manager of the transaction
id - the transaction id
See Also:
prepare(net.jini.core.transaction.server.TransactionManager, long), commit(net.jini.core.transaction.server.TransactionManager, long)


Copyright © 1999 Sun Microsystems, Inc. All rights reserved