All Examples  All EJB Examples  This Package

Class examples.ejb.basic.beanManaged.AccountBean

java.lang.Object
   |
   +----examples.ejb.basic.beanManaged.AccountBean

public class AccountBean
extends Object
implements EntityBean
AccountBean is an EntityBean. This EJBean illustrates:

Author:
Copyright (c) 1998 by WebLogic, Inc. All Rights Reserved., Copyright (c) 1998-1999 by BEA WebXpress. All Rights Reserved.

Variable Index

 o accountId
 o balance

Constructor Index

 o AccountBean()

Method Index

 o balance()
Returns current balance.
 o deposit(double)
Adds amount to balance.
 o ejbActivate()
Required by the EJB specification, this method is not used by this example.
 o ejbCreate(String, double)
This method corresponds to the create method in the home interface "AccountHome.java".
 o ejbFindBigAccounts(double)
Finds all EJBeans with a balance greater than a given amount.
 o ejbFindByPrimaryKey(AccountPK)
Given a Primary Key, refreshes the EJBean from the persistent storage.
 o ejbFindSavingsAccount()
Throws a FinderException as there is no savings account.
 o ejbLoad()
Refreshes the EJBean from the persistent storage.
 o ejbPassivate()
This method is required by the EJB Specification, but is not used by this example.
 o ejbPostCreate(String, double)
Required by the EJB specification, this method is not used by this example.
 o ejbRemove()
Deletes the EJBean from the persistent storage.
 o ejbStore()
Stores the EJBean in the persistent storage.
 o getConnection()
Gets current connection to the connection pool.
 o id()
Returns the Primary Key identifying this EJBean.
 o setEntityContext(EntityContext)
Sets the EntityContext for the EJBean.
 o unsetEntityContext()
Unsets the EntityContext for the EJBean.
 o withdraw(double)
Subtracts amount from balance.

Variables

 o accountId
 public String accountId
 o balance
 public double balance

Constructors

 o AccountBean
 public AccountBean()

Methods

 o id
 public String id()
Returns the Primary Key identifying this EJBean.

Returns:
String Identification
 o ejbActivate
 public void ejbActivate() throws RemoteException
Required by the EJB specification, this method is not used by this example.

Throws: RemoteException
if there is a communications or systems failure
 o setEntityContext
 public void setEntityContext(EntityContext ctx) throws RemoteException
Sets the EntityContext for the EJBean.

Parameters:
ctx - EntityContext
Throws: RemoteException
if there is a communications or systems failure
 o unsetEntityContext
 public void unsetEntityContext() throws RemoteException
Unsets the EntityContext for the EJBean.

Throws: RemoteException
if there is a communications or systems failure
 o ejbPassivate
 public void ejbPassivate() throws RemoteException
This method is required by the EJB Specification, but is not used by this example.

Throws: RemoteException
if there is a communications or systems failure
 o ejbLoad
 public void ejbLoad() throws RemoteException
Refreshes the EJBean from the persistent storage.

Throws: RemoteException
if there is a communications or systems failure
 o ejbFindByPrimaryKey
 public AccountPK ejbFindByPrimaryKey(AccountPK pk) throws FinderException, RemoteException
Given a Primary Key, refreshes the EJBean from the persistent storage.

Parameters:
pk - AccountPK Primary Key
Returns:
AccountPK Primary Key
Throws: RemoteException
if there is a communications or systems failure
Throws: FinderException
thrown if the EJBean cannot be found
 o ejbStore
 public void ejbStore() throws RemoteException
Stores the EJBean in the persistent storage.

Throws: RemoteException
if there is a communications or systems failure
 o ejbRemove
 public void ejbRemove() throws RemoteException
Deletes the EJBean from the persistent storage.

Throws: RemoteException
if there is a communications or systems failure
 o ejbCreate
 public AccountPK ejbCreate(String accountId,
                            double initialBalance) throws 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 bean and calls AccountBean.ejbCreate().

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

Parameters:
accountID - String Account ID
initialBalance - Double Initial Balance
Returns:
AccountPK
Throws: CreateException
if there is a problem creating the bean
 o ejbPostCreate
 public void ejbPostCreate(String accountId,
                           double initialBalance)
Required by the EJB specification, this method is not used by this example.

Parameters:
accountID - String Account Identification
initialBalance - double Initial Balance
 o ejbFindBigAccounts
 public Enumeration ejbFindBigAccounts(double balanceGreaterThan) throws FinderException, RemoteException
Finds all EJBeans with a balance greater than a given amount. Returns an Enumeration of found EJBean primary keys.

Parameters:
balanceGreaterThan - double Test Amount
Returns:
Enumeration EJBean Primary Keys
Throws: RemoteException
if there is a communications or systems failure
Throws: FinderException
if an error occurs while accessing the persistent storage
 o ejbFindSavingsAccount
 public AccountPK ejbFindSavingsAccount() throws FinderException, RemoteException
Throws a FinderException as there is no savings account.

Returns:
AccountPK EJBean primary key
Throws: FinderException
if there is a problem finding the bean
Throws: RemoteException
if there is a communications or systems failure
 o deposit
 public double deposit(double amount) throws ProcessingErrorException
Adds amount to balance.

Parameters:
amount - double Amount
Returns:
double balance
Throws: ProcessingErrorException
if there is an error making a deposit
 o withdraw
 public double withdraw(double amount) throws ProcessingErrorException
Subtracts amount from balance.

Parameters:
amount - double Amount
Returns:
double Balance
Throws: ProcessingErrorException
if Amount > Balance.
 o balance
 public double balance()
Returns current balance.

Returns:
double Balance
 o getConnection
 public Connection getConnection() throws SQLException
Gets current connection to the connection pool.

Returns:
Connection
Throws: SQLException
if there is an error getting a Connection

All Examples  All EJB Examples  This Package