jgroup.test.jini.txn
Class PassiveReplicatedBankServer2

java.lang.Object
  extended by jgroup.test.jini.txn.PassiveReplicatedBankServer2
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, jgroup.core.ExternalGMIListener, jgroup.core.InternalGMIListener, jgroup.core.MembershipListener, InternalPassiveTransactionParticipant, Bank, net.jini.core.transaction.server.TransactionConstants, net.jini.core.transaction.server.TransactionParticipant

public class PassiveReplicatedBankServer2
extends java.lang.Object
implements Bank, net.jini.core.transaction.server.TransactionParticipant, jgroup.core.MembershipListener, InternalPassiveTransactionParticipant

Bank server with replication support used as participant in a transaction.

Author:
Rohnny Moland
See Also:
Serialized Form

Nested Class Summary
 class PassiveReplicatedBankServer2.CreditDebit
          Class that holds a temporary credit/debit operation, before doing a commit/abort operation.
 
Nested classes/interfaces inherited from interface jgroup.core.MembershipListener
jgroup.core.MembershipListener.AllowDuplicateViews
 
Field Summary
 
Fields inherited from interface net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
 
Constructor Summary
PassiveReplicatedBankServer2(java.lang.String[] configArgs, com.sun.jini.start.LifeCycle lifeCycle)
          Constructor compatible with the jini service starter.
 
Method Summary
 void abort(net.jini.core.transaction.server.TransactionManager mgr, long id)
           
 void commit(net.jini.core.transaction.server.TransactionManager mgr, long id)
           
 void deposit(long accountNumber, int amount, long transactionID)
          Do a deposit operation on given account.
 java.lang.Integer getBalance(long accNumber)
          Get balance of an account.
 java.lang.String getName()
          Get the name of a bank service.
 void hasLeft()
           
 int prepare(net.jini.core.transaction.server.TransactionManager mgr, long id)
           
 int prepareAndCommit(net.jini.core.transaction.server.TransactionManager mgr, long id)
           
 void prepareChange()
           
 void txnCompleted(long TxnId, int outcome)
           
 void txnDeposit(long account, int amount, long transactionID)
          Transfer deposit state to other members int he group
 void txnPrepared(long txnId, java.lang.Object stateObj)
          Transfers the state of the txn to other members of the group.
 void txnWithdraw(long account, int amount, long transactionID)
          Transfer withdraw state to other members in the group.
 void viewChange(jgroup.core.View view)
           
 void withdraw(long accountNumber, int amount, long transactionID)
          Do a withdraw operation on given account.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PassiveReplicatedBankServer2

public PassiveReplicatedBankServer2(java.lang.String[] configArgs,
                                    com.sun.jini.start.LifeCycle lifeCycle)
                             throws java.lang.Exception
Constructor compatible with the jini service starter.

Parameters:
configArgs - String array whose elements are the arguments to use when creating the server.
lifeCycle - instance of LifeCycle that, if non-null, will cause this object's unregister method to be invoked during shutdown to notify the service starter framework that the reference to this service's implementation can be 'released' for garbage collection. A value of null for this argument is allowed.
Throws:
java.lang.Exception - If there was a problem initializing the service.
Method Detail

getBalance

@Anycast
public java.lang.Integer getBalance(long accNumber)
                             throws java.rmi.RemoteException
Description copied from interface: Bank
Get balance of an account.

Specified by:
getBalance in interface Bank
Parameters:
accNumber - Account number
Returns:
the balance of the account
Throws:
java.rmi.RemoteException

withdraw

@Anycast
public void withdraw(long accountNumber,
                             int amount,
                             long transactionID)
              throws java.rmi.RemoteException
Description copied from interface: Bank
Do a withdraw operation on given account.

Specified by:
withdraw in interface Bank
Parameters:
accountNumber - The account number to use
amount - The amount to withdraw
transactionID - The transaction id to use
Throws:
java.rmi.RemoteException

deposit

