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:
- Container-managed JDBC persistence and transactions;
the code in this file never directly accesses the data storage.
- Application-defined exceptions.
- The use of the WebLogic extension isModified;
methods that modify a container managed field set isDirty to true.
ejbStore sets isModified to false at the end of the transaction.
-
accountId
-
-
accountType
-
-
balance
-
-
AccountBean()
-
-
accountType()
- Returns the account type.
-
balance()
- Returns current balance.
-
deposit(double)
- Adds amount to balance.
-
ejbActivate()
- This method is required by the EJB Specification,
but is not used by this example.
-
ejbCreate(String, double, String)
- This method corresponds to the create method in the home interface
"AccountHome.java".
-
ejbLoad()
- This method is required by the EJB Specification,
but is not used by this example.
-
ejbPassivate()
- This method is required by the EJB Specification,
but is not used by this example.
-
ejbPostCreate(String, double, String)
- This method is required by the EJB Specification,
but is not used by this example.
-
ejbRemove()
- This method is required by the EJB Specification,
but is not used by this example.
-
ejbStore()
- Sets the EJBean's modified flag to false.
-
isModified()
- Returns whether the EJBean has been modified or not.
-
setEntityContext(EntityContext)
- Sets the EntityContext for the EJBean.
-
setModified(boolean)
- Sets the EJBean's modified flag.
-
unsetEntityContext()
- Unsets the EntityContext for the EJBean.
-
withdraw(double)
- Subtracts amount from balance.
accountId
public java.lang.String accountId
balance
public double balance
accountType
public java.lang.String accountType
AccountBean
public AccountBean()
setEntityContext
public void setEntityContext(javax.ejb.EntityContext ctx)
Sets the EntityContext for the EJBean.
- Parameters:
ctx
- EntityContext
unsetEntityContext
public void unsetEntityContext()
Unsets the EntityContext for the EJBean.
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
setModified
public void setModified(boolean flag)
Sets the EJBean's modified flag.
- Parameters:
flag
- Modified Flag
ejbActivate
public void ejbActivate()
This method is required by the EJB Specification,
but is not used by this example.
ejbPassivate
public void ejbPassivate()
This method is required by the EJB Specification,
but is not used by this example.
ejbLoad
public void ejbLoad()
This method is required by the EJB Specification,
but is not used by this example.
ejbStore
public void ejbStore()
Sets the EJBean's modified flag to false.
set to false to "reset" the variable for the next transaction.
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
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
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
deposit
public double deposit(double amount)
Adds amount to balance.
- Parameters:
amount
- double Amount
- Returns:
- double balance
withdraw
public double withdraw(double amount) throws ProcessingErrorException
Subtracts amount from balance.
- Parameters:
amount
- double Amount
- Returns:
- double Balance
- Throws:
- ProcessingErrorException - if Amount > Balance
balance
public double balance()
Returns current balance.
- Returns:
- double Balance
accountType
public java.lang.String accountType()
Returns the account type.
- Returns:
- String account Type
All Examples All EJB Examples This Package