WebLogic Server 6.0 Code Examples, BEA Systems, Inc.

examples.ejb20.relationships.many2many
Class AccountBean

java.lang.Object
  |
  +--examples.ejb20.relationships.many2many.AccountBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, javax.ejb.EntityBean, java.io.Serializable

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

AccountBean is an EntityBean. This EJBean illustrates:

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

Field Summary
(package private) static boolean VERBOSE
           
 
Constructor Summary
AccountBean()
           
 
Method Summary
 java.lang.String accountType()
          Returns the account type.
 void addCustomer(Customer cust)
           
 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.
abstract  java.lang.String getAccountId()
          container managed fields
abstract  java.lang.String getAccountType()
           
 java.util.Collection getAllCustomers()
           
abstract  double getBalance()
           
abstract  java.util.Collection getCustomers()
           
abstract  void setAccountId(java.lang.String val)
           
abstract  void setAccountType(java.lang.String val)
           
abstract  void setBalance(double val)
           
abstract  void setCustomers(java.util.Collection col)
           
 void setEntityContext(javax.ejb.EntityContext ctx)
          Sets the EntityContext for the EJBean.
 java.lang.String toString()
           
 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, wait, wait, wait
 

Field Detail

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

addCustomer

public void addCustomer(Customer cust)

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)
                   throws javax.ejb.CreateException
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

getAccountId

public abstract java.lang.String getAccountId()
container managed fields

getAccountType

public abstract java.lang.String getAccountType()

getAllCustomers

public java.util.Collection getAllCustomers()

getBalance

public abstract double getBalance()

getCustomers

public abstract java.util.Collection getCustomers()

setAccountId

public abstract void setAccountId(java.lang.String val)

setAccountType

public abstract void setAccountType(java.lang.String val)

setBalance

public abstract void setBalance(double val)

setCustomers

public abstract void setCustomers(java.util.Collection col)

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unsetEntityContext

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

withdraw

public double withdraw(double amount)
Subtracts amount from balance.
Parameters:
amount - double Amount
Returns:
double Balance

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

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