001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.samples.daytrader.session;
018    
019    import java.math.BigDecimal;
020    import java.rmi.RemoteException;
021    import java.util.Collection;
022    
023    import org.apache.geronimo.samples.daytrader.*;
024    import org.apache.geronimo.samples.daytrader.direct.TradeDirect;
025    import org.apache.geronimo.samples.daytrader.util.*;
026    
027    import javax.ejb.*;
028    
029    
030    public class TradeJDBCBean implements SessionBean {
031            private SessionContext context = null;
032            private TradeDirect tradeDirect = null;
033    
034            public TradeJDBCBean() {
035            }
036    
037            public void ejbCreate() throws CreateException {
038                    if (Log.doTrace())
039                            Log.trace("TradeJDBCBean:ejbCreate");
040            }
041    
042            public void ejbRemove() {
043                    try {
044                            if (Log.doTrace())
045                                    Log.trace("TradeJDBCBean:ejbRemove");
046                    } catch (Exception e) {
047                            Log.error(e, "Unable to close Queue or Topic connection on Session EJB remove");
048                    }
049            }
050    
051            public void ejbActivate() {
052            }
053    
054            public void ejbPassivate() {
055            }
056    
057            public void setSessionContext(SessionContext sc) {
058                    this.context = sc;
059            }
060    
061            public MarketSummaryDataBean getMarketSummary() throws Exception, RemoteException {
062                    return (new TradeDirect(true)).getMarketSummary();
063            }
064    
065    
066            public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode) throws Exception, RemoteException {
067                    return (new TradeDirect(true)).buy(userID, symbol, quantity, orderProcessingMode);
068            }
069    
070            public OrderDataBean sell(String userID, Integer holdingID, int orderProcessingMode) throws Exception, RemoteException {
071                    return (new TradeDirect(true)).sell(userID, holdingID, orderProcessingMode);
072            }
073    
074            public void queueOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
075                    (new TradeDirect(true)).queueOrder(orderID, twoPhase);
076            }
077    
078            public OrderDataBean completeOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
079                    return (new TradeDirect(true)).completeOrder(orderID, twoPhase);
080            }
081    
082            public void cancelOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
083                    (new TradeDirect(true)).cancelOrder(orderID, twoPhase);
084            }
085    
086            public void orderCompleted(String userID, Integer orderID) throws Exception, RemoteException {
087                    (new TradeDirect(true)).orderCompleted(userID, orderID);
088            }
089    
090            public Collection getOrders(String userID) throws Exception, RemoteException {
091                    return (new TradeDirect(true)).getOrders(userID);
092            }
093    
094            public Collection getClosedOrders(String userID) throws Exception, RemoteException {
095                    return (new TradeDirect(true)).getClosedOrders(userID);
096            }
097    
098            public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price) throws Exception, RemoteException {
099                    return (new TradeDirect(true)).createQuote(symbol, companyName, price);
100            }
101    
102            public QuoteDataBean getQuote(String symbol) throws Exception, RemoteException {
103                    return (new TradeDirect(true)).getQuote(symbol);
104            }
105    
106            public Collection getAllQuotes() throws Exception, RemoteException {
107                    return (new TradeDirect(true)).getAllQuotes();
108            }
109    
110            public QuoteDataBean updateQuotePriceVolume(String symbol, BigDecimal newPrice, double sharesTraded) throws Exception, RemoteException {
111                    return (new TradeDirect(true)).updateQuotePriceVolume(symbol, newPrice, sharesTraded);
112            }
113    
114            public Collection getHoldings(String userID) throws Exception, RemoteException {
115                    return (new TradeDirect(true)).getHoldings(userID);
116            }
117    
118            public HoldingDataBean getHolding(Integer holdingID) throws Exception, RemoteException {
119                    return (new TradeDirect(true)).getHolding(holdingID);
120            }
121    
122            public AccountDataBean getAccountData(String userID) throws javax.ejb.FinderException, Exception {
123                    return (new TradeDirect(true)).getAccountData(userID);
124            }
125    
126            public AccountProfileDataBean getAccountProfileData(String userID) throws Exception, RemoteException {
127                    return (new TradeDirect(true)).getAccountProfileData(userID);
128            }
129    
130            public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData) throws Exception, RemoteException {
131                    return (new TradeDirect(true)).updateAccountProfile(profileData);
132            }
133    
134            public AccountDataBean login(String userID, String password) throws Exception, RemoteException {
135                    return (new TradeDirect(true)).login(userID, password);
136            }
137    
138            public void logout(String userID) throws Exception, RemoteException {
139                    (new TradeDirect(true)).logout(userID);
140            }
141    
142            public AccountDataBean register(String userID, String password, String fullname, String address, String email, String creditcard, BigDecimal openBalance) throws Exception, RemoteException {
143                    return (new TradeDirect(true)).register(userID, password, fullname, address, email, creditcard, openBalance);
144            }
145    
146            public RunStatsDataBean resetTrade(boolean deleteAll) throws Exception, RemoteException {
147                    return (new TradeDirect(true)).resetTrade(deleteAll);
148            }
149    }