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.ejb;
018    
019    import javax.ejb.EJBObject;
020    import java.rmi.Remote;
021    import java.rmi.RemoteException;
022    
023    import org.apache.geronimo.samples.daytrader.*;
024    
025    public interface Trade extends EJBObject, TradeServices, Remote {
026    
027       /**
028             * Queue the Order identified by orderID to be processed in a One Phase commit
029             * 
030             * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
031             * 2-phase commit transaction across Entity and MDB access
032             * 
033             * Orders are submitted through JMS to a Trading Broker
034             * and completed asynchronously. This method queues the order for processing
035             *
036             * @param orderID the Order being queued for processing
037             * @return OrderDataBean providing the status of the completed order
038             */
039            public void queueOrderOnePhase(Integer orderID) throws RemoteException;
040       /**
041             * Complete the Order identified by orderID in a One Phase commit
042             * 
043             * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
044             * 2-phase commit transaction across Entity and MDB access
045             * 
046             * Orders are submitted through JMS to a Trading agent
047             * and completed asynchronously. This method completes the order
048             * For a buy, the stock is purchased creating a holding and the users account is debited
049             * For a sell, the stock holding is removed and the users account is credited with the proceeds
050             *
051             * @param orderID the Order to complete
052             * @return OrderDataBean providing the status of the completed order
053             */
054            public OrderDataBean completeOrderOnePhase(Integer orderID) throws RemoteException;
055            
056       /**
057             * Complete the Order identified by orderID in a One Phase commit
058             * using TradeDirect to complete the Order
059             * 
060             * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
061             * 2-phase commit transaction across DB and MDB access
062             * The EJB method is used only to start a new transaction so the direct runtime mode
063             * for the completeOrder will run in a 1-phase commit
064             * 
065             * Orders are submitted through JMS to a Trading agent
066             * and completed asynchronously. This method completes the order using TradeDirect
067             * For a buy, the stock is purchased creating a holding and the users account is debited
068             * For a sell, the stock holding is removed and the users account is credited with the proceeds
069             *
070             * @param orderID the Order to complete
071             * @return OrderDataBean providing the status of the completed order
072             */     
073        public OrderDataBean completeOrderOnePhaseDirect(Integer orderID) throws RemoteException;
074    
075       /**
076             * Cancel the Order identefied by orderID
077             * 
078             * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
079             * 2-phase commit transaction across Entity and MDB access
080             * 
081             * The boolean twoPhase specifies to the server implementation whether or not the
082             * method is to participate in a global transaction
083             *
084             * @param orderID the Order to complete
085             * @return OrderDataBean providing the status of the completed order
086             */
087            public void cancelOrderOnePhase(Integer orderID) throws RemoteException;
088    
089       /**
090             * Cancel the Order identefied by orderID
091             * using TradeDirect to complete the Order
092             * 
093             * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
094             * 2-phase commit transaction across DB and MDB access
095             * The EJB method is used only to start a new transaction so the direct runtime mode
096             * for the cancleOrder will run in a 1-phase commit
097             * 
098             * The boolean twoPhase specifies to the server implementation whether or not the
099             * method is to participate in a global transaction
100             *
101             * @param orderID the Order to complete
102             * @return OrderDataBean providing the status of the completed order
103             */
104            public void cancelOrderOnePhaseDirect(Integer orderID) throws RemoteException;
105            
106       /**
107             * Publish to the QuoteChange Message topic when a stock
108             * price and volume are updated
109             * 
110             * This method is deployed as TXN REQUIRES NEW to avoid a 
111             * 2-phase commit transaction across the DB update and MDB access
112             * (i.e. a failure to publish will not cause the stock update to fail
113             *
114             * @param quoteData - the updated Quote
115             * @param oldPrice - the price of the Quote before the update
116             * @param sharesTraded - the quantity of sharesTraded
117             */
118            public void publishQuotePriceChange(QuoteDataBean quoteData, java.math.BigDecimal oldPrice, java.math.BigDecimal changeFactor,  double sharesTraded) throws RemoteException;
119            
120            /**
121             * provides a simple session method with no database access to test performance of a simple
122             * path through a stateless session 
123             * @param investment amount
124             * @param NetValue current value
125             * @return return on investment as a percentage
126             */
127            public double investmentReturn(double investment, double NetValue) throws RemoteException;      
128    
129            /**
130             * This method provides a ping test for a 2-phase commit operation
131             * 
132             * @param symbol to lookup
133             * @return quoteData after sending JMS message
134             */     
135            public QuoteDataBean pingTwoPhase(String symbol) throws RemoteException;
136    
137    }