geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From viol...@apache.org
Subject svn commit: r1071543 [8/15] - in /geronimo/daytrader/trunk: ./ assemblies/javaee/ javaee6/ javaee6/assemblies/ javaee6/assemblies/daytrader-ear/ javaee6/assemblies/daytrader-ear/src/ javaee6/assemblies/daytrader-ear/src/main/ javaee6/assemblies/daytrad...
Date Thu, 17 Feb 2011 08:24:04 GMT
Added: geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeDirectContextListener.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeDirectContextListener.java?rev=1071543&view=auto
==============================================================================
--- geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeDirectContextListener.java (added)
+++ geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeDirectContextListener.java Thu Feb 17 08:23:57 2011
@@ -0,0 +1,41 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.daytrader.javaee6.web;
+
+import javax.servlet.*;
+import javax.servlet.annotation.WebListener;
+
+import org.apache.geronimo.daytrader.javaee6.core.direct.TradeJEEDirect;
+import org.apache.geronimo.daytrader.javaee6.utils.Log;
+
+@WebListener
+public class TradeDirectContextListener    implements ServletContextListener 
+{
+
+    //receieve trade web app startup/shutown events to start(initialized)/stop TradeJEEDirect
+    public void contextInitialized(ServletContextEvent event)
+    {
+        Log.trace("TradeDirectContextListener:contextInitialized - initializing TradeJEEDirect");        
+        TradeJEEDirect.init();
+    }
+    public void contextDestroyed(ServletContextEvent event)
+    {
+        Log.trace("TradeDirectContextListener:contextDestroyed - calling TradeJEEDirect:destroy()");        
+        TradeJEEDirect.destroy();
+    }
+
+}

Added: geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeJDBCContextListener.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeJDBCContextListener.java?rev=1071543&view=auto
==============================================================================
--- geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeJDBCContextListener.java (added)
+++ geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeJDBCContextListener.java Thu Feb 17 08:23:57 2011
@@ -0,0 +1,43 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.daytrader.javaee6.web;
+
+import javax.servlet.*;
+
+import javax.servlet.annotation.WebListener;
+
+import org.apache.geronimo.daytrader.javaee6.core.direct.TradeJDBCDirect;
+import org.apache.geronimo.daytrader.javaee6.utils.Log;
+
+@WebListener
+public class TradeJDBCContextListener
+    implements ServletContextListener 
+{
+
+    //receieve trade web app startup/shutown events to start(initialized)/stop TradeJDBCDirect
+    public void contextInitialized(ServletContextEvent event)
+    {
+        Log.trace("TradeJDBCContextListener:contextInitialized - initializing TradeJDBCDirect");
+        TradeJDBCDirect.init();
+    }
+    public void contextDestroyed(ServletContextEvent event)
+    {
+        Log.trace("TradeJDBCContextListener:contextDestroyed - calling TradeJDBCDirect:destroy()");        
+        TradeJDBCDirect.destroy();
+    }
+
+}

Added: geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeJPAContextListener.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeJPAContextListener.java?rev=1071543&view=auto
==============================================================================
--- geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeJPAContextListener.java (added)
+++ geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeJPAContextListener.java Thu Feb 17 08:23:57 2011
@@ -0,0 +1,42 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.daytrader.javaee6.web;
+
+import javax.servlet.*;
+
+import javax.servlet.annotation.WebListener;
+
+import org.apache.geronimo.daytrader.javaee6.core.direct.TradeJPADirect;
+import org.apache.geronimo.daytrader.javaee6.utils.Log;
+
+@WebListener
+public class TradeJPAContextListener implements ServletContextListener 
+{
+
+    //receieve trade web app startup/shutown events to start(initialized)/stop TradeJPADirect
+    public void contextInitialized(ServletContextEvent event)
+    {
+        Log.trace("TradeJPAContextListener:contextInitialized - initializing TradeJPADirect");
+        TradeJPADirect.init();
+    }
+    public void contextDestroyed(ServletContextEvent event)
+    {
+        Log.trace("TradeJPAContextListener:contextDestroyed - calling TradeJPADirect:destroy()");        
+        TradeJPADirect.destroy();
+    }
+
+}

