jgroup.test.jini.txn
Class ReplicatedBankServer

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

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

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

Author:
Rohnny Moland

Nested Class Summary
 class ReplicatedBankServer.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
ReplicatedBankServer(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 viewChange(jgroup.core.View view)
           
 void withdraw(long accountNumber, int amount, long transactionID)
          This method should be atomic or using leadercast.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicatedBankServer

public ReplicatedBankServer(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

@Atomic
public void withdraw(long accountNumber,
                            int amount,
                            long transactionID)
              throws java.rmi.RemoteException
This method should be atomic or using leadercast.

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

@Atomic
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

@Atomic
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

@Atomic
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

@Atomic
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

@Atomic
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


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