All Examples All EJB Examples This Package
Class examples.ejb.basic.statefulSession.TraderBean
java.lang.Object
|
+----examples.ejb.basic.statefulSession.TraderBean
- public class TraderBean
- extends Object
- implements SessionBean
TraderBean is a stateful SessionBean. This EJBean illustrates:
- Automatic persistence of state between calls to the SessionBean
- Application-defined exceptions
- Author:
- Copyright (c) 1998 by WebLogic, Inc. All Rights Reserved.
- Copyright (c) 1998-1999 by BEA WebXpress. All Rights Reserved.
-
traderName
-
-
tradingBalance
-
-
TraderBean()
-
-
buy(String, String, int)
- Buys shares of a stock for a named customer.
-
ejbActivate()
- This method is required by the EJB Specification,
but is not used by this example.
-
ejbCreate(String)
- This method corresponds to the create method in the home interface
"TraderHome.java".
-
ejbPassivate()
- 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.
-
getBalance()
- Returns the current balance of a trading session.
-
getDatabaseName()
- Returns the JDBC pool name.
-
getStockPrice(String)
- Returns the stock price for a given stock.
-
getTradeLimit()
- Returns the trading limit.
-
getTraderName()
- Returns the name of this Trader.
-
sell(String, String, int)
- Sells shares of a stock for a named customer.
-
setSessionContext(SessionContext)
- Sets the session context.
traderName
public String traderName
tradingBalance
public double tradingBalance
TraderBean
public TraderBean()
ejbActivate
public void ejbActivate()
- This method is required by the EJB Specification,
but is not used by this example.
ejbRemove
public void ejbRemove()
- 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.
setSessionContext
public void setSessionContext(SessionContext ctx)
- Sets the session context.
- Parameters:
- ctx - SessionContext Context for session
ejbCreate
public void ejbCreate(String traderName)
- This method corresponds to the create method in the home interface
"TraderHome.java".
The parameter sets of the two methods are identical. When the client calls
TraderHome.create()
, the container allocates an instance of
the EJBean and calls ejbCreate()
.
- Parameters:
- traderName - String Trader Name
- See Also:
- Trader
buy
public TradeResult buy(String customerName,
String stockSymbol,
int shares) throws ProcessingErrorException
- Buys shares of a stock for a named customer.
- Parameters:
- customerName - String Customer name
- stockSymbol - String Stock symbol
- shares - int Number of shares to buy
- Returns:
- TradeResult Trade Result
- Throws: ProcessingErrorException
- if there is an error while buying the shares
sell
public TradeResult sell(String customerName,
String stockSymbol,
int shares) throws ProcessingErrorException
- Sells shares of a stock for a named customer.
- Parameters:
- customerName - String Customer name
- stockSymbol - String Stock symbol
- shares - int Number of shares to buy
- Returns:
- TradeResult Trade Result
- Throws: ProcessingErrorException
- if there is an error while selling the shares
getTraderName
public String getTraderName()
- Returns the name of this Trader.
- Returns:
- String traderName
getBalance
public double getBalance()
- Returns the current balance of a trading session.
- Returns:
- double Balance
getTradeLimit
public int getTradeLimit()
- Returns the trading limit.
- Returns:
- int Trading limit
getDatabaseName
public String getDatabaseName()
- Returns the JDBC pool name.
- Returns:
- String JDBC pool name
getStockPrice
public double getStockPrice(String stockSymbol) throws ProcessingErrorException
- Returns the stock price for a given stock.
- Parameters:
- stockSymbol - String Stock symbol
- Returns:
- double Stock price
- Throws: ProcessingErrorException
- if there is an error while checking the price
All Examples All EJB Examples This Package