org.apache.geronimo.samples.daytrader
Interface TradeServices

All Superinterfaces:
java.rmi.Remote
All Known Subinterfaces:
Trade
All Known Implementing Classes:
TradeAction, TradeDirect, TradeWebSoapProxy

public interface TradeServices
extends java.rmi.Remote

TradeServices interface specifies the business methods provided by the Trade online broker application. These business methods represent the features and operations that can be performed by customers of the brokerage such as login, logout, get a stock quote, buy or sell a stock, etc. This interface is implemented by Trade providing an EJB implementation of these business methods and also by TradeDirect providing a JDBC implementation.

See Also:
Trade, TradeDirect

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 identefied by orderID The boolean twoPhase specifies to the server implementation whether or not the method is to participate in a global transaction
 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 QuoteDataBean describing 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 QuoteDataBean describing 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.
 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.
 AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData)
          Update userID's account profile information using the provided AccountProfileDataBean object
 QuoteDataBean updateQuotePriceVolume(java.lang.String symbol, java.math.BigDecimal newPrice, double sharesTraded)
          Update the stock quote price and volume for the specified stock symbol
 

Method Detail

getMarketSummary

public MarketSummaryDataBean getMarketSummary()
                                       throws java.lang.Exception,
                                              java.rmi.RemoteException
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

Returns:
A snapshot of the current market summary
Throws:
java.lang.Exception
java.rmi.RemoteException

buy

public OrderDataBean buy(java.lang.String userID,
                         java.lang.String symbol,
                         double quantity,
                         int orderProcessingMode)
                  throws java.lang.Exception,
                         java.rmi.RemoteException
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. buy/sell are asynchronous, using J2EE messaging, A new order is created and submitted for processing to the TradeBroker

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
java.rmi.RemoteException

sell

public OrderDataBean sell(java.lang.String userID,
                          java.lang.Integer holdingID,
                          int orderProcessingMode)
                   throws java.lang.Exception,
                          java.rmi.RemoteException
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.

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
java.rmi.RemoteException

queueOrder

public void queueOrder(java.lang.Integer orderID,
                       boolean twoPhase)
                throws java.lang.Exception,
                       java.rmi.RemoteException
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

Parameters:
orderID - the Order being queued for processing
Returns:
OrderDataBean providing the status of the completed order
Throws:
java.lang.Exception
java.rmi.RemoteException

completeOrder

public OrderDataBean completeOrder(java.lang.Integer orderID,
                                   boolean twoPhase)
                            throws java.lang.Exception,
                                   java.rmi.RemoteException
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

Parameters:
orderID - the Order to complete
Returns:
OrderDataBean providing the status of the completed order
Throws:
java.lang.Exception
java.rmi.RemoteException

cancelOrder

public void cancelOrder(java.lang.Integer orderID,
                        boolean twoPhase)
                 throws java.lang.Exception,
                        java.rmi.RemoteException
Cancel the Order identefied by orderID The boolean twoPhase specifies to the server implementation whether or not the method is to participate in a global transaction

Parameters:
orderID - the Order to complete
Returns:
OrderDataBean providing the status of the completed order
Throws:
java.lang.Exception
java.rmi.RemoteException

orderCompleted

public void orderCompleted(java.lang.String userID,
                           java.lang.Integer orderID)
                    throws java.lang.Exception,
                           java.rmi.RemoteException
Signify an order has been completed for the given userID

Parameters:
userID - the user for which an order has completed
orderID - the order which has completed
Throws:
java.lang.Exception
java.rmi.RemoteException

getOrders

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

Parameters:
userID - the customer account to retrieve orders for
Returns:
Collection OrderDataBeans providing detailed order information
Throws:
java.lang.Exception
java.rmi.RemoteException

getClosedOrders

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

Parameters:
userID - the customer account to retrieve orders for
Returns:
Collection OrderDataBeans providing detailed order information
Throws:
java.lang.Exception
java.rmi.RemoteException

createQuote

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

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
java.rmi.RemoteException

getQuote

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

Parameters:
symbol - the stock symbol to retrieve the current Quote
Returns:
the QuoteDataBean
Throws:
java.lang.Exception
java.rmi.RemoteException

getAllQuotes

public java.util.Collection getAllQuotes()
                                  throws java.lang.Exception,
                                         java.rmi.RemoteException
Return a Collection of QuoteDataBean describing all current quotes

Returns:
A collection of QuoteDataBean
Throws:
java.lang.Exception
java.rmi.RemoteException

updateQuotePriceVolume

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

Parameters:
symbol - for stock quote to update
Returns:
the QuoteDataBean describing the stock
Throws:
java.lang.Exception
java.rmi.RemoteException

getHoldings

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

Parameters:
userID - the customer requesting the portfolio
Returns:
Collection of the users portfolio of stock holdings
Throws:
java.lang.Exception
java.rmi.RemoteException

getHolding

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

Parameters:
holdingID - the holdingID to return
Returns:
a HoldingDataBean describing the holding
Throws:
java.lang.Exception
java.rmi.RemoteException

getAccountData

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

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,
                                                    java.rmi.RemoteException
Return an AccountProfileDataBean for userID providing the users profile

Parameters:
userID - the account userID to lookup
Throws:
java.lang.Exception
java.rmi.RemoteException

updateAccountProfile

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

Throws:
java.lang.Exception
java.rmi.RemoteException

login

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

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
java.rmi.RemoteException

logout

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

Parameters:
userID - the customer to logout
Returns:
the login status
Throws:
java.lang.Exception
java.rmi.RemoteException

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,
                                java.rmi.RemoteException
Register a new Trade customer. Create a new user profile, user registry entry, account with initial balance, and empty portfolio.

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
java.rmi.RemoteException

resetTrade

public RunStatsDataBean resetTrade(boolean deleteAll)
                            throws java.lang.Exception,
                                   java.rmi.RemoteException
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

Throws:
java.lang.Exception
java.rmi.RemoteException


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