jgroup.test.jini.txn
Class NonReplicatedBankServer2

java.lang.Object
  extended by jgroup.test.jini.txn.NonReplicatedBankServer2
All Implemented Interfaces:
java.rmi.Remote, java.util.EventListener, jgroup.core.ExternalGMIListener, Bank, net.jini.core.transaction.server.TransactionConstants, net.jini.core.transaction.server.TransactionParticipant, net.jini.lookup.ServiceIDListener

public class NonReplicatedBankServer2
extends java.lang.Object
implements Bank, net.jini.core.transaction.server.TransactionParticipant, net.jini.lookup.ServiceIDListener

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

Author:
Rohnny Moland

Nested Class Summary
 class NonReplicatedBankServer2.CreditDebit
          Class that holds a temporary credit/debit operation, before doing a commit/abort operation.
 
Field Summary
 
Fields inherited from interface net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
 
Constructor Summary
NonReplicatedBankServer2(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.
 int prepare(net.jini.core.transaction.server.TransactionManager mgr, long id)
           
 int prepareAndCommit(net.jini.core.transaction.server.TransactionManager mgr, long id)
           
 void serviceIDNotify(net.jini.core.lookup.ServiceID serviceID)
           
 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

NonReplicatedBankServer2

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

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

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

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

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

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

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

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

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

serviceIDNotify

public void serviceIDNotify(net.jini.core.lookup.ServiceID serviceID)
Specified by:
serviceIDNotify in interface net.jini.lookup.ServiceIDListener


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