All Examples  All EJB Examples  This Package

Class examples.ejb.basic.containerManaged.AccountBean

examples.ejb.basic.containerManaged.AccountBean

public class AccountBean
AccountBean is an EntityBean. This EJBean illustrates:


Variable Index

 o accountId
 
 o accountType
 
 o balance
 

Constructor Index

 o AccountBean()
 

Method Index

 o accountType()
Returns the account type.
 o balance()
Returns current balance.
 o deposit(double)
Adds amount to balance.
 o ejbActivate()
This method is required by the EJB Specification, but is not used by this example.
 o ejbCreate(String, double, String)
This method corresponds to the create method in the home interface "AccountHome.java".
 o ejbLoad()
This method is required by the EJB Specification, but is not used by this example.
 o ejbPassivate()
This method is required by the EJB Specification, but is not used by this example.
 o ejbPostCreate(String, double, String)
This method is required by the EJB Specification, but is not used by this example.
 o ejbRemove()
This method is required by the EJB Specification, but is not used by this example.
 o ejbStore()
Sets the EJBean's modified flag to false.
 o isModified()
Returns whether the EJBean has been modified or not.
 o setEntityContext(EntityContext)
Sets the EntityContext for the EJBean.
 o setModified(boolean)
Sets the EJBean's modified flag.
 o unsetEntityContext()
Unsets the EntityContext for the EJBean.
 o withdraw(double)
Subtracts amount from balance.

Field Detail

 o accountId
public java.lang.String accountId
 o balance
public double balance
 o accountType
public java.lang.String accountType

Constructor Detail

 o AccountBean
public AccountBean()

Method Detail

 o setEntityContext
public void setEntityContext(javax.ejb.EntityContext ctx)
          Sets the EntityContext for the EJBean.
Parameters:
ctx - EntityContext
 o unsetEntityContext
public void unsetEntityContext()
          Unsets the EntityContext for the EJBean.
 o 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
 o setModified
public void setModified(boolean flag)
          Sets the EJBean's modified flag.
Parameters:
flag - Modified Flag
 o ejbActivate
public void ejbActivate()
          This method is required by the EJB Specification, but is not used by this example.
 o ejbPassivate
public void ejbPassivate()
          This method is required by the EJB Specification, but is not used by this example.
 o ejbLoad
public void ejbLoad()
          This method is required by the EJB Specification, but is not used by this example.
 o ejbStore
public void ejbStore()
          Sets the EJBean's modified flag to false. set to false to "reset" the variable for the next transaction.
 o ejbRemove
public void ejbRemove() throws javax.ejb.RemoveException
          This method is required by the EJB Specification, but is not used by this example.
Throws:
javax.ejb.RemoveException - if the EJBean does not allow removing the EJBean
 o 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
 o 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
 o deposit
public double deposit(double amount)
          Adds amount to balance.
Parameters:
amount - double Amount
Returns:
double balance
 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 accountType
public java.lang.String accountType()
          Returns the account type.
Returns:
String account Type

All Examples  All EJB Examples  This Package