org.apache.geronimo.samples.daytrader
Class TradeAction

java.lang.Object
  extended byorg.apache.geronimo.samples.daytrader.TradeAction
All Implemented Interfaces:
java.rmi.Remote, TradeServices

public class TradeAction
extends java.lang.Object
implements TradeServices

The TradeAction class provides the generic client side access to each of the Trade brokerage user operations. These include login, logout, buy, sell, getQuote, etc. The TradeAction class does not handle user interface processing and should be used by a class that is UI specific. For example, trade_client.TradeServletActionmanages a web interface to Trade, making calls to TradeAction methods to actually performance each operation.


Constructor Summary
TradeAction()
           
TradeAction(TradeServices trade)
           
 
Method Summary
 OrderDataBean buy(java.lang.String userID, java.lang.String symbol, double quantity, int orderProcessingMode)
          Purchase a stock and create a new holding for the given user.
 void cancelOrder(java.lang.Integer orderID, boolean twoPhase)
          Cancel the Order identified by orderID Orders are submitted through JMS to a Trading Broker and completed asynchronously.
 OrderDataBean completeOrder(java.lang.Integer orderID, boolean twoPhase)
          Complete the Order identefied by orderID Orders are submitted through JMS to a Trading agent and completed asynchronously.
 QuoteDataBean createQuote(java.lang.String symbol, java.lang.String companyName, java.math.BigDecimal price)
          Given a market symbol, price, and details, create and return a new QuoteDataBean
 AccountDataBean getAccountData(java.lang.String userID)
          Return an AccountDataBean object for userID describing the account
 AccountProfileDataBean getAccountProfileData(java.lang.String userID)
          Return an AccountProfileDataBean for userID providing the users profile
 java.util.Collection getAllQuotes()
          Return a collection of QuoteDataBeandescribing all current quotes
 java.util.Collection getClosedOrders(java.lang.String userID)
          Get the collection of completed orders for a given account that need to be alerted to the user
 HoldingDataBean getHolding(java.lang.Integer holdingID)
          Return a specific user stock holding identifed by the holdingID
 java.util.Collection getHoldings(java.lang.String userID)
          Return the portfolio of stock holdings for the specified customer as a collection of HoldingDataBeans
 MarketSummaryDataBean getMarketSummary()
          Compute and return a snapshot of the current market conditions This includes the TSIA - an index of the price of the top 100 Trade stock quotes The openTSIA ( the index at the open) The volume of shares traded, Top Stocks gain and loss
 java.util.Collection getOrders(java.lang.String userID)
          Get the collection of all orders for a given account
 QuoteDataBean getQuote(java.lang.String symbol)
          Return a QuoteDataBeandescribing a current quote for the given stock symbol
 AccountDataBean login(java.lang.String userID, java.lang.String password)
          Attempt to authenticate and login a user with the given password
 void logout(java.lang.String userID)
          Logout the given user
 void orderCompleted(java.lang.String userID, java.lang.Integer orderID)
          Signify an order has been completed for the given userID
 void queueOrder(java.lang.Integer orderID, boolean twoPhase)
          Queue the Order identified by orderID to be processed Orders are submitted through JMS to a Trading Broker and completed asynchronously.
 AccountDataBean register(java.lang.String userID, java.lang.String password, java.lang.String fullname, java.lang.String address, java.lang.String email, java.lang.String creditCard, java.math.BigDecimal openBalance)
          Register a new Trade customer.
 AccountDataBean register(java.lang.String userID, java.lang.String password, java.lang.String fullname, java.lang.String address, java.lang.String email, java.lang.String creditCard, java.lang.String openBalanceString)
           
 RunStatsDataBean resetTrade(boolean deleteAll)
          Reset the TradeData by - removing all newly registered users by scenario servlet (i.e.
 OrderDataBean sell(java.lang.String userID, java.lang.Integer holdingID, int orderProcessingMode)
          Sell a stock holding and removed the holding for the given user.
 OrderDataBean sell(java.lang.String userID, int holdingID, int orderProcessingMode)
          Sell(SOAP 2.2 Wrapper converting int to Integer) a stock holding and removed the holding for the given user.
 AccountProfileDataBean updateAccountProfile(AccountProfileDataBean accountProfileData)
          Update userID's account profile information using the provided AccountProfileDataBean object
 QuoteDataBean updateQuotePriceVolume(java.lang.String symbol, java.math.BigDecimal changeFactor, double sharesTraded)
          Update the stock quote price for the specified stock symbol
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TradeAction

public TradeAction()

TradeAction

public TradeAction(TradeServices trade)
Method Detail

getMarketSummary

public MarketSummaryDataBean getMarketSummary()
                                       throws java.lang.Exception
Compute and return a snapshot of the current market conditions This includes the TSIA - an index of the price of the top 100 Trade stock quotes The openTSIA ( the index at the open) The volume of shares traded, Top Stocks gain and loss

Specified by:
getMarketSummary in interface TradeServices
Returns:
A snapshot of the current market summary
Throws:
java.lang.Exception

buy

public OrderDataBean buy(java.lang.String userID,
                         java.lang.String symbol,
                         double quantity,
                         int orderProcessingMode)
                  throws java.lang.Exception
Purchase a stock and create a new holding for the given user. Given a stock symbol and quantity to purchase, retrieve the current quote price, debit the user's account balance, and add holdings to user's portfolio.

Specified by:
buy in interface TradeServices
Parameters:
userID - the customer requesting the stock purchase
symbol - the symbol of the stock being purchased
quantity - the quantity of shares to purchase
Returns:
OrderDataBean providing the status of the newly created buy order
Throws:
java.lang.Exception

sell

public OrderDataBean sell(java.lang.String userID,
                          int holdingID,
                          int orderProcessingMode)
                   throws java.lang.Exception
Sell(SOAP 2.2 Wrapper converting int to Integer) a stock holding and removed the holding for the given user. Given a Holding, retrieve current quote, credit user's account, and reduce holdings in user's portfolio.

Parameters:
userID - the customer requesting the sell
holdingID - the users holding to be sold
Returns:
OrderDataBean providing the status of the newly created sell order
Throws:
java.lang.Exception

sell

public OrderDataBean sell(java.lang.String userID,
                          java.lang.Integer holdingID,
                          int orderProcessingMode)
                   throws java.lang.Exception
Sell a stock holding and removed the holding for the given user. Given a Holding, retrieve current quote, credit user's account, and reduce holdings in user's portfolio.

Specified by:
sell in interface TradeServices
Parameters:
userID - the customer requesting the sell
holdingID - the users holding to be sold
Returns:
OrderDataBean providing the status of the newly created sell order
Throws:
java.lang.Exception

queueOrder

public void queueOrder(java.lang.Integer orderID,
                       boolean twoPhase)
Queue the Order identified by orderID to be processed Orders are submitted through JMS to a Trading Broker and completed asynchronously. This method queues the order for processing The boolean twoPhase specifies to the server implementation whether or not the method is to participate in a global transaction

Specified by:
queueOrder in interface TradeServices
Parameters:
orderID - the Order being queued for processing
Returns:
OrderDataBean providing the status of the completed order

completeOrder

public OrderDataBean completeOrder(java.lang.Integer orderID,
                                   boolean twoPhase)
Complete the Order identefied by orderID Orders are submitted through JMS to a Trading agent and completed asynchronously. This method completes the order For a buy, the stock is purchased creating a holding and the users account is debited For a sell, the stock holding is removed and the users account is credited with the proceeds The boolean twoPhase specifies to the server implementation whether or not the method is to participate in a global transaction

Specified by:
completeOrder in interface TradeServices
Parameters:
orderID - the Order to complete
Returns:
OrderDataBean providing the status of the completed order

cancelOrder

public void cancelOrder(java.lang.Integer orderID,
                        boolean twoPhase)
Cancel the Order identified by orderID Orders are submitted through JMS to a Trading Broker and completed asynchronously. This method queues the order for processing The boolean twoPhase specifies to the server implementation whether or not the method is to participate in a global transaction

Specified by:
cancelOrder in interface TradeServices
Parameters:
orderID - the Order being queued for processing
Returns:
OrderDataBean providing the status of the completed order

orderCompleted

public void orderCompleted(java.lang.String userID,
                           java.lang.Integer orderID)
                    throws java.lang.Exception
Description copied from interface: TradeServices
Signify an order has been completed for the given userID

Specified by:
orderCompleted in interface TradeServices
Parameters:
userID - the user for which an order has completed
orderID - the order which has completed
Throws:
java.lang.Exception

getOrders

public java.util.Collection getOrders(java.lang.String userID)
                               throws java.lang.Exception
Get the collection of all orders for a given account

Specified by:
getOrders in interface TradeServices
Parameters:
userID - the customer account to retrieve orders for
Returns:
Collection OrderDataBeans providing detailed order information
Throws:
java.lang.Exception

getClosedOrders

public java.util.Collection getClosedOrders(java.lang.String userID)
                                     throws java.lang.Exception
Get the collection of completed orders for a given account that need to be alerted to the user

Specified by:
getClosedOrders in interface TradeServices
Parameters:
userID - the customer account to retrieve orders for
Returns:
Collection OrderDataBeans providing detailed order information
Throws:
java.lang.Exception

createQuote

public QuoteDataBean createQuote(java.lang.String symbol,
                                 java.lang.String companyName,
                                 java.math.BigDecimal price)
                          throws java.lang.Exception
Given a market symbol, price, and details, create and return a new QuoteDataBean

Specified by:
createQuote in interface TradeServices
Parameters:
symbol - the symbol of the stock
price - the current stock price
Returns:
a new QuoteDataBean or null if Quote could not be created
Throws:
java.lang.Exception

getAllQuotes

public java.util.Collection getAllQuotes()
                                  throws java.lang.Exception
Return a collection of QuoteDataBeandescribing all current quotes

Specified by:
getAllQuotes in interface TradeServices
Returns:
the collection of QuoteDataBean
Throws:
java.lang.Exception

getQuote

public QuoteDataBean getQuote(java.lang.String symbol)
                       throws java.lang.Exception
Return a QuoteDataBeandescribing a current quote for the given stock symbol

Specified by:
getQuote in interface TradeServices
Parameters:
symbol - the stock symbol to retrieve the current Quote
Returns:
the QuoteDataBean
Throws:
java.lang.Exception

updateQuotePriceVolume

public QuoteDataBean updateQuotePriceVolume(java.lang.String symbol,
                                            java.math.BigDecimal changeFactor,
                                            double sharesTraded)
                                     throws java.lang.Exception
Update the stock quote price for the specified stock symbol

Specified by:
updateQuotePriceVolume in interface TradeServices
Parameters:
symbol - for stock quote to update
Returns:
the QuoteDataBean describing the stock
Throws:
java.lang.Exception

getHoldings

public java.util.Collection getHoldings(java.lang.String userID)
                                 throws java.lang.Exception
Return the portfolio of stock holdings for the specified customer as a collection of HoldingDataBeans

Specified by:
getHoldings in interface TradeServices
Parameters:
userID - the customer requesting the portfolio
Returns:
Collection of the users portfolio of stock holdings
Throws:
java.lang.Exception

getHolding

public HoldingDataBean getHolding(java.lang.Integer holdingID)
                           throws java.lang.Exception
Return a specific user stock holding identifed by the holdingID

Specified by:
getHolding in interface TradeServices
Parameters:
holdingID - the holdingID to return
Returns:
a HoldingDataBean describing the holding
Throws:
java.lang.Exception

getAccountData

public AccountDataBean getAccountData(java.lang.String userID)
                               throws javax.ejb.FinderException,
                                      java.rmi.RemoteException
Return an AccountDataBean object for userID describing the account

Specified by:
getAccountData in interface TradeServices
Parameters:
userID - the account userID to lookup
Returns:
User account data in AccountDataBean
Throws:
javax.ejb.FinderException
java.rmi.RemoteException

getAccountProfileData

public AccountProfileDataBean getAccountProfileData(java.lang.String userID)
                                             throws java.lang.Exception
Return an AccountProfileDataBean for userID providing the users profile

Specified by:
getAccountProfileData in interface TradeServices
Parameters:
userID - the account userID to lookup
Throws:
java.lang.Exception

updateAccountProfile

public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean accountProfileData)
                                            throws java.lang.Exception