Added: geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeScenarioServlet.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeScenarioServlet.java?rev=1071543&view=auto
==============================================================================
--- geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeScenarioServlet.java (added)
+++ geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeScenarioServlet.java Thu Feb 17 08:23:57 2011
@@ -0,0 +1,310 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.daytrader.javaee6.web;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.annotation.WebInitParam;
+
+import org.apache.geronimo.daytrader.javaee6.entities.HoldingDataBean;
+import org.apache.geronimo.daytrader.javaee6.utils.*;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * TradeScenarioServlet emulates a population of web users by generating a specific Trade operation 
+ * for a randomly chosen user on each access to the URL. Test this servlet by clicking Trade Scenario 
+ * and hit "Reload" on your browser to step through a Trade Scenario. To benchmark using this URL aim 
+ * your favorite web load generator (such as AKStress) at the Trade Scenario URL and fire away.
+ */
+@WebServlet(value = "/scenario", initParams = {
+        @WebInitParam(name = "runTimeMode", value = "Web JPA"),
+        @WebInitParam(name = "orderProcessingMode", value = "Synchronous"),
+        @WebInitParam(name = "accessMode", value = "Standard"),
+        @WebInitParam(name = "webServicesEndpoint", value = "http://localhost:8080/daytrader/services/TradeWSServices"),
+        @WebInitParam(name = "workloadMix", value = "Standard"),
+        @WebInitParam(name = "WebInterface", value = "JSP"),
+        @WebInitParam(name = "maxUsers", value = "200"),
+        @WebInitParam(name = "maxQuotes", value = "400"),
+        @WebInitParam(name = "primIterations", value = "1"),
+        @WebInitParam(name = "cachingType", value = "No Caching")})
+public class TradeScenarioServlet extends HttpServlet {
+
+   /**
+    * Servlet initialization method.
+    */
+    public void init(ServletConfig config) throws ServletException
+    {
+        super.init(config);
+        java.util.Enumeration en = config.getInitParameterNames();
+        while ( en.hasMoreElements() )
+        {
+            String parm = (String) en.nextElement();
+            String value = config.getInitParameter(parm);
+            TradeConfig.setConfigParam(parm, value);
+        }
+    }
+    
+   /**
+    * Returns a string that contains information about TradeScenarioServlet
+    *
+    * @return The servlet information
+    */
+    public java.lang.String getServletInfo()
+    {
+        return "TradeScenarioServlet emulates a population of web users";
+    }    
+
+
+
+   /**
+    * Process incoming HTTP GET requests
+    *
+    * @param request Object that encapsulates the request to the servlet
+    * @param response Object that encapsulates the response from the servlet
+    */
+    public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
+        throws ServletException, IOException
+    {
+        performTask(request,response);
+    }
+
+   /**
+    * Process incoming HTTP POST requests
+    *
+    * @param request Object that encapsulates the request to the servlet
+    * @param response Object that encapsulates the response from the servlet
+    */
+    public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
+        throws ServletException, IOException
+    {
+        performTask(request,response);
+    }    
+
+   /** 
+    * Main service method for TradeScenarioServlet
+    *
+    * @param request Object that encapsulates the request to the servlet
+    * @param response Object that encapsulates the response from the servlet
+    */    
+    public void performTask(HttpServletRequest req, HttpServletResponse resp)
+        throws ServletException, IOException {
+
+        // Scenario generator for Trade2
+        char action = ' ';
+        String userID = null;
+
+        // String to create full dispatch path to TradeAppServlet w/ request Parameters
+        String dispPath = null; // Dispatch Path to TradeAppServlet
+
+        String scenarioAction = (String) req.getParameter("action");
+        if ((scenarioAction != null) && (scenarioAction.length() >= 1))
+        {
+            action = scenarioAction.charAt(0);
+            if (action == 'n')
+            { //null;
+                try
+                {
+                    resp.setContentType("text/html");
+                    PrintWriter out = new PrintWriter(resp.getOutputStream());
+                    out.println("<HTML><HEAD>TradeScenarioServlet</HEAD><BODY>Hello</BODY></HTML>"); 
+                    out.close();
+                    return;
+    
+                }
+                catch (Exception e)
+                {
+                    Log.error(
+                        "trade_client.TradeScenarioServlet.service(...)" + 
+                        "error creating printwriter from responce.getOutputStream", e);
+                        
+                    resp.sendError(
+                            500, 
+                        "trade_client.TradeScenarioServlet.service(...): erorr creating and writing to PrintStream created from response.getOutputStream()"); 
+                } //end of catch
+    
+            } //end of action=='n'
+        }
+
+
+        ServletContext ctx = null;
+        HttpSession session = null;
+        try
+        {
+            ctx = getServletConfig().getServletContext();
+            // These operations require the user to be logged in. Verify the user and if not logged in
+            // change the operation to a login
+            session = req.getSession(true);
+            userID = (String) session.getAttribute("uidBean");
+        }
+        catch (Exception e)
+        {
+            Log.error(
+                "trade_client.TradeScenarioServlet.service(...): performing " + scenarioAction +
+                "error getting ServletContext,HttpSession, or UserID from session" +
+                "will make scenarioAction a login and try to recover from there", e);
+            userID = null;
+            action = 'l';
+        }
+
+        if (userID == null)
+        {
+            action = 'l'; // change to login
+            TradeConfig.incrementScenarioCount();
+        }
+        else if (action == ' ') {
+            //action is not specified perform a random operation according to current mix
+            // Tell getScenarioAction if we are an original user or a registered user 
+            // -- sellDeficits should only be compensated for with original users.
+            action = TradeConfig.getScenarioAction(
+                userID.startsWith(TradeConfig.newUserPrefix));
+        }    
+        switch (action)
+            {
+
+                case 'q' : //quote 
+                    dispPath = tasPathPrefix + "quotes&symbols=" + TradeConfig.rndSymbols();
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                    break;
+                case 'a' : //account
+                    dispPath = tasPathPrefix + "account";
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                    break;
+                case 'u' : //update account profile
+                    dispPath = tasPathPrefix + "account";
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+
+                    String fullName = "rnd" + System.currentTimeMillis();
+                    String address = "rndAddress";
+                    String   password = "xxx";
+                    String email = "rndEmail";
+                    String creditcard = "rndCC";
+                    dispPath = tasPathPrefix + "update_profile&fullname=" + fullName + 
+                        "&password=" + password + "&cpassword=" + password +                     
+                        "&address=" + address +    "&email=" + email + 
+                        "&creditcard=" +  creditcard;
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                    break;
+                case 'h' : //home
+                    dispPath = tasPathPrefix + "home";
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                    break;
+                case 'l' : //login
+                    userID = TradeConfig.getUserID();
+                    String password2 = "xxx";
+                    dispPath = tasPathPrefix + "login&inScenario=true&uid=" + userID + "&passwd=" + password2;
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                        
+                    // login is successful if the userID is written to the HTTP session
+                    if (session.getAttribute("uidBean") == null) {
+                        System.out.println("TradeScenario login failed. Reset DB between runs");
+                    } 
+                    break;
+                case 'o' : //logout
+                    dispPath = tasPathPrefix + "logout";
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                    break;
+                case 'p' : //portfolio
+                    dispPath = tasPathPrefix + "portfolio";
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                    break;
+                case 'r' : //register
+                    //Logout the current user to become a new user
+                    // see note in TradeServletAction
+                    req.setAttribute("TSS-RecreateSessionInLogout", Boolean.TRUE);
+                    dispPath = tasPathPrefix + "logout";
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+
+                    userID = TradeConfig.rndNewUserID();
+                    String passwd = "yyy";
+                    fullName = TradeConfig.rndFullName();
+                    creditcard = TradeConfig.rndCreditCard();
+                    String money = TradeConfig.rndBalance();
+                    email = TradeConfig.rndEmail(userID);
+                    String smail = TradeConfig.rndAddress();
+                    dispPath = tasPathPrefix + "register&Full Name=" + fullName + "&snail mail=" + smail +
+                        "&email=" + email + "&user id=" + userID + "&passwd=" + passwd + 
+                        "&confirm passwd=" + passwd + "&money=" + money + 
+                        "&Credit Card Number=" + creditcard;
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                    break;
+                case 's' : //sell
+                    dispPath = tasPathPrefix + "portfolioNoEdge";
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+
+                    Collection holdings = (Collection) req.getAttribute("holdingDataBeans");
+                    int numHoldings = holdings.size();
+                    if (numHoldings > 0)
+                    {
+                        //sell first available security out of holding 
+                        
+                        Iterator it = holdings.iterator();
+                        boolean foundHoldingToSell = false;
+                        while (it.hasNext()) 
+                        {
+                            HoldingDataBean holdingData = (HoldingDataBean) it.next();
+                            if ( !(holdingData.getPurchaseDate().equals(new java.util.Date(0)))  )
+                            {
+                                Integer holdingID = holdingData.getHoldingID();
+
+                                dispPath = tasPathPrefix + "sell&holdingID="+holdingID;
+                                ctx.getRequestDispatcher(dispPath).include(req, resp);
+                                foundHoldingToSell = true;
+                                break;    
+                            }
+                        }
+                        if (foundHoldingToSell) break;
+                        if (Log.doTrace())
+                            Log.trace("TradeScenario: No holding to sell -switch to buy -- userID = " + userID + "  Collection count = " + numHoldings);        
+
+                    }
+                    // At this point: A TradeScenario Sell was requested with No Stocks in Portfolio
+                    // This can happen when a new registered user happens to request a sell before a buy
+                    // In this case, fall through and perform a buy instead
+
+                    /* Trade 2.037: Added sell_deficit counter to maintain correct buy/sell mix.
+                     * When a users portfolio is reduced to 0 holdings, a buy is requested instead of a sell.
+                     * This throws off the buy/sell mix by 1. This results in unwanted holding table growth
+                     * To fix this we increment a sell deficit counter to maintain the correct ratio in getScenarioAction
+                     * The 'z' action from getScenario denotes that this is a sell action that was switched from a buy
+                     * to reduce a sellDeficit
+                     */
+                    if (userID.startsWith(TradeConfig.newUserPrefix) == false)
+                    {
+                        TradeConfig.incrementSellDeficit();
+                    }
+                case 'b' : //buy
+                    String symbol = TradeConfig.rndSymbol();
+                    String amount = TradeConfig.rndQuantity() + "";
+
+                    dispPath = tasPathPrefix + "quotes&symbols=" + symbol;
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+
+                    dispPath = tasPathPrefix + "buy&quantity=" + amount + "&symbol=" + symbol;
+                    ctx.getRequestDispatcher(dispPath).include(req, resp);
+                    break;
+            } //end of switch statement 
+    }
+
+    // URL Path Prefix for dispatching to TradeAppServlet
+    private final static String tasPathPrefix = "/app?action=";
+
+}

