WebLogic Server 6.0 Code Examples, BEA Systems, Inc.

examples.cluster.ejb.teller
Class TellerBean

java.lang.Object
  |
  +--examples.cluster.ejb.teller.TellerBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, java.io.Serializable, javax.ejb.SessionBean

public class TellerBean
extends java.lang.Object
implements javax.ejb.SessionBean

TellerBean is a stateless SessionBean. This bean illustrates:

Author:
Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.

Inner Class Summary
(package private)  class TellerBean.Balance
          Performs a balance lookup.
(package private)  class TellerBean.Deposit
          Performs a deposit.
(package private)  class TellerBean.Transaction
          Inner class that is used for transactions with the entity beans.
(package private)  class TellerBean.Transfer
          Performs a transfer.
(package private)  class TellerBean.Withdrawal
          Performs a withdrawl.
 
Field Summary
(package private) static int SLEEP
           
(package private) static boolean VERBOSE
           
 
Constructor Summary
TellerBean()
           
 
Method Summary
 TellerResult balance(java.lang.String accountId)
          Returns the balance of the account in a TellerResult object.
 boolean checkTransactionId(java.lang.String transactionId)
          Returns true if the transaction with a given ID was completed (i.e., the transaction ID can be found in the transaction log table).
 TellerResult deposit(java.lang.String accountId, double amount, java.lang.String transactionId)
          Deposits amount in specified account using a specific transactionID.
 void ejbActivate()
          This method is required by the EJB Specification, but is not used by this example.
 void ejbCreate()
          This method corresponds to the create method in the home interface "TellerHome.java".
 void ejbPassivate()
          This method is required by the EJB Specification, but is not used by this example.
 void ejbRemove()
          This method is required by the EJB Specification, but is not used by this example.
 void setSessionContext(javax.ejb.SessionContext ctx)
          Sets the session context, server name, properties, maximum log table size and the log pool name.
 TellerResult transfer(java.lang.String accountFrom, java.lang.String accountTo, double amount, java.lang.String transactionId)
          Transfers amount from accountFrom to accountTo using a specific transactionID.
 TellerResult withdraw(java.lang.String accountId, double amount, java.lang.String transactionId)
          Withdraws amount from a specified account using a specific transactionID.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLEEP

static final int SLEEP

VERBOSE

static final boolean VERBOSE
Constructor Detail

TellerBean

public TellerBean()
Method Detail

balance

public TellerResult balance(java.lang.String accountId)
                     throws TellerException,
                            java.rmi.RemoteException
Returns the balance of the account in a TellerResult object.
Parameters:
accountId - string account ID
Returns:
TellerResult result of inquiry
Throws:
TellerException - if there is an error while checking the balance
java.rmi.RemoteException - if there is a communications or systems failure

checkTransactionId

public boolean checkTransactionId(java.lang.String transactionId)
                           throws java.rmi.RemoteException
Returns true if the transaction with a given ID was completed (i.e., the transaction ID can be found in the transaction log table).

Note that the code in this method is specific for Oracle databases and would require adjustment for other databases.

Parameters:
transactionID - string transaction ID
Returns:
Boolean
Throws:
java.rmi.RemoteException - if there is a communications or systems failure

deposit

public TellerResult deposit(java.lang.String accountId,
                            double amount,
                            java.lang.String transactionId)
                     throws TellerException,
                            java.rmi.RemoteException
Deposits amount in specified account using a specific transactionID.
Parameters:
accountId - string account ID
amount - double amount to deposit
transactionId - string transaction ID
Returns:
TellerResult result of inquiry
Throws:
TellerException - if there is an error while making the deposit
java.rmi.RemoteException - if there is a communications or systems failure

ejbActivate

public void ejbActivate()
This method is required by the EJB Specification, but is not used by this example.
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
This method corresponds to the create method in the home interface "TellerHome.java". The parameter sets of the two methods are identical. When the client calls TellerHome.create(), the container allocates an instance of the EJBean and calls ejbCreate().
Throws:
javax.ejb.CreateException - if there is a problem creating the bean
See Also:
examples.cluster.ejb.Teller

ejbPassivate

public void ejbPassivate()
This method is required by the EJB Specification, but is not used by this example.
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
This method is required by the EJB Specification, but is not used by this example.
Specified by:
ejbRemove in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext ctx)
Sets the session context, server name, properties, maximum log table size and the log pool name.
Specified by:
setSessionContext in interface javax.ejb.SessionBean
Parameters:
ctx - SessionContext

transfer

public TellerResult transfer(java.lang.String accountFrom,
                             java.lang.String accountTo,
                             double amount,
                             java.lang.String transactionId)
                      throws TellerException,
                             java.rmi.RemoteException
Transfers amount from accountFrom to accountTo using a specific transactionID.
Parameters:
accountFrom - string account ID of account taking amount from
accountTo - string account ID of account sending amount to
amount - double amount to transfer
transactionId - string transaction ID
Returns:
TellerResult result of inquiry
Throws:
TellerException - if there is an error while making the transfer
java.rmi.RemoteException - if there is a communications or systems failure

withdraw

public TellerResult withdraw(java.lang.String accountId,
                             double amount,
                             java.lang.String transactionId)
                      throws TellerException,
                             java.rmi.RemoteException
Withdraws amount from a specified account using a specific transactionID.
Parameters:
accountId - string account ID
amount - double amount to withdraw
transactionId - string transaction ID
Returns:
TellerResult result of inquiry
Throws:
TellerException - if there is an error while making the withdrawal
java.rmi.RemoteException - if there is a communications or systems failure

Documentation is available at
http://e-docs.bea.com/wls/docs60

Copyright © 2000 BEA Systems, Inc. All Rights Reserved.