org.apache.aries.samples.ariestrader.persist.jdbc
Class TradeJdbc

java.lang.Object
  extended by org.apache.aries.samples.ariestrader.persist.jdbc.TradeJdbc
All Implemented Interfaces:
Remote, TradeServices

public class TradeJdbc
extends Object
implements TradeServices

TradeJdbc uses direct JDBC access to a javax.sql.DataSource to implement the business methods of 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. and are specified in the org.apache.aries.samples.ariestrader.TradeServices interface Note: In order for this class to be thread-safe, a new TradeJDBC must be created for each call to a method from the TradeInterface interface. Otherwise, pooled connections may not be released.

See Also:
org.apache.aries.samples.ariestrader.TradeServices

Constructor Summary
TradeJdbc()
          Zero arg constructor for TradeJdbc
TradeJdbc(boolean inSession)
           
 
Method Summary
 OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode)
           
 void cancelOrder(Integer orderID, boolean twoPhase)
           
 OrderDataBean completeOrder(Integer orderID, boolean twoPhase)
           
 QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price)
           
 void destroy()
           
 AccountDataBean getAccountData(int accountID)
           
 AccountDataBean getAccountData(String userID)
           
 AccountProfileDataBean getAccountProfileData(String userID)
           
 Collection getAllQuotes()
           
 Collection getClosedOrders(String userID)
           
 HoldingDataBean getHolding(Integer holdingID)
           
 Collection getHoldings(String userID)
           
 MarketSummaryDataBean getMarketSummary()
           
 TradeConfig.ModeType getMode()
          Get mode - returns the persistence mode (TradeConfig.JDBC)
 Collection getOrders(String userID)
           
 QuoteDataBean getQuote(String symbol)
           
 void init()
           
 AccountDataBean login(String userID, String password)
           
 void logout(String userID)
           
 void orderCompleted(String userID, Integer orderID)
           
 void queueOrder(Integer orderID, boolean twoPhase)
           
 AccountDataBean register(String userID, String password, String fullname, String address, String email, String creditCard, BigDecimal openBalance)
           
 OrderDataBean sell(String userID, Integer holdingID, int orderProcessingMode)
           
 void setDataSource(DataSource dataSource)
          set data source
 void setInSession(boolean inSession)
          setInSession
 AccountProfileDataBean updateAccountProfile(String userID, String password, String fullName, String address, String email, String creditcard)
           
 QuoteDataBean updateQuotePriceVolume(String symbol, BigDecimal changeFactor, double sharesTraded)
           
 QuoteDataBean updateQuotePriceVolumeInt(String symbol, BigDecimal changeFactor, double sharesTraded, boolean publishQuotePriceChange)
          Update a quote's price and volume
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TradeJdbc

public TradeJdbc()
Zero arg constructor for TradeJdbc


TradeJdbc

public TradeJdbc(boolean inSession)
Method Detail

setDataSource

public void setDataSource(DataSource dataSource)
set data source


setInSession

public void setInSession(boolean inSession)
setInSession


getMarketSummary

public MarketSummaryDataBean getMarketSummary()
                                       throws Exception
Specified by:
getMarketSummary in interface TradeServices
Throws:
Exception
See Also:
TradeServices.getMarketSummary()

buy

public OrderDataBean buy(String userID,
                         String symbol,
                         double quantity,
                         int orderProcessingMode)
                  throws Exception
Specified by:
buy in interface TradeServices
Throws:
Exception
See Also:
TradeServices#buy(String, String, double)

sell

public OrderDataBean sell(String userID,
                          Integer holdingID,
                          int orderProcessingMode)
                   throws Exception
Specified by:
sell in interface TradeServices
Throws:
Exception
See Also:
TradeServices#sell(String, Integer)

queueOrder

public void queueOrder(Integer orderID,
                       boolean twoPhase)
                throws Exception
Specified by:
queueOrder in interface TradeServices
Throws:
Exception
See Also:
TradeServices#queueOrder(Integer)

completeOrder

public OrderDataBean completeOrder(Integer orderID,
                                   boolean twoPhase)
                            throws Exception
Specified by:
completeOrder in interface TradeServices
Throws:
Exception
See Also:
TradeServices#completeOrder(Integer)

cancelOrder

public void cancelOrder(Integer orderID,
                        boolean twoPhase)
                 throws Exception
Specified by:
cancelOrder in interface TradeServices
Throws:
Exception
See Also:
TradeServices.cancelOrder(Integer, boolean)