Added: geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeServletAction.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeServletAction.java?rev=1071543&view=auto
==============================================================================
--- geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeServletAction.java (added)
+++ geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/TradeServletAction.java Thu Feb 17 08:23:57 2011
@@ -0,0 +1,775 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.daytrader.javaee6.web;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.geronimo.daytrader.javaee6.core.api.TradeServices;
+import org.apache.geronimo.daytrader.javaee6.core.direct.TradeAction;
+import org.apache.geronimo.daytrader.javaee6.entities.*;
+import org.apache.geronimo.daytrader.javaee6.utils.*;
+
+
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.math.BigDecimal;
+
+
+/**
+ * TradeServletAction provides servlet specific client side access to each of
+ * the Trade brokerage user operations. These include login, logout, buy, sell,
+ * getQuote, etc. TradeServletAction manages a web interface to Trade handling
+ * HttpRequests/HttpResponse objects and forwarding results to the appropriate
+ * JSP page for the web interface. TradeServletAction invokes
+ * {@link TradeAction} methods to actually perform each trading operation.
+ * 
+ */
+public class TradeServletAction {
+
+    private TradeServices tAction = null;
+
+    TradeServletAction() {
+        if (TradeConfig.getAccessMode() == TradeConfig.STANDARD) {
+            tAction = new TradeAction();
+        } else if (TradeConfig.getAccessMode() == TradeConfig.WEBSERVICES) {             
+            //Disable SOAP
+            //tAction = (TradeServices) new TradeWebSoapProxy();
+        } else {
+            throw new IllegalArgumentException(
+                "TradeServletAction - Uknown TradeConfig accessMode=" +
+                TradeConfig.getAccessMode());
+        }
+    }
+
+    /**
+     * Display User Profile information such as address, email, etc. for the
+     * given Trader Dispatch to the Trade Account JSP for display
+     * 
+     * @param userID
+     *            The User to display profile info
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @param results
+     *            A short description of the results/success of this web request
+     *            provided on the web page
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doAccount(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String results)
+            throws javax.servlet.ServletException, java.io.IOException {
+        try {
+
+            AccountDataBean accountData = tAction.getAccountData(userID);
+            AccountProfileDataBean accountProfileData = tAction
+                    .getAccountProfileData(userID);
+            ArrayList orderDataBeans = (TradeConfig.getLongRun() ? new ArrayList() : (ArrayList) tAction.getOrders(userID));
+            
+            req.setAttribute("accountData", accountData);
+            req.setAttribute("accountProfileData", accountProfileData);
+            req.setAttribute("orderDataBeans", orderDataBeans);
+            req.setAttribute("results", results);
+            requestDispatch(ctx, req, resp, userID, TradeConfig
+                    .getPage(TradeConfig.ACCOUNT_PAGE));
+        } catch (java.lang.IllegalArgumentException e) { // this is a user
+                                                            // error so I will
+            // forward them to another page rather than throw a 500
+            req.setAttribute("results", results
+                    + "could not find account for userID = " + userID);
+            requestDispatch(ctx, req, resp, userID, TradeConfig
+                    .getPage(TradeConfig.HOME_PAGE));
+            // log the exception with an error level of 3 which means, handled
+            // exception but would invalidate a automation run
+            Log.error(
+                            "TradeServletAction.doAccount(...)",
+                            "illegal argument, information should be in exception string",
+                            e);
+        } catch (Exception e) {
+            // log the exception with error page
+            throw new ServletException("TradeServletAction.doAccount(...)"
+                    + " exception user =" + userID, e);
+        }
+
+    }
+
+    /**
+     * Update User Profile information such as address, email, etc. for the
+     * given Trader Dispatch to the Trade Account JSP for display If any in put
+     * is incorrect revert back to the account page w/ an appropriate message
+     * 
+     * @param userID
+     *            The User to upddate profile info
+     * @param password
+     *            The new User password
+     * @param cpassword
+     *            Confirm password
+     * @param fullname
+     *            The new User fullname info
+     * @param address
+     *            The new User address info
+     * @param cc
+     *            The new User credit card info
+     * @param email
+     *            The new User email info
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doAccountUpdate(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String password,
+            String cpassword, String fullName, String address,
+            String creditcard, String email)
+            throws javax.servlet.ServletException, java.io.IOException {
+        String results = "";
+
+        // First verify input data
+        boolean doUpdate = true;
+        if (password.equals(cpassword) == false) {
+            results = "Update profile error: passwords do not match";
+            doUpdate = false;
+        } else if (password.length() <= 0 || fullName.length() <= 0
+                || address.length() <= 0 || creditcard.length() <= 0
+                || email.length() <= 0) {
+            results = "Update profile error: please fill in all profile information fields";
+            doUpdate = false;
+        }
+        AccountProfileDataBean accountProfileData = new AccountProfileDataBean(
+                userID, password, fullName, address, email, creditcard);
+        try {
+            if (doUpdate) {
+                accountProfileData = tAction
+                        .updateAccountProfile(accountProfileData);
+                results = "Account profile update successful";
+            }
+
+        } catch (java.lang.IllegalArgumentException e) { // this is a user
+                                                            // error so I will
+            // forward them to another page rather than throw a 500
+            req
+                    .setAttribute(
+                            "results",
+                            results
+                                    + "invalid argument, check userID is correct, and the database is populated"
+                                    + userID);
+            Log
+                    .error(
+                            e,
+                            "TradeServletAction.doAccount(...)",
+                            "illegal argument, information should be in exception string",
+                            "treating this as a user error and forwarding on to a new page");
+        } catch (Exception e) {
+            // log the exception with error page
+            throw new ServletException(
+                    "TradeServletAction.doAccountUpdate(...)"
+                            + " exception user =" + userID, e);
+        }
+        doAccount(ctx, req, resp, userID, results);
+    }
+
+    /**
+     * Buy a new holding of shares for the given trader Dispatch to the Trade
+     * Portfolio JSP for display
+     * 
+     * @param userID
+     *            The User buying shares
+     * @param symbol
+     *            The stock to purchase
+     * @param amount
+     *            The quantity of shares to purchase
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doBuy(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String symbol,
+            String quantity) throws ServletException, IOException {
+
+        String results = "";
+
+        try {
+            OrderDataBean orderData = tAction.buy(userID, symbol, new Double(
+                    quantity).doubleValue(), TradeConfig.orderProcessingMode);
+
+            req.setAttribute("orderData", orderData);
+            req.setAttribute("results", results);
+        } catch (java.lang.IllegalArgumentException e) { // this is a user
+                                                            // error so I will
+            // forward them to another page rather than throw a 500
+            req.setAttribute("results", results + "illegal argument:");
+            requestDispatch(ctx, req, resp, userID, TradeConfig
+                    .getPage(TradeConfig.HOME_PAGE));
+            // log the exception with an error level of 3 which means, handled
+            // exception but would invalidate a automation run
+            Log.error(e, "TradeServletAction.doBuy(...)",
+                    "illegal argument. userID = " + userID, "symbol = "
+                            + symbol);
+        } catch (Exception e) {
+            // log the exception with error page
+            throw new ServletException("TradeServletAction.buy(...)"
+                    + " exception buying stock " + symbol + " for user "
+                    + userID, e);
+        }
+        requestDispatch(ctx, req, resp, userID, TradeConfig
+                .getPage(TradeConfig.ORDER_PAGE));
+    }
+
+    /**
+     * Create the Trade Home page with personalized information such as the
+     * traders account balance Dispatch to the Trade Home JSP for display
+     * 
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @param results
+     *            A short description of the results/success of this web request
+     *            provided on the web page
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doHome(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String results)
+            throws javax.servlet.ServletException, java.io.IOException {
+        
+        BigDecimal balance;
+        String result = "";
+        
+        try {
+            AccountDataBean accountData = tAction.getAccountData(userID);
+            Collection<HoldingDataBean> holdingDataBeans = tAction.getHoldings(userID);
+
+            // Edge Caching:
+            // Getting the MarketSummary has been moved to the JSP
+            // MarketSummary.jsp. This makes the MarketSummary a
+            // standalone "fragment", and thus is a candidate for
+            // Edge caching.
+            // marketSummaryData = tAction.getMarketSummary();
+
+            req.setAttribute("accountData", accountData);
+            req.setAttribute("holdingDataBeans", holdingDataBeans);
+            // See Edge Caching above
+            // req.setAttribute("marketSummaryData", marketSummaryData);
+            req.setAttribute("results", results);
+        } catch (java.lang.IllegalArgumentException e) { 
+            // this is a user error so I will
+            // forward them to another page rather than throw a 500
+            req.setAttribute("results", results + "check userID = " + userID
+                + " and that the database is populated");
+            requestDispatch(ctx, req, resp, userID, TradeConfig
+                .getPage(TradeConfig.HOME_PAGE));
+            // log the exception with an error level of 3 which means, handled
+            // exception but would invalidate a automation run
+            Log.error("TradeServletAction.doHome(...)"
+                + "illegal argument, information should be in exception string"
+                + "treating this as a user error and forwarding on to a new page",
+                e);
+        // } catch (javax.ejb.FinderException e) {
+            // moved to below
+        } catch (Exception e) {
+            boolean javaee = false;
+            // since we will not have the EJB Spec for non-JavaEE containers,
+            // lets try to handle the expected exception logic, where for
+            // JavaEE we should catch a javax.ejb.FinderException while
+            // for non-JavaEE we should catch a RuntimeException
+            try {
+                Class c = Class.forName("javax.ejb.FinderException");
+                javaee = true;
+                if ((c != null) && (e instanceof javax.ejb.FinderException)) { // JavaEE container
+                    // this is a user error so I will
+                    // forward them to another page rather than throw a 500
+                    req.setAttribute("results", results
+                        + "\nCould not find account for + " + userID);
+                    // requestDispatch(ctx, req, resp,
+                    // TradeConfig.getPage(TradeConfig.HOME_PAGE));
+                    // log the exception with an error level of 3 which means, handled
+                    // exception but would invalidate a automation run
+                    Log.error("TradeServletAction.doHome(...)"
+                        + "Error finding account for user "
+                        + userID
+                        + "treating this as a user error and forwarding on to a new page",
+                        e);
+                }
+            } catch (ClassNotFoundException cnne) {
+                // ignore, for the non-JavaEE web-only assemblies
+            }
+            
+            if (!javaee && (e instanceof RuntimeException)) {   // non-JavaEE container
+                // this is a user error so I will
+                // forward them to another page rather than throw a 500
+                req.setAttribute("results", results
+                    + "\nCould not find account for + " + userID);
+                // requestDispatch(ctx, req, resp,
+                // TradeConfig.getPage(TradeConfig.HOME_PAGE));
+                // log the exception with an error level of 3 which means, handled
+                // exception but would invalidate a automation run
+                Log.error("TradeServletAction.doHome(...)"
+                    + "Error finding account for user "
+                    + userID
+                    + "treating this as a user error and forwarding on to a new page",
+                    e);                
+            } else {
+                // log the exception with error page
+                throw new ServletException("TradeServletAction.doHome(...)"
+                    + " exception user =" + userID, e);
+            }
+        }
+
+        requestDispatch(ctx, req, resp, userID, TradeConfig
+                .getPage(TradeConfig.HOME_PAGE));
+    }
+
+    /**
+     * Login a Trade User. Dispatch to the Trade Home JSP for display
+     * 
+     * @param userID
+     *            The User to login
+     * @param passwd
+     *            The password supplied by the trader used to authenticate
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @param results
+     *            A short description of the results/success of this web request
+     *            provided on the web page
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doLogin(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String passwd)
+            throws javax.servlet.ServletException, java.io.IOException {
+
+        String results = "";
+        try {
+            // Got a valid userID and passwd, attempt login
+
+            AccountDataBean accountData = tAction.login(userID, passwd);
+
+            if (accountData != null) {
+                HttpSession session = req.getSession(true);
+                session.setAttribute("uidBean", userID);
+                session.setAttribute("sessionCreationDate",
+                        new java.util.Date());
+                results = "Ready to Trade";
+                doHome(ctx, req, resp, userID, results);
+                return;
+            } else {
+                req.setAttribute("results", results
+                        + "\nCould not find account for user=" + userID);
+                // log the exception with an error level of 3 which means,
+                // handled exception but would invalidate a automation run
+                Log.log(
+                                "TradeServletAction.doLogin(...)",
+                                "Error finding account for user " + userID + "",
+                                "user entered a bad username or the database is not populated");
+                throw new NullPointerException("User does not exist or password is incorrect!");
+            }
+        } catch (java.lang.IllegalArgumentException e) { // this is a user
+                                                            // error so I will
+            // forward them to another page rather than throw a 500
+            req.setAttribute("results", results + "illegal argument:"
+                    + e.getMessage());
+            // log the exception with an error level of 3 which means, handled
+            // exception but would invalidate a automation run
+            Log
+                    .error(
+                            e,
+                            "TradeServletAction.doLogin(...)",
+                            "illegal argument, information should be in exception string",
+                            "treating this as a user error and forwarding on to a new page");
+
+        } catch (Exception e) {
+            // log the exception with error page
+            throw new ServletException("TradeServletAction.doLogin(...)"
+                    + "Exception logging in user=" + userID + " with password="
+                    + passwd + "; " + e.getMessage(), e);
+        }
+
+        requestDispatch(ctx, req, resp, userID, TradeConfig
+                .getPage(TradeConfig.WELCOME_PAGE));
+
+    }
+
+    /**
+     * Logout a Trade User Dispatch to the Trade Welcome JSP for display
+     * 
+     * @param userID
+     *            The User to logout
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @param results
+     *            A short description of the results/success of this web request
+     *            provided on the web page
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doLogout(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID) throws ServletException,
+            IOException {
+        String results = "";
+
+        try {
+            tAction.logout(userID);
+
+        } catch (java.lang.IllegalArgumentException e) { // this is a user
+                                                            // error so I will
+            // forward them to another page, at the end of the page.
+            req.setAttribute("results", results + "illegal argument:"
+                    + e.getMessage());
+
+            // log the exception with an error level of 3 which means, handled
+            // exception but would invalidate a automation run
+            Log
+                    .error(
+                            e,
+                            "TradeServletAction.doLogout(...)",
+                            "illegal argument, information should be in exception string",
+                            "treating this as a user error and forwarding on to a new page");
+        } catch (Exception e) {
+            // log the exception and foward to a error page
+            Log.error(e, "TradeServletAction.doLogout(...):",
+                    "Error logging out" + userID, "fowarding to an error page");
+            // set the status_code to 500
+            throw new ServletException("TradeServletAction.doLogout(...)"
+                    + "exception logging out user " + userID, e);
+        }
+        HttpSession session = req.getSession();
+        if (session != null) {
+            session.invalidate();
+        }
+
+        Object o = req.getAttribute("TSS-RecreateSessionInLogout");
+        if (o != null && ((Boolean) o).equals(Boolean.TRUE)) {
+            // Recreate Session object before writing output to the response
+            // Once the response headers are written back to the client the
+            // opportunity
+            // to create a new session in this request may be lost
+            // This is to handle only the TradeScenarioServlet case
+            session = req.getSession(true);
+        }
+        requestDispatch(ctx, req, resp, userID, TradeConfig
+                .getPage(TradeConfig.WELCOME_PAGE));
+    }
+
+    /**
+     * Retrieve the current portfolio of stock holdings for the given trader
+     * Dispatch to the Trade Portfolio JSP for display
+     * 
+     * @param userID
+     *            The User requesting to view their portfolio
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @param results
+     *            A short description of the results/success of this web request
+     *            provided on the web page
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doPortfolio(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String results)
+            throws ServletException, IOException {
+
+        try {
+            // Get the holdiings for this user
+
+            Collection quoteDataBeans = new ArrayList();
+            Collection holdingDataBeans = tAction.getHoldings(userID);
+
+            // Walk through the collection of user
+            // holdings and creating a list of quotes
+            if (holdingDataBeans.size() > 0) {
+
+                Iterator it = holdingDataBeans.iterator();
+                while (it.hasNext()) {
+                    HoldingDataBean holdingData = (HoldingDataBean) it.next();
+                    QuoteDataBean quoteData = tAction.getQuote(holdingData
+                            .getQuoteID());
+                    quoteDataBeans.add(quoteData);
+                }
+            } else {
+                results = results + ".  Your portfolio is empty.";
+            }
+            req.setAttribute("results", results);
+            req.setAttribute("holdingDataBeans", holdingDataBeans);
+            req.setAttribute("quoteDataBeans", quoteDataBeans);
+            requestDispatch(ctx, req, resp, userID, TradeConfig
+                    .getPage(TradeConfig.PORTFOLIO_PAGE));
+        } catch (java.lang.IllegalArgumentException e) { // this is a user
+                                                            // error so I will
+            // forward them to another page rather than throw a 500
+            req.setAttribute("results", results + "illegal argument:"
+                    + e.getMessage());
+            requestDispatch(ctx, req, resp, userID, TradeConfig
+                    .getPage(TradeConfig.PORTFOLIO_PAGE));
+            // log the exception with an error level of 3 which means, handled
+            // exception but would invalidate a automation run
+            Log
+                    .error(
+                            e,
+                            "TradeServletAction.doPortfolio(...)",
+                            "illegal argument, information should be in exception string",
+                            "user error");
+        } catch (Exception e) {
+            // log the exception with error page
+            throw new ServletException("TradeServletAction.doPortfolio(...)"
+                    + " exception user =" + userID, e);
+        }
+    }
+
+    /**
+     * Retrieve the current Quote for the given stock symbol Dispatch to the
+     * Trade Quote JSP for display
+     * 
+     * @param userID
+     *            The stock symbol used to get the current quote
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doQuotes(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String symbols)
+            throws ServletException, IOException {
+        String results = "";
+
+        // Edge Caching:
+        // Getting Quotes has been moved to the JSP
+        // Quote.jsp. This makes each Quote a
+        // standalone "fragment", and thus is a candidate for
+        // Edge caching.
+        //            
+
+        requestDispatch(ctx, req, resp, userID, TradeConfig
+                .getPage(TradeConfig.QUOTE_PAGE));
+    }
+
+    /**
+     * Register a new trader given the provided user Profile information such as
+     * address, email, etc. Dispatch to the Trade Home JSP for display
+     * 
+     * @param userID
+     *            The User to create
+     * @param passwd
+     *            The User password
+     * @param fullname
+     *            The new User fullname info
+     * @param ccn
+     *            The new User credit card info
+     * @param money
+     *            The new User opening account balance
+     * @param address
+     *            The new User address info
+     * @param email
+     *            The new User email info
+     * @return The userID of the new trader
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doRegister(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String passwd,
+            String cpasswd, String fullname, String ccn,
+            String openBalanceString, String email, String address)
+            throws ServletException, IOException {
+        String results = "";
+
+        try {
+            // Validate user passwords match and are atleast 1 char in length
+            if ((passwd.equals(cpasswd)) && (passwd.length() >= 1)) {
+
+                AccountDataBean accountData = tAction.register(userID, passwd,
+                        fullname, address, email, ccn, new BigDecimal(
+                                openBalanceString));
+                if (accountData == null) {
+                    results = "Registration operation failed;";
+                    System.out.println(results);
+                    req.setAttribute("results", results);
+                    requestDispatch(ctx, req, resp, userID, TradeConfig
+                            .getPage(TradeConfig.REGISTER_PAGE));
+                } else {
+                    doLogin(ctx, req, resp, userID, passwd);
+                    results = "Registration operation succeeded;  Account "
+                            + accountData.getAccountID() + " has been created.";
+                    req.setAttribute("results", results);
+
+                }
+            } else {
+                // Password validation failed
+                results = "Registration operation failed, your passwords did not match";
+                System.out.println(results);
+                req.setAttribute("results", results);
+                requestDispatch(ctx, req, resp, userID, TradeConfig
+                        .getPage(TradeConfig.REGISTER_PAGE));
+            }
+
+        } catch (Exception e) {
+            // log the exception with error page
+            throw new ServletException("TradeServletAction.doRegister(...)"
+                    + " exception user =" + userID, e);
+        }
+    }
+
+    /**
+     * Sell a current holding of stock shares for the given trader. Dispatch to
+     * the Trade Portfolio JSP for display
+     * 
+     * @param userID
+     *            The User buying shares
+     * @param symbol
+     *            The stock to sell
+     * @param indx
+     *            The unique index identifying the users holding to sell
+     * @param ctx
+     *            the servlet context
+     * @param req
+     *            the HttpRequest object
+     * @param resp
+     *            the HttpResponse object
+     * @exception javax.servlet.ServletException
+     *                If a servlet specific exception is encountered
+     * @exception javax.io.IOException
+     *                If an exception occurs while writing results back to the
+     *                user
+     * 
+     */
+    void doSell(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, Integer holdingID)
+            throws ServletException, IOException {
+        String results = "";
+        try {
+            OrderDataBean orderData = tAction.sell(userID, holdingID,
+                    TradeConfig.orderProcessingMode);
+
+            req.setAttribute("orderData", orderData);
+            req.setAttribute("results", results);
+        } catch (java.lang.IllegalArgumentException e) { // this is a user
+                                                            // error so I will
+            // just log the exception and then later on I will redisplay the
+            // portfolio page
+            // because this is just a user exception
+            Log
+                    .error(
+                            e,
+                            "TradeServletAction.doSell(...)",
+                            "illegal argument, information should be in exception string",
+                            "user error");
+        } catch (Exception e) {
+            // log the exception with error page
+            throw new ServletException("TradeServletAction.doSell(...)"
+                    + " exception selling holding " + holdingID + " for user ="
+                    + userID, e);
+        }
+        requestDispatch(ctx, req, resp, userID, TradeConfig
+                .getPage(TradeConfig.ORDER_PAGE));
+    }
+
+    void doWelcome(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String status) throws ServletException,
+            IOException {
+
+        req.setAttribute("results", status);
+        requestDispatch(ctx, req, resp, null, TradeConfig
+                .getPage(TradeConfig.WELCOME_PAGE));
+    }
+
+    private void requestDispatch(ServletContext ctx, HttpServletRequest req,
+            HttpServletResponse resp, String userID, String page)
+            throws ServletException, IOException {
+
+        ctx.getRequestDispatcher(page).include(req, resp);
+    }
+
+    private void sendRedirect(HttpServletResponse resp, String page)
+            throws ServletException, IOException {
+        resp.sendRedirect(resp.encodeRedirectURL(page));
+    }
+}

