WebLogic Server 6.1 Code Examples, BEA Systems, Inc.

examples.tutorials.migration.banking
Class AccountBean

java.lang.Object
  |
  +--examples.tutorials.migration.banking.AccountBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, javax.ejb.EntityBean, java.io.Serializable

public class AccountBean
extends java.lang.Object
implements javax.ejb.EntityBean

AccountBean is an EntityBean. This EJBean illustrates:

Author:
Copyright (c) 1998 by WebLogic, Inc. All Rights Reserved., Copyright (c) 2001 by BEA Systems, Inc. All Rights Reserved.

Field Summary
 java.lang.String accountId
           
 java.lang.String accountType
           
 double balance
           
(package private) static boolean VERBOSE
           
 
Constructor Summary
AccountBean()
           
 
Method Summary
 java.lang.String accountType()
          Returns the account type.
 double balance()
          Returns current balance.
 double deposit(double amount)
          Adds amount to balance.
 void ejbActivate()
          This method is required by the EJB Specification, but is not used by this example.
 java.lang.String ejbCreate(java.lang.String accountId, double initialBalance, java.lang.String type)
          This method corresponds to the create method in the home interface "AccountHome.java".
 void ejbLoad()
          This method is required by the EJB Specification, but is not used by this example.
 void ejbPassivate()
          This method is required by the EJB Specification, but is not used by this example.
 void ejbPostCreate(java.lang.String accountId, double initialBalance, java.lang.String type)
          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 ejbStore()
          Sets the EJBean's modified flag to false.
 boolean isModified()
          Returns whether the EJBean has been modified or not.
 void setEntityContext(javax.ejb.EntityContext ctx)
          Sets the EntityContext for the EJBean.
 void setModified(boolean flag)
          Sets the EJBean's modified flag.
 void unsetEntityContext()
          Unsets the EntityContext for the EJBean.
 double withdraw(double amount)
          Subtracts amount from balance.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

accountId

public java.lang.String accountId

accountType

public java.lang.String accountType

balance

public double balance

VERBOSE

static final boolean VERBOSE
Constructor Detail

AccountBean

public AccountBean()
Method Detail

accountType

public java.lang.String accountType()
Returns the account type.
Returns:
String account Type

balance

public double balance()
Returns current balance.
Returns:
double Balance

deposit

public double deposit(double amount)
Adds amount to balance.
Parameters:
amount - double Amount
Returns:
double balance

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.EntityBean

ejbCreate

public java.lang.String ejbCreate(java.lang.String accountId,
                                  double initialBalance,
                                  java.lang.String type)
                           throws javax.ejb.CreateException
This method corresponds to the create method in the home interface "AccountHome.java". The parameter sets of the two methods are identical. When the client calls AccountHome.create(), the container (which in WebLogic EJB is also the home) allocates an instance of this EJBean and calls AccountBean.ejbCreate().

For container-managed persistence, ejbCreate() returns a null, unlike the case of bean-managed persistence, where it returns a primary key.

Parameters:
accountID - String Account ID
initialBalance - double Initial Balance
Throws:
javax.ejb.CreateException - if there is a problem creating the bean

ejbLoad

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

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.EntityBean

ejbPostCreate

public void ejbPostCreate(java.lang.String accountId,
                          double initialBalance,
                          java.lang.String type)
This method is required by the EJB Specification, but is not used by this example.
Parameters:
accountID - String Account Identification
initialBalance - double Initial Balance
type - String Account type

ejbRemove

public void ejbRemove()
               throws javax.ejb.RemoveException
This method is required by the EJB Specification, but is not used by this example.
Specified by:
ejbRemove in interface javax.ejb.EntityBean
Throws:
javax.ejb.RemoveException - if the EJBean does not allow removing the EJBean

ejbStore

public void ejbStore()
Sets the EJBean's modified flag to false. set to false to "reset" the variable for the next transaction.
Specified by:
ejbStore in interface javax.ejb.EntityBean

isModified

public boolean isModified()
Returns whether the EJBean has been modified or not. This method must be public for the container to be able to invoke it.
Returns:
boolean isDirty

setEntityContext

public void setEntityContext(javax.ejb.EntityContext ctx)
Sets the EntityContext for the EJBean.
Specified by:
setEntityContext in interface javax.ejb.EntityBean
Parameters:
ctx - EntityContext

setModified

public void setModified(boolean flag)
Sets the EJBean's modified flag.
Parameters:
flag - Modified Flag

unsetEntityContext

public void unsetEntityContext()
Unsets the EntityContext for the EJBean.
Specified by:
unsetEntityContext in interface javax.ejb.EntityBean

withdraw

public double withdraw(double amount)
                throws ProcessingErrorException
Subtracts amount from balance.
Parameters:
amount - double Amount
Returns:
double Balance
Throws:
ProcessingErrorException - if Amount > Balance

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

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