@Anycast
public void deposit(long accountNumber,
                            int amount,
                            long transactionID)
             throws java.rmi.RemoteException
Description copied from interface: Bank
Do a deposit operation on given account.

Specified by:
deposit in interface Bank
Parameters:
accountNumber - The account number to use
amount - The amount to deposit
Throws:
java.rmi.RemoteException

getName

@Anycast
public java.lang.String getName()
                         throws java.rmi.RemoteException
Description copied from interface: Bank
Get the name of a bank service.

Specified by:
getName in interface Bank
Returns:
Name of bank
Throws:
java.rmi.RemoteException

prepare

@Anycast
public int prepare(net.jini.core.transaction.server.TransactionManager mgr,
                           long id)
            throws net.jini.core.transaction.UnknownTransactionException,
                   java.rmi.RemoteException
Specified by:
prepare in interface net.jini.core.transaction.server.TransactionParticipant
Throws:
net.jini.core.transaction.UnknownTransactionException
java.rmi.RemoteException

commit

@Anycast
public void commit(net.jini.core.transaction.server.TransactionManager mgr,
                           long id)
            throws net.jini.core.transaction.UnknownTransactionException,
                   java.rmi.RemoteException
Specified by:
commit in interface net.jini.core.transaction.server.TransactionParticipant
Throws:
net.jini.core.transaction.UnknownTransactionException
java.rmi.RemoteException

abort

@Leadercast
public void abort(net.jini.core.transaction.server.TransactionManager mgr,
                             long id)
           throws net.jini.core.transaction.UnknownTransactionException,
                  java.rmi.RemoteException
Specified by:
abort in interface net.jini.core.transaction.server.TransactionParticipant
Throws:
net.jini.core.transaction.UnknownTransactionException
java.rmi.RemoteException

prepareAndCommit

@Leadercast
public int prepareAndCommit(net.jini.core.transaction.server.TransactionManager mgr,
                                       long id)
                     throws net.jini.core.transaction.UnknownTransactionException,
                            java.rmi.RemoteException
Specified by:
prepareAndCommit in interface net.jini.core.transaction.server.TransactionParticipant
Throws:
net.jini.core.transaction.UnknownTransactionException
java.rmi.RemoteException

viewChange

public void viewChange(jgroup.core.View view)
Specified by:
viewChange in interface jgroup.core.MembershipListener

prepareChange

public void prepareChange()
Specified by:
prepareChange in interface jgroup.core.MembershipListener

hasLeft

public void hasLeft()
Specified by:
hasLeft in interface jgroup.core.MembershipListener

txnPrepared

public void txnPrepared(long txnId,
                        java.lang.Object stateObj)
                 throws java.rmi.RemoteException
Description copied from interface: InternalPassiveTransactionParticipant
Transfers the state of the txn to other members of the group.

Specified by:
txnPrepared in interface InternalPassiveTransactionParticipant
Throws:
java.rmi.RemoteException

txnCompleted

public void txnCompleted(long TxnId,
                         int outcome)
                  throws java.rmi.RemoteException
Specified by:
txnCompleted in interface InternalPassiveTransactionParticipant
Throws:
java.rmi.RemoteException

txnWithdraw

public void txnWithdraw(long account,
                        int amount,
                        long transactionID)
                 throws java.rmi.RemoteException
Description copied from interface: InternalPassiveTransactionParticipant
Transfer withdraw state to other members in the group.

Specified by:
txnWithdraw in interface InternalPassiveTransactionParticipant
Throws:
java.rmi.RemoteException

txnDeposit

public void txnDeposit(long account,
                       int amount,
                       long transactionID)
                throws java.rmi.RemoteException
Description copied from interface: InternalPassiveTransactionParticipant
Transfer deposit state to other members int he group

Specified by:
txnDeposit in interface InternalPassiveTransactionParticipant
Throws:
java.rmi.RemoteException


Copyright © 1998-2006 The Jgroup/ARM development team. All Rights Reserved.