Added: geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBBean.java?rev=1071543&view=auto
==============================================================================
--- geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBBean.java (added)
+++ geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBBean.java Thu Feb 17 08:23:57 2011
@@ -0,0 +1,127 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.daytrader.javaee6.web.ejb3;
+
+import org.apache.geronimo.daytrader.javaee6.entities.*;
+import org.apache.geronimo.daytrader.javaee6.core.beans.RunStatsDataBean;
+import org.apache.geronimo.daytrader.javaee6.core.beans.MarketSummaryDataBean;
+import org.apache.geronimo.daytrader.javaee6.core.direct.TradeJEEDirect;
+
+import java.math.BigDecimal;
+import java.util.Collection;
+import javax.ejb.*;
+
+
+@Stateless
+@TransactionAttribute(TransactionAttributeType.REQUIRED)
+@TransactionManagement(TransactionManagementType.CONTAINER)
+public class DirectSLSBBean implements DirectSLSBRemote, DirectSLSBLocal {
+
+    public DirectSLSBBean() {
+    }
+
+    public MarketSummaryDataBean getMarketSummary() throws Exception {
+        return (new TradeJEEDirect(true)).getMarketSummary();
+    }
+
+
+    public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode) throws Exception {
+        return (new TradeJEEDirect(true)).buy(userID, symbol, quantity, orderProcessingMode);
+    }
+
+    public OrderDataBean sell(String userID, Integer holdingID, int orderProcessingMode) throws Exception {
+        return (new TradeJEEDirect(true)).sell(userID, holdingID, orderProcessingMode);
+    }
+
+    public void queueOrder(Integer orderID, boolean twoPhase) throws Exception {
+        (new TradeJEEDirect(true)).queueOrder(orderID, twoPhase);
+    }
+
+    public OrderDataBean completeOrder(Integer orderID, boolean twoPhase) throws Exception {
+        return (new TradeJEEDirect(true)).completeOrder(orderID, twoPhase);
+    }
+
+    public void cancelOrder(Integer orderID, boolean twoPhase) throws Exception {
+        (new TradeJEEDirect(true)).cancelOrder(orderID, twoPhase);
+    }
+
+    public void orderCompleted(String userID, Integer orderID) throws Exception {
+        (new TradeJEEDirect(true)).orderCompleted(userID, orderID);
+    }
+
+    public Collection getOrders(String userID) throws Exception {
+        return (new TradeJEEDirect(true)).getOrders(userID);
+    }
+
+    public Collection getClosedOrders(String userID) throws Exception {
+        return (new TradeJEEDirect(true)).getClosedOrders(userID);
+    }
+
+    public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price) throws Exception {
+        return (new TradeJEEDirect(true)).createQuote(symbol, companyName, price);
+    }
+
+    public QuoteDataBean getQuote(String symbol) throws Exception {
+        return (new TradeJEEDirect(true)).getQuote(symbol);
+    }
+
+    public Collection getAllQuotes() throws Exception {
+        return (new TradeJEEDirect(true)).getAllQuotes();
+    }
+
+    public QuoteDataBean updateQuotePriceVolume(String symbol, BigDecimal newPrice, double sharesTraded) throws Exception {
+        return (new TradeJEEDirect(true)).updateQuotePriceVolume(symbol, newPrice, sharesTraded);
+    }
+
+    public Collection getHoldings(String userID) throws Exception {
+        return (new TradeJEEDirect(true)).getHoldings(userID);
+    }
+
+    public HoldingDataBean getHolding(Integer holdingID) throws Exception {
+        return (new TradeJEEDirect(true)).getHolding(holdingID);
+    }
+
+    public AccountDataBean getAccountData(String userID) throws Exception {
+        return (new TradeJEEDirect(true)).getAccountData(userID);
+    }
+
+    public AccountProfileDataBean getAccountProfileData(String userID) throws Exception {
+        return (new TradeJEEDirect(true)).getAccountProfileData(userID);
+    }
+
+    public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData) throws Exception {
+        return (new TradeJEEDirect(true)).updateAccountProfile(profileData);
+    }
+
+    public AccountDataBean login(String userID, String password) throws Exception {
+        return (new TradeJEEDirect(true)).login(userID, password);
+    }
+
+    public void logout(String userID) throws Exception {
+        (new TradeJEEDirect(true)).logout(userID);
+    }
+
+    public AccountDataBean register(String userID, String password, String fullname, String address, String email, String creditcard, BigDecimal openBalance) throws Exception {
+        return (new TradeJEEDirect(true)).register(userID, password, fullname, address, email, creditcard, openBalance);
+    }
+
+    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+    public RunStatsDataBean resetTrade(boolean deleteAll) throws Exception {
+        return (new TradeJEEDirect(false)).resetTrade(deleteAll);
+    }
+}

Added: geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBLocal.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBLocal.java?rev=1071543&view=auto
==============================================================================
--- geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBLocal.java (added)
+++ geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBLocal.java Thu Feb 17 08:23:57 2011
@@ -0,0 +1,26 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.daytrader.javaee6.web.ejb3;
+
+import javax.ejb.Local;
+import org.apache.geronimo.daytrader.javaee6.core.api.TradeServices;
+
+@Local
+public interface DirectSLSBLocal extends TradeServices {
+}
+

Added: geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBRemote.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBRemote.java?rev=1071543&view=auto
==============================================================================
--- geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBRemote.java (added)
+++ geronimo/daytrader/trunk/javaee6/modules/web/src/main/java/org/apache/geronimo/daytrader/javaee6/web/ejb3/DirectSLSBRemote.java Thu Feb 17 08:23:57 2011
@@ -0,0 +1,26 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.daytrader.javaee6.web.ejb3;
+
+import javax.ejb.Remote;
+import org.apache.geronimo.daytrader.javaee6.core.api.TradeServices;
+
+@Remote
+public interface DirectSLSBRemote extends TradeServices {
+}
+



Mime
View raw message