com.sun.jini.outrigger
Class ParticipantProxy

java.lang.Object
  extended by com.sun.jini.outrigger.ParticipantProxy
All Implemented Interfaces:
Serializable, Remote, TransactionConstants, TransactionParticipant, ReferentUuid
Direct Known Subclasses:
ConstrainableParticipantProxy

 class ParticipantProxy
extends Object
implements TransactionParticipant, ReferentUuid, Serializable

Object Outrigger hands to transaction managers on join. Passes through TransactionParticipant calls to the inner proxy and provides implementations of equals and hashCode that do reference equality.

Author:
Sun Microsystems, Inc.

Field Summary
(package private) static long serialVersionUID
           
(package private)  TransactionParticipant space
          The remote server this proxy works with.
(package private)  Uuid spaceUuid
          The Uuid that identifies the space this proxy is for.
 
Fields inherited from interface net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
 
Constructor Summary
ParticipantProxy(TransactionParticipant space, Uuid spaceUuid)
          Create a new ParticipantProxy for the given space.
 
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.
 boolean equals(Object other)
           
 Uuid getReferentUuid()
          Return the Uuid that has been assigned to the resource this proxy represents.
 int hashCode()
           
 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.
private  void readObject(ObjectInputStream in)
          Read this object back and validate state.
private  void readObjectNoData()
          We should always have data in the stream, if this method gets called there is something wrong.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

space

final TransactionParticipant space
The remote server this proxy works with. Package protected so it can be read by subclasses and proxy verifier.


spaceUuid

final Uuid spaceUuid
The Uuid that identifies the space this proxy is for. Package protected so it can be read by subclasses and proxy verifier.

Constructor Detail

ParticipantProxy

ParticipantProxy(TransactionParticipant space,
                 Uuid spaceUuid)
Create a new ParticipantProxy for the given space.

Parameters:
space - The an inner proxy that implements TransactionParticipant for the space.
spaceUuid - The universally unique ID for the space
Throws:
NullPointerException - if space or spaceUuid is null.
Method Detail

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Read this object back and validate state.

Throws:
IOException
ClassNotFoundException

readObjectNoData

private void readObjectNoData()
                       throws InvalidObjectException
We should always have data in the stream, if this method gets called there is something wrong.

Throws:
InvalidObjectException

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getReferentUuid

public Uuid getReferentUuid()
Description copied from interface: ReferentUuid
Return the Uuid that has been assigned to the resource this proxy represents.

Specified by:
getReferentUuid in interface ReferentUuid
Returns:
the Uuid associated with the resource this proxy represents. Will not return null.

prepare

public int prepare(TransactionManager mgr,
                   long id)
            throws UnknownTransactionException,
                   RemoteException
Description copied from interface: TransactionParticipant
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.

Specified by:
prepare in interface TransactionParticipant
Parameters:
mgr - the manager of the transaction
id - the transaction ID
Returns:
an int representing this participant's state
Throws:
UnknownTransactionException - if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.
RemoteException - if there is a communication error

commit

public void commit(TransactionManager mgr,
                   long id)
            throws UnknownTransactionException,
                   RemoteException
Description copied from interface: TransactionParticipant
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.

Specified by:
commit in interface TransactionParticipant
Parameters:
mgr - the manager of the transaction
id - the transaction ID
Throws:
UnknownTransactionException - if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.
RemoteException - if there is a communication error

abort

public void abort(TransactionManager mgr,
                  long id)
           throws UnknownTransactionException,
                  RemoteException
Description copied from interface: TransactionParticipant
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.

Specified by:
abort in interface TransactionParticipant
Parameters:
mgr - the manager of the transaction
id - the transaction ID
Throws:
UnknownTransactionException - if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.
RemoteException - if there is a communication error

prepareAndCommit

public int prepareAndCommit(TransactionManager mgr,
                            long id)
                     throws UnknownTransactionException,
                            RemoteException
Description copied from interface: TransactionParticipant
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;
        }
 

Specified by:
prepareAndCommit in interface TransactionParticipant
Parameters:
mgr - the manager of the transaction
id - the transaction ID
Returns:
an int representing its state
Throws:
UnknownTransactionException - if the transaction is unknown to the transaction manager, either because the transaction ID is incorrect or because the transaction is complete and its state has been discarded by the manager.
RemoteException - if there is a communication error
See Also:
TransactionParticipant.prepare(net.jini.core.transaction.server.TransactionManager, long), TransactionParticipant.commit(net.jini.core.transaction.server.TransactionManager, long)


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.