orderCompleted

public void orderCompleted(String userID,
                           Integer orderID)
                    throws Exception
Specified by:
orderCompleted in interface TradeServices
Throws:
Exception

getOrders

public Collection getOrders(String userID)
                     throws Exception
Specified by:
getOrders in interface TradeServices
Throws:
Exception
See Also:
TradeServices.getOrders(String)

getClosedOrders

public Collection getClosedOrders(String userID)
                           throws Exception
Specified by:
getClosedOrders in interface TradeServices
Throws:
Exception
See Also:
TradeServices.getClosedOrders(String)

createQuote

public QuoteDataBean createQuote(String symbol,
                                 String companyName,
                                 BigDecimal price)
                          throws Exception
Specified by:
createQuote in interface TradeServices
Throws:
Exception
See Also:
TradeServices.createQuote(String, String, BigDecimal)

getQuote

public QuoteDataBean getQuote(String symbol)
                       throws Exception
Specified by:
getQuote in interface TradeServices
Throws:
Exception
See Also:
TradeServices.getQuote(String)

getAllQuotes

public Collection getAllQuotes()
                        throws Exception
Specified by:
getAllQuotes in interface TradeServices
Throws:
Exception
See Also:
TradeServices#getAllQuotes(String)

getHoldings

public Collection getHoldings(String userID)
                       throws Exception
Specified by:
getHoldings in interface TradeServices
Throws:
Exception
See Also:
TradeServices.getHoldings(String)

getHolding

public HoldingDataBean getHolding(Integer holdingID)
                           throws Exception
Specified by:
getHolding in interface TradeServices
Throws:
Exception
See Also:
TradeServices.getHolding(Integer)

getAccountData

public AccountDataBean getAccountData(String userID)
                               throws Exception
Specified by:
getAccountData in interface TradeServices
Throws:
Exception
See Also:
TradeServices.getAccountData(String)

getAccountData

public AccountDataBean getAccountData(int accountID)
                               throws Exception
Throws:
Exception
See Also:
TradeServices.getAccountData(String)

getAccountProfileData

public AccountProfileDataBean getAccountProfileData(String userID)
                                             throws Exception
Specified by:
getAccountProfileData in interface TradeServices
Throws:
Exception
See Also:
TradeServices.getAccountProfileData(String)

updateAccountProfile

public AccountProfileDataBean updateAccountProfile(String userID,
                                                   String password,
                                                   String fullName,
                                                   String address,
                                                   String email,
                                                   String creditcard)
                                            throws Exception
Specified by:
updateAccountProfile in interface TradeServices
Throws:
Exception
See Also:
TradeServices#updateAccountProfile(AccountProfileDataBean)

updateQuotePriceVolume

public QuoteDataBean updateQuotePriceVolume(String symbol,
                                            BigDecimal changeFactor,
                                            double sharesTraded)
                                     throws Exception
Specified by:
updateQuotePriceVolume in interface TradeServices
Throws:
Exception

updateQuotePriceVolumeInt

public QuoteDataBean updateQuotePriceVolumeInt(String symbol,
                                               BigDecimal changeFactor,
                                               double sharesTraded,
                                               boolean publishQuotePriceChange)
                                        throws Exception
Update a quote's price and volume

Parameters:
symbol - The PK of the quote
changeFactor - the percent to change the old price by (between 50% and 150%)
sharedTraded - the ammount to add to the current volume
publishQuotePriceChange - used by the PingJDBCWrite Primitive to ensure no JMS is used, should be true for all normal calls to this API
Throws:
Exception

login

public AccountDataBean login(String userID,
                             String password)
                      throws Exception
Specified by:
login in interface TradeServices
Throws:
Exception
See Also:
TradeServices.login(String, String)

logout

public void logout(String userID)
            throws Exception
Specified by:
logout in interface TradeServices
Throws:
Exception
See Also:
TradeServices.logout(String)

register

public AccountDataBean register(String userID,
                                String password,
                                String fullname,
                                String address,
                                String email,
                                String creditCard,
                                BigDecimal openBalance)
                         throws Exception
Specified by:
register in interface TradeServices
Throws:
Exception
See Also:
TradeServices#register(String, String, String, String, String, String, BigDecimal, boolean)

init

public void init()

destroy

public void destroy()

getMode

public TradeConfig.ModeType getMode()
Get mode - returns the persistence mode (TradeConfig.JDBC)

Specified by:
getMode in interface TradeServices
Returns:
TradeConfig.ModeType


Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.