Update userID's account profile information using the provided AccountProfileDataBean object

Specified by:
updateAccountProfile in interface TradeServices
Throws:
java.lang.Exception

login

public AccountDataBean login(java.lang.String userID,
                             java.lang.String password)
                      throws java.lang.Exception
Attempt to authenticate and login a user with the given password

Specified by:
login in interface TradeServices
Parameters:
userID - the customer to login
password - the password entered by the customer for authentication
Returns:
User account data in AccountDataBean
Throws:
java.lang.Exception

logout

public void logout(java.lang.String userID)
            throws java.lang.Exception
Logout the given user

Specified by:
logout in interface TradeServices
Parameters:
userID - the customer to logout
Returns:
the login status
Throws:
java.lang.Exception

register

public AccountDataBean register(java.lang.String userID,
                                java.lang.String password,
                                java.lang.String fullname,
                                java.lang.String address,
                                java.lang.String email,
                                java.lang.String creditCard,
                                java.math.BigDecimal openBalance)
                         throws java.lang.Exception
Register a new Trade customer. Create a new user profile, user registry entry, account with initial balance, and empty portfolio.

Specified by:
register in interface TradeServices
Parameters:
userID - the new customer to register
password - the customers password
fullname - the customers fullname
address - the customers street address
email - the customers email address
creditCard - the customers creditcard number
Returns:
the userID if successful, null otherwise
Throws:
java.lang.Exception

register

public AccountDataBean register(java.lang.String userID,
                                java.lang.String password,
                                java.lang.String fullname,
                                java.lang.String address,
                                java.lang.String email,
                                java.lang.String creditCard,
                                java.lang.String openBalanceString)
                         throws java.lang.Exception
Throws:
java.lang.Exception

resetTrade

public RunStatsDataBean resetTrade(boolean deleteAll)
                            throws java.lang.Exception
Reset the TradeData by - removing all newly registered users by scenario servlet (i.e. users with userID's beginning with "ru:") * - removing all buy/sell order pairs - setting logoutCount = loginCount return statistics for this benchmark run

Specified by:
resetTrade in interface TradeServices
Throws:
java.lang.Exception


Copyright © 2005-2006 Apache Software Foundation. All Rights Reserved.