geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r810185 - in /geronimo/daytrader/trunk: assemblies/javaee/daytrader-war/src/main/webapp/ assemblies/web/daytrader-web-jdbc/src/main/webapp/ assemblies/web/daytrader-web-jdbc/src/main/webapp/dbscripts/other/ modules/core/src/main/java/org/ap...
Date Tue, 01 Sep 2009 19:22:31 GMT
Author: dwoods
Date: Tue Sep  1 19:22:30 2009
New Revision: 810185

URL: http://svn.apache.org/viewvc?rev=810185&view=rev
Log:
daytrader-web-jdbc is now working (was daytrader-web-only which is JDBC Direct w/o JMS or a TxMgr)

Added:
    geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/dbscripts/other/
    geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/dbscripts/other/Table.ddl
    geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeDBServices.java   (with props)
Modified:
    geronimo/daytrader/trunk/assemblies/javaee/daytrader-war/src/main/webapp/config.jsp
    geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/config.jsp
    geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java
    geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeServices.java
    geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJDBCDirect.java
    geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java
    geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJPADirect.java
    geronimo/daytrader/trunk/modules/ejb3/src/main/java/org/apache/geronimo/samples/daytrader/ejb3/TradeSLSBBean.java
    geronimo/daytrader/trunk/modules/util/src/main/java/org/apache/geronimo/samples/daytrader/util/TradeConfig.java
    geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java
    geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeConfigServlet.java
    geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java
    geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBQueue.java
    geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBTopic.java

Modified: geronimo/daytrader/trunk/assemblies/javaee/daytrader-war/src/main/webapp/config.jsp
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/assemblies/javaee/daytrader-war/src/main/webapp/config.jsp?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/assemblies/javaee/daytrader-war/src/main/webapp/config.jsp (original)
+++ geronimo/daytrader/trunk/assemblies/javaee/daytrader-war/src/main/webapp/config.jsp Tue Sep  1 19:22:30 2009
@@ -21,7 +21,7 @@
 <TITLE>Welcome to DayTrader</TITLE>
 </HEAD>
 <BODY bgcolor="#ffffff" link="#000099">
-<%@ page import="org.apache.geronimo.samples.daytrader.TradeConfig"
+<%@ page import="org.apache.geronimo.samples.daytrader.util.TradeConfig"
 	session="false" isThreadSafe="true" isErrorPage="false"%>
 
 <TABLE style="font-size: smaller">

Modified: geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/config.jsp
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/config.jsp?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/config.jsp (original)
+++ geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/config.jsp Tue Sep  1 19:22:30 2009
@@ -21,7 +21,7 @@
 <TITLE>Welcome to DayTrader</TITLE>
 </HEAD>
 <BODY bgcolor="#ffffff" link="#000099">
-<%@ page import="org.apache.geronimo.samples.daytrader.TradeConfig"
+<%@ page import="org.apache.geronimo.samples.daytrader.util.TradeConfig"
 	session="false" isThreadSafe="true" isErrorPage="false"%>
 
 <TABLE style="font-size: smaller">

Added: geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/dbscripts/other/Table.ddl
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/dbscripts/other/Table.ddl?rev=810185&view=auto
==============================================================================
--- geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/dbscripts/other/Table.ddl (added)
+++ geronimo/daytrader/trunk/assemblies/web/daytrader-web-jdbc/src/main/webapp/dbscripts/other/Table.ddl Tue Sep  1 19:22:30 2009
@@ -0,0 +1,107 @@
+##    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.
+
+# Each SQL statement in this file should terminate with a semicolon (;)
+# Lines starting with the pound character (#) are considered as comments
+DROP TABLE HOLDINGEJB;
+DROP TABLE ACCOUNTPROFILEEJB;
+DROP TABLE QUOTEEJB;
+DROP TABLE KEYGENEJB;
+DROP TABLE ACCOUNTEJB;
+DROP TABLE ORDEREJB;
+
+CREATE TABLE HOLDINGEJB
+  (PURCHASEPRICE DECIMAL(14, 2),
+   HOLDINGID INTEGER NOT NULL,
+   QUANTITY DOUBLE NOT NULL,
+   PURCHASEDATE TIMESTAMP,
+   ACCOUNT_ACCOUNTID INTEGER,
+   QUOTE_SYMBOL VARCHAR(250));
+
+ALTER TABLE HOLDINGEJB
+  ADD CONSTRAINT PK_HOLDINGEJB PRIMARY KEY (HOLDINGID);
+
+CREATE TABLE ACCOUNTPROFILEEJB
+  (ADDRESS VARCHAR(250),
+   PASSWD VARCHAR(250),
+   USERID VARCHAR(250) NOT NULL,
+   EMAIL VARCHAR(250),
+   CREDITCARD VARCHAR(250),
+   FULLNAME VARCHAR(250));
+
+ALTER TABLE ACCOUNTPROFILEEJB
+  ADD CONSTRAINT PK_ACCOUNTPROFILE2 PRIMARY KEY (USERID);
+
+CREATE TABLE QUOTEEJB
+  (LOW DECIMAL(14, 2),
+   OPEN1 DECIMAL(14, 2),
+   VOLUME DOUBLE NOT NULL,
+   PRICE DECIMAL(14, 2),
+   HIGH DECIMAL(14, 2),
+   COMPANYNAME VARCHAR(250),
+   SYMBOL VARCHAR(250) NOT NULL,
+   CHANGE1 DOUBLE NOT NULL);
+
+ALTER TABLE QUOTEEJB
+  ADD CONSTRAINT PK_QUOTEEJB PRIMARY KEY (SYMBOL);
+
+CREATE TABLE KEYGENEJB
+  (KEYVAL INTEGER NOT NULL,
+   KEYNAME VARCHAR(250) NOT NULL);
+
+ALTER TABLE KEYGENEJB
+  ADD CONSTRAINT PK_KEYGENEJB PRIMARY KEY (KEYNAME);
+
+CREATE TABLE ACCOUNTEJB
+  (CREATIONDATE TIMESTAMP,
+   OPENBALANCE DECIMAL(14, 2),
+   LOGOUTCOUNT INTEGER NOT NULL,
+   BALANCE DECIMAL(14, 2),
+   ACCOUNTID INTEGER NOT NULL,
+   LASTLOGIN TIMESTAMP,
+   LOGINCOUNT INTEGER NOT NULL,
+   PROFILE_USERID VARCHAR(250));
+
+ALTER TABLE ACCOUNTEJB
+  ADD CONSTRAINT PK_ACCOUNTEJB PRIMARY KEY (ACCOUNTID);
+
+CREATE TABLE ORDEREJB
+  (ORDERFEE DECIMAL(14, 2),
+   COMPLETIONDATE TIMESTAMP,
+   ORDERTYPE VARCHAR(250),
+   ORDERSTATUS VARCHAR(250),
+   PRICE DECIMAL(14, 2),
+   QUANTITY DOUBLE NOT NULL,
+   OPENDATE TIMESTAMP,
+   ORDERID INTEGER NOT NULL,
+   ACCOUNT_ACCOUNTID INTEGER,
+   QUOTE_SYMBOL VARCHAR(250),
+   HOLDING_HOLDINGID INTEGER);
+
+ALTER TABLE ORDEREJB
+  ADD CONSTRAINT PK_ORDEREJB PRIMARY KEY (ORDERID);
+
+ALTER TABLE HOLDINGEJB VOLATILE;
+ALTER TABLE ACCOUNTPROFILEEJB VOLATILE;
+ALTER TABLE QUOTEEJB VOLATILE;
+ALTER TABLE KEYGENEJB VOLATILE;
+ALTER TABLE ACCOUNTEJB VOLATILE;
+ALTER TABLE ORDEREJB VOLATILE;
+
+CREATE INDEX ACCOUNT_USERID ON ACCOUNTEJB(PROFILE_USERID);
+CREATE INDEX HOLDING_ACCOUNTID ON HOLDINGEJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_ACCOUNTID ON ORDEREJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_HOLDINGID ON ORDEREJB(HOLDING_HOLDINGID);
+CREATE INDEX CLOSED_ORDERS ON ORDEREJB(ACCOUNT_ACCOUNTID,ORDERSTATUS);

Modified: geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java (original)
+++ geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java Tue Sep  1 19:22:30 2009
@@ -557,4 +557,5 @@
         runStatsData = trade.resetTrade(deleteAll);
 		return runStatsData;
 	}
+    
 }

Added: geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeDBServices.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeDBServices.java?rev=810185&view=auto
==============================================================================
--- geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeDBServices.java (added)
+++ geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeDBServices.java Tue Sep  1 19:22:30 2009
@@ -0,0 +1,38 @@
+/**
+ *  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.samples.daytrader;
+
+
+/**
+  * TradeDBServices interface specifies the DB specific methods provided by SOME TradeServices instances.
+  *
+  * @see TradeJDBCDirect
+  * @see TradeJEEDirect
+  *
+  */ 
+public interface TradeDBServices {
+    
+    /**
+     * TradeBuildDB needs this abstracted method
+     */
+    public String checkDBProductName() throws Exception;
+    
+    /**
+     * TradeBuildDB needs this abstracted method
+     */
+    public boolean recreateDBTables(Object[] sqlBuffer, java.io.PrintWriter out) throws Exception;
+}   

Propchange: geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeDBServices.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeServices.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeServices.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeServices.java (original)
+++ geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/TradeServices.java Tue Sep  1 19:22:30 2009
@@ -272,5 +272,6 @@
  	 *  return statistics for this benchmark run
 	 */
     public RunStatsDataBean resetTrade(boolean deleteAll) throws Exception, RemoteException;
+    
 }   
 

Modified: geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJDBCDirect.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJDBCDirect.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJDBCDirect.java (original)
+++ geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJDBCDirect.java Tue Sep  1 19:22:30 2009
@@ -53,7 +53,7 @@
  * 
  */
 
-public class TradeJDBCDirect implements TradeServices {
+public class TradeJDBCDirect implements TradeServices, TradeDBServices {
 
     private static String dsName = TradeConfig.DATASOURCE;
 

Modified: geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java (original)
+++ geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java Tue Sep  1 19:22:30 2009
@@ -56,7 +56,7 @@
  * 
  */
 
-public class TradeJEEDirect implements TradeServices {
+public class TradeJEEDirect implements TradeServices, TradeDBServices {
 
     private static String dsName = TradeConfig.DATASOURCE;
 

Modified: geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJPADirect.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJPADirect.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJPADirect.java (original)
+++ geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJPADirect.java Tue Sep  1 19:22:30 2009
@@ -18,6 +18,7 @@
 
 import org.apache.geronimo.samples.daytrader.AccountDataBean;
 import org.apache.geronimo.samples.daytrader.AccountProfileDataBean;
+import org.apache.geronimo.samples.daytrader.direct.TradeJDBCDirect;
 import org.apache.geronimo.samples.daytrader.FinancialUtils;
 import org.apache.geronimo.samples.daytrader.HoldingDataBean;
 import org.apache.geronimo.samples.daytrader.MarketSummaryDataBean;
@@ -25,6 +26,7 @@
 import org.apache.geronimo.samples.daytrader.QuoteDataBean;
 import org.apache.geronimo.samples.daytrader.RunStatsDataBean;
 import org.apache.geronimo.samples.daytrader.TradeAction;
+import org.apache.geronimo.samples.daytrader.TradeDBServices;
 import org.apache.geronimo.samples.daytrader.TradeServices;
 import org.apache.geronimo.samples.daytrader.util.Log;
 import org.apache.geronimo.samples.daytrader.util.MDBStats;
@@ -71,7 +73,7 @@
  * 
  */
 
-public class TradeJPADirect implements TradeServices {
+public class TradeJPADirect implements TradeServices, TradeDBServices {
 
     @PersistenceContext
     private EntityManager entityManager;
@@ -619,7 +621,7 @@
         if (Log.doTrace())
             Log.trace("TradeJPADirect:resetTrade", deleteAll);
 
-        return new org.apache.geronimo.samples.daytrader.direct.TradeJDBCDirect(false).resetTrade(deleteAll);
+        return (new TradeJDBCDirect(false)).resetTrade(deleteAll);
     }
 
     private void publishQuotePriceChange(QuoteDataBean quote, BigDecimal oldPrice, BigDecimal changeFactor,
@@ -685,4 +687,21 @@
         Log.trace("publishQuotePriceChange: " + TradeConfig.getPublishQuotePriceChange());
     }
 
+    /**
+     * TradeBuildDB needs this abstracted method
+     */
+    public String checkDBProductName() throws Exception {
+        if (Log.doTrace())
+            Log.trace("TradeJPADirect:checkDBProductName");
+        return (new TradeJDBCDirect(false)).checkDBProductName();
+    }
+
+    /**
+     * TradeBuildDB needs this abstracted method
+     */
+    public boolean recreateDBTables(Object[] sqlBuffer, java.io.PrintWriter out) throws Exception {
+        if (Log.doTrace())
+            Log.trace("TradeJPADirect:checkDBProductName");
+        return (new TradeJDBCDirect(false)).recreateDBTables(sqlBuffer, out);
+    }
 }

Modified: geronimo/daytrader/trunk/modules/ejb3/src/main/java/org/apache/geronimo/samples/daytrader/ejb3/TradeSLSBBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb3/src/main/java/org/apache/geronimo/samples/daytrader/ejb3/TradeSLSBBean.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb3/src/main/java/org/apache/geronimo/samples/daytrader/ejb3/TradeSLSBBean.java (original)
+++ geronimo/daytrader/trunk/modules/ejb3/src/main/java/org/apache/geronimo/samples/daytrader/ejb3/TradeSLSBBean.java Tue Sep  1 19:22:30 2009
@@ -19,6 +19,7 @@
 
 import org.apache.geronimo.samples.daytrader.AccountDataBean;
 import org.apache.geronimo.samples.daytrader.AccountProfileDataBean;
+import org.apache.geronimo.samples.daytrader.direct.TradeJEEDirect;
 import org.apache.geronimo.samples.daytrader.FinancialUtils;
 import org.apache.geronimo.samples.daytrader.HoldingDataBean;
 import org.apache.geronimo.samples.daytrader.MarketSummaryDataBean;
@@ -614,7 +615,7 @@
         if (Log.doTrace())
             Log.trace("TradeSLSBBean:resetTrade", deleteAll);
 
-        return new org.apache.geronimo.samples.daytrader.direct.TradeJEEDirect(false).resetTrade(deleteAll);
+        return (new TradeJEEDirect(false)).resetTrade(deleteAll);
     }
 
     private void publishQuotePriceChange(QuoteDataBean quote, BigDecimal oldPrice, BigDecimal changeFactor, double sharesTraded) {

Modified: geronimo/daytrader/trunk/modules/util/src/main/java/org/apache/geronimo/samples/daytrader/util/TradeConfig.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/util/src/main/java/org/apache/geronimo/samples/daytrader/util/TradeConfig.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/util/src/main/java/org/apache/geronimo/samples/daytrader/util/TradeConfig.java (original)
+++ geronimo/daytrader/trunk/modules/util/src/main/java/org/apache/geronimo/samples/daytrader/util/TradeConfig.java Tue Sep  1 19:22:30 2009
@@ -507,7 +507,7 @@
 			try {
 				for (int i = 0; i < runTimeModeNames.length; i++) {
 					if (value.equalsIgnoreCase(runTimeModeNames[i])) {
-						runTimeMode = i;
+						setRunTimeMode(i);
 						break;
 					}
 				}
@@ -518,7 +518,7 @@
 						+ "trying to set runtimemode to "
 						+ value
 						+ "reverting to current value: "
-						+ runTimeModeNames[runTimeMode],
+						+ runTimeModeNames[getRunTimeMode()],
 					e);
 			} // If the value is bad, simply revert to current
 		} else if (parm.equalsIgnoreCase("orderProcessingMode")) {
@@ -851,6 +851,14 @@
 //		TradeWebSoapProxy.updateServicePort();
 	}
 
+    public static int getRunTimeMode() {
+        return runTimeMode;
+    }
+    
+    public static void setRunTimeMode(int value) {
+        runTimeMode = value;
+    }
+
 	public static int getPrimIterations() {
 		return primIterations;
 	}

Modified: geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java (original)
+++ geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeBuildDB.java Tue Sep  1 19:22:30 2009
@@ -24,286 +24,289 @@
 import java.util.ArrayList;
 
 import org.apache.geronimo.samples.daytrader.*;
-import org.apache.geronimo.samples.daytrader.direct.TradeJEEDirect;
+import org.apache.geronimo.samples.daytrader.direct.*;
 import org.apache.geronimo.samples.daytrader.util.*;
 
 /**
- * TradeBuildDB uses operations provided by the TradeApplication to (a) create the Database tables
- * (b)populate a DayTrader database without creating the tables. Specifically, a 
- * new DayTrader User population is created using UserIDs of the form "uid:xxx" 
- * where xxx is a sequential number (e.g. uid:0, uid:1, etc.). New stocks are also created of the 
- * form "s:xxx", again where xxx represents sequential numbers (e.g. s:1, s:2, etc.)
+ * TradeBuildDB uses operations provided by the TradeApplication to 
+ *   (a) create the Database tables 
+ *   (b) populate a DayTrader database without creating the tables. 
+ * Specifically, a new DayTrader User population is created using
+ * UserIDs of the form "uid:xxx" where xxx is a sequential number 
+ * (e.g. uid:0, uid:1, etc.). New stocks are also created of the form "s:xxx",
+ * again where xxx represents sequential numbers (e.g. s:1, s:2, etc.)
  */
 public class TradeBuildDB {
 
-	private boolean verbose = true;
-	private TradeConfig t = new TradeConfig();
+    private boolean verbose = true;
+    private TradeConfig t = new TradeConfig();
 
-	/**
-	  * Populate a Trade DB using standard out as a log
-	  */
-	public TradeBuildDB() throws Exception {
-		this(new java.io.PrintWriter(System.out), null);
-	}
-
-	/**
-		* Re-create the DayTrader db tables and populate them OR just populate a DayTrader DB, logging to the provided output stream
-		*/
-	public TradeBuildDB(java.io.PrintWriter out, String warPath) throws Exception {
-		String symbol, companyName;
-		int errorCount = 0; // Give up gracefully after 10 errors
-		TradeAction tradeAction = new TradeAction();
-
-		//  TradeStatistics.statisticsEnabled=false;  // disable statistics
-		out.println(
-			"<HEAD><BR><EM> TradeBuildDB: Building DayTrader Database...</EM><BR> This operation will take several minutes. Please wait...</HEAD>");
-		out.println("<BODY>");
-		
-		if (warPath != null)
-		{	
-			//out.println("<BR>TradeBuildDB: **** warPath= "+warPath+" ****</BR></BODY>");
-			
-			TradeJEEDirect tradeDirect = new TradeJEEDirect();
-			boolean success = false;
-			String dbProductName = null;
-			File ddlFile = null;
-			Object[] sqlBuffer = null;
-			
-			//Find out the Database being used
-			try
-			{
-				dbProductName = tradeDirect.checkDBProductName();
-			}
-			catch (Exception e)
-			{
-				Log.error(e, "TradeBuildDB: Unable to check DB Product name");
-			}
-			if (dbProductName == null)
-			{
-				out.println("<BR>TradeBuildDB: **** Unable to check DB Product name, please check Database/AppServer configuration and retry ****</BR></BODY>");
-				return;
-			}
-			
-			//Locate DDL file for the specified database
-			try
-			{
-				out.println("<BR>TradeBuildDB: **** Database Product detected: "+dbProductName+" ****</BR>");
-				if (dbProductName.startsWith("DB2/")) // if db is DB2
-				{
-					ddlFile = new File(warPath+File.separatorChar+"dbscripts"+File.separatorChar+"db2"+File.separatorChar+"Table.ddl");
-				}
-				else if (dbProductName.startsWith("Apache Derby")) //if db is Derby
-				{
-					ddlFile = new File(warPath+File.separatorChar+"dbscripts"+File.separatorChar+"derby"+File.separatorChar+"Table.ddl");
-				}
-				else if (dbProductName.startsWith("Oracle")) // if the Db is Oracle
-				{
-					ddlFile = new File(warPath+File.separatorChar+"dbscripts"+File.separatorChar+"oracle"+File.separatorChar+"Table.ddl");
-				}
-				else // Unsupported "Other" Database
-				{
-					ddlFile = new File(warPath+File.separatorChar+"dbscripts"+File.separatorChar+"other"+File.separatorChar+"Table.ddl");
-					out.println("<BR>TradeBuildDB: **** This Database is unsupported/untested use at your own risk ****</BR>");
-				}
-				
-				if (!ddlFile.exists())
-				{
-					Log.error("TradeBuildDB: DDL file doesnt exist at path "+ ddlFile.getCanonicalPath()+" , please provide the file and retry");
-					out.println("<BR>TradeBuildDB: DDL file doesnt exist at path <I>"+ ddlFile.getCanonicalPath()+"</I> , please provide the file and retry ****</BR></BODY>");
-					return;
-				}
-				out.println("<BR>TradeBuildDB: **** The DDL file at path <I>"+ ddlFile.getCanonicalPath()+"</I> will be used ****</BR>");
-				out.flush();
-			}
-			catch (Exception e)
-			{
-				Log.error(e, "TradeBuildDB: Unable to locate DDL file for the specified database");
-				out.println("<BR>TradeBuildDB: **** Unable to locate DDL file for the specified database ****</BR></BODY>");
-				return;
-			}
-			
-			//parse the DDL file and fill the SQL commands into a buffer
-			try
-			{
-				sqlBuffer = parseDDLToBuffer(ddlFile);
-			}
-			catch (Exception e)
-			{
-				Log.error(e, "TradeBuildDB: Unable to parse DDL file");
-				out.println("<BR>TradeBuildDB: **** Unable to parse DDL file for the specified database ****</BR></BODY>");
-				return;
-			}
-			if ((sqlBuffer == null)||(sqlBuffer.length == 0))
-			{
-				out.println("<BR>TradeBuildDB: **** Parsing DDL file returned empty buffer, please check that a valid DB specific DDL file is available and retry ****</BR></BODY>");
-				return;
-			}
-			
-			// send the sql commands buffer to drop and recreate the Daytrader tables
-			out.println("<BR>TradeBuildDB: **** Dropping and Recreating the DayTrader tables... ****</BR>");
-			try
-			{
-				success = tradeDirect.recreateDBTables(sqlBuffer, out);
-			}
-			catch (Exception e)
-			{
-				Log.error(e, "TradeBuildDB: Unable to drop and recreate DayTrader Db Tables, please check for database consistency before continuing");
-			}
-			if (!success)
-			{
-				out.println("<BR>TradeBuildDB: **** Unable to drop and recreate DayTrader Db Tables, please check for database consistency before continuing ****</BR></BODY>");
-				return;
-			}
-			out.println("<BR>TradeBuildDB: **** DayTrader tables successfully created! ****</BR><BR><b> Please Stop and Re-start your Daytrader application (or your application server) and then use the \"Repopulate Daytrader Database\" link to populate your database.</b></BR><BR><BR></BODY>");
-			return;
-		} // end of createDBTables
-		
-		out.println("<BR>TradeBuildDB: **** Creating " + TradeConfig.getMAX_QUOTES() + " Quotes ****</BR>");
-		//Attempt to delete all of the Trade users and Trade Quotes first
-		try
-		{
-			tradeAction.resetTrade(true);
-		}
-		catch (Exception e)
-		{
-			Log.error(e, "TradeBuildDB: Unable to delete Trade users (uid:0, uid:1, ...) and Trade Quotes (s:0, s:1, ...)");
-		}
-		for (int i = 0; i < TradeConfig.getMAX_QUOTES(); i++) {
-			symbol = "s:" + i;
-			companyName = "S" + i + " Incorporated";
-			try {
-				QuoteDataBean quoteData =
-					tradeAction.createQuote(
-						symbol,
-						companyName,
-						new java.math.BigDecimal(TradeConfig.rndPrice()));
-				if (i % 10 == 0) {
-					out.print("....." + symbol);
-					if (i % 100 == 0) {
-						out.println(" -<BR>");
-						out.flush();
-					}
-				}
-			} catch (Exception e) {
-				if (errorCount++ >= 10) {
-					String error = "Populate Trade DB aborting after 10 create quote errors. Check the EJB datasource configuration. Check the log for details <BR><BR> Exception is: <BR> " + e.toString();						
-					Log.error(e, error);
-					throw e;
-				}	
-			}
-		}
-		out.println("<BR>");
-		out.println("<BR>**** Registering " + TradeConfig.getMAX_USERS() + " Users **** ");
-		errorCount = 0; //reset for user registrations
-
-		// Registration is a formal operation in Trade 2. 
-		for (int i = 0; i < TradeConfig.getMAX_USERS(); i++) {
-			String userID = "uid:" + i;
-			String fullname = TradeConfig.rndFullName();
-			String email = TradeConfig.rndEmail(userID);
-			String address = TradeConfig.rndAddress();
-			String creditcard = TradeConfig.rndCreditCard();
-			double initialBalance = (double) (TradeConfig.rndInt(100000)) + 200000;
-			if (i == 0) {
-				initialBalance = 1000000; // uid:0 starts with a cool million.
-			}
-			try {
-				AccountDataBean accountData =
-					tradeAction.register(
-						userID,
-						"xxx",
-						fullname,
-						address,
-						email,
-						creditcard,
-						new BigDecimal(initialBalance));
-				String results;
-				if (accountData != null) {
-					if (i % 50 == 0) {
-						out.print("<BR>Account# " +accountData.getAccountID() + " userID=" + userID);
-					} // end-if
-
-					int holdings = TradeConfig.rndInt(TradeConfig.getMAX_HOLDINGS()+1); // 0-MAX_HOLDING (inclusive), avg holdings per user = (MAX-0)/2
-					double quantity = 0;
-					OrderDataBean orderData;
-					for (int j = 0; j < holdings; j++) {
-						symbol = TradeConfig.rndSymbol();
-						quantity = TradeConfig.rndQuantity();
-						orderData = tradeAction.buy(userID, symbol, quantity, TradeConfig.orderProcessingMode);
-					} // end-for
-					if (i % 50 == 0) {
-						out.println(" has " + holdings + " holdings.");
-						out.flush();
-					} // end-if
-				} else {
-					out.println("<BR>UID " + userID + " already registered.</BR>");
-					out.flush();
-				} // end-if
-
-			} catch (Exception e) {
-				if (errorCount++ >= 10) {
-					AccountProfileDataBean accountProfileData = null;
-
-					String error = "Populate Trade DB aborting after 10 user registration errors. Check the log for details. <BR><BR> Exception is: <BR>"	+ e.toString();
-					Log.error(e, error);
-					throw e;					
-				}
-			}
-		} // end-for
-		out.println("</BODY>");
-	}
-	
-	public Object[] parseDDLToBuffer(File ddlFile) throws Exception 
-	{
+    /**
+     * Populate a Trade DB using standard out as a log
+     */
+    public TradeBuildDB() throws Exception {
+        this(new java.io.PrintWriter(System.out), null);
+    }
+
+    /**
+     * Re-create the DayTrader db tables and populate them OR just populate a 
+     * DayTrader DB, logging to the provided output stream
+     */
+    public TradeBuildDB(java.io.PrintWriter out, String warPath)
+        throws Exception {
+        String symbol, companyName;
+        int errorCount = 0; // Give up gracefully after 10 errors
+        TradeAction tradeAction = new TradeAction();
+
+        // TradeStatistics.statisticsEnabled=false; // disable statistics
+        out.println("<HEAD><BR><EM> TradeBuildDB: Building DayTrader Database...</EM><BR>"
+            + "This operation will take several minutes. Please wait...</HEAD>");
+        out.println("<BODY>");
+
+        if (warPath != null) {
+            // out.println("<BR>TradeBuildDB: **** warPath= "+warPath+" ****</BR></BODY>");
+            TradeDBServices tradeDB = null;
+
+            if ((TradeConfig.getRunTimeMode() == TradeConfig.JDBC)
+                || (TradeConfig.getRunTimeMode() == TradeConfig.JPA)) {
+                tradeDB = new TradeJDBCDirect();
+            } else {
+                tradeDB = new TradeJEEDirect();
+            }
+
+            boolean success = false;
+            String dbProductName = null;
+            File ddlFile = null;
+            Object[] sqlBuffer = null;
+
+            // Find out the Database being used
+            try {
+                dbProductName = tradeDB.checkDBProductName();
+            } catch (Exception e) {
+                Log.error(e, "TradeBuildDB: Unable to check DB Product name");
+            }
+            if (dbProductName == null) {
+                out.println("<BR>TradeBuildDB: **** Unable to check DB Product name,"
+                    + "please check Database/AppServer configuration and retry ****</BR></BODY>");
+                return;
+            }
+
+            // Locate DDL file for the specified database
+            try {
+                out.println("<BR>TradeBuildDB: **** Database Product detected: "
+                    + dbProductName + " ****</BR>");
+                if (dbProductName.startsWith("DB2/")) { // if db is DB2
+                    ddlFile = new File(warPath + File.separatorChar + "dbscripts"
+                        + File.separatorChar + "db2" + File.separatorChar + "Table.ddl");
+                } else if (dbProductName.startsWith("Apache Derby")) { // if db is Derby
+                    ddlFile = new File(warPath + File.separatorChar + "dbscripts"
+                        + File.separatorChar + "derby" + File.separatorChar + "Table.ddl");
+                } else if (dbProductName.startsWith("Oracle")) { // if the Db is Oracle
+                    ddlFile = new File(warPath + File.separatorChar + "dbscripts"
+                        + File.separatorChar + "oracle" + File.separatorChar + "Table.ddl");
+                } else { // Unsupported "Other" Database
+                    ddlFile = new File(warPath + File.separatorChar + "dbscripts"
+                        + File.separatorChar + "other" + File.separatorChar + "Table.ddl");
+                    out.println("<BR>TradeBuildDB: **** This Database is "
+                        + "unsupported/untested use at your own risk ****</BR>");
+                }
+
+                if (!ddlFile.exists()) {
+                    Log.error("TradeBuildDB: DDL file doesnt exist at path "
+                        + ddlFile.getCanonicalPath()
+                        + " , please provide the file and retry");
+                    out.println("<BR>TradeBuildDB: DDL file doesnt exist at path <I>"
+                        + ddlFile.getCanonicalPath() +
+                        "</I> , please provide the file and retry ****</BR></BODY>");
+                    return;
+                }
+                out.println("<BR>TradeBuildDB: **** The DDL file at path <I>"
+                    + ddlFile.getCanonicalPath()
+                    + "</I> will be used ****</BR>");
+                out.flush();
+            } catch (Exception e) {
+                Log.error(e,
+                    "TradeBuildDB: Unable to locate DDL file for the specified database");
+                out.println("<BR>TradeBuildDB: **** Unable to locate DDL file for "
+                    + "the specified database ****</BR></BODY>");
+                return;
+            }
+
+            // parse the DDL file and fill the SQL commands into a buffer
+            try {
+                sqlBuffer = parseDDLToBuffer(ddlFile);
+            } catch (Exception e) {
+                Log.error(e, "TradeBuildDB: Unable to parse DDL file");
+                out.println("<BR>TradeBuildDB: **** Unable to parse DDL file for the specified "+
+                    "database ****</BR></BODY>");
+                return;
+            }
+            if ((sqlBuffer == null) || (sqlBuffer.length == 0)) {
+                out.println("<BR>TradeBuildDB: **** Parsing DDL file returned empty buffer, please check "+
+                    "that a valid DB specific DDL file is available and retry ****</BR></BODY>");
+                return;
+            }
+
+            // send the sql commands buffer to drop and recreate the Daytrader tables
+            out.println("<BR>TradeBuildDB: **** Dropping and Recreating the DayTrader tables... ****</BR>");
+            try {
+                success = tradeDB.recreateDBTables(sqlBuffer, out);
+            } catch (Exception e) {
+                Log.error(e,
+                    "TradeBuildDB: Unable to drop and recreate DayTrader Db Tables, "+
+                    "please check for database consistency before continuing");
+            }
+            if (!success) {
+                out.println("<BR>TradeBuildDB: **** Unable to drop and recreate DayTrader Db Tables, "+
+                    "please check for database consistency before continuing ****</BR></BODY>");
+                return;
+            }
+            out.println("<BR>TradeBuildDB: **** DayTrader tables successfully created! ****</BR><BR><b> "+
+                "Please Stop and Re-start your Daytrader application (or your application server) and then use "+
+                "the \"Repopulate Daytrader Database\" link to populate your database.</b></BR><BR><BR></BODY>");
+            return;
+        } // end of createDBTables
+
+        out.println("<BR>TradeBuildDB: **** Creating "
+            + TradeConfig.getMAX_QUOTES() + " Quotes ****</BR>");
+        // Attempt to delete all of the Trade users and Trade Quotes first
+        try {
+            tradeAction.resetTrade(true);
+        } catch (Exception e) {
+            Log.error(e, "TradeBuildDB: Unable to delete Trade users "+
+                "(uid:0, uid:1, ...) and Trade Quotes (s:0, s:1, ...)");
+        }
+        for (int i = 0; i < TradeConfig.getMAX_QUOTES(); i++) {
+            symbol = "s:" + i;
+            companyName = "S" + i + " Incorporated";
+            try {
+                QuoteDataBean quoteData =
+                    tradeAction.createQuote(symbol, companyName,
+                        new java.math.BigDecimal(TradeConfig.rndPrice()));
+                if (i % 10 == 0) {
+                    out.print("....." + symbol);
+                    if (i % 100 == 0) {
+                        out.println(" -<BR>");
+                        out.flush();
+                    }
+                }
+            } catch (Exception e) {
+                if (errorCount++ >= 10) {
+                    String error = "Populate Trade DB aborting after 10 create quote errors. Check "+
+                        "the EJB datasource configuration. Check the log for details <BR><BR> Exception is: <BR> "
+                        + e.toString();
+                    Log.error(e, error);
+                    throw e;
+                }
+            }
+        }
+        out.println("<BR>");
+        out.println("<BR>**** Registering " + TradeConfig.getMAX_USERS()
+            + " Users **** ");
+        errorCount = 0; // reset for user registrations
+
+        // Registration is a formal operation in Trade 2.
+        for (int i = 0; i < TradeConfig.getMAX_USERS(); i++) {
+            String userID = "uid:" + i;
+            String fullname = TradeConfig.rndFullName();
+            String email = TradeConfig.rndEmail(userID);
+            String address = TradeConfig.rndAddress();
+            String creditcard = TradeConfig.rndCreditCard();
+            double initialBalance =
+                (double) (TradeConfig.rndInt(100000)) + 200000;
+            if (i == 0) {
+                initialBalance = 1000000; // uid:0 starts with a cool million.
+            }
+            try {
+                AccountDataBean accountData =
+                    tradeAction.register(userID, "xxx", fullname, address,
+                        email, creditcard, new BigDecimal(initialBalance));
+                String results;
+                if (accountData != null) {
+                    if (i % 50 == 0) {
+                        out.print("<BR>Account# " + accountData.getAccountID()
+                            + " userID=" + userID);
+                    }
+
+                    // 0-MAX_HOLDING (inclusive), avg holdings per user = (MAX-0)/2
+                    int holdings = TradeConfig.rndInt(TradeConfig.getMAX_HOLDINGS() + 1); 
+                    double quantity = 0;
+                    OrderDataBean orderData;
+                    for (int j = 0; j < holdings; j++) {
+                        symbol = TradeConfig.rndSymbol();
+                        quantity = TradeConfig.rndQuantity();
+                        orderData =
+                            tradeAction.buy(userID, symbol, quantity,
+                                TradeConfig.orderProcessingMode);
+                    }
+                    if (i % 50 == 0) {
+                        out.println(" has " + holdings + " holdings.");
+                        out.flush();
+                    }
+                } else {
+                    out.println("<BR>UID " + userID
+                        + " already registered.</BR>");
+                    out.flush();
+                }
+
+            } catch (Exception e) {
+                if (errorCount++ >= 10) {
+                    AccountProfileDataBean accountProfileData = null;
+
+                    String error = "Populate Trade DB aborting after 10 user registration errors. "+
+                        "Check the log for details. <BR><BR> Exception is: <BR>" + e.toString();
+                    Log.error(e, error);
+                    throw e;
+                }
+            }
+        } // end-for
+        out.println("</BODY>");
+    }
+
+    public Object[] parseDDLToBuffer(File ddlFile) throws Exception {
         BufferedReader br = null;
-        ArrayList sqlBuffer = new ArrayList(30); //initial capacity 30 assuming we have 30 ddl-sql statements to read
+        ArrayList sqlBuffer = new ArrayList(30); // initial capacity 30 assuming we have 30 ddl-sql statements to read
 
-        try 
-        {
-        	if (Log.doTrace()) Log.traceEnter("TradeBuildDB:parseDDLToBuffer - " + ddlFile);
-        	
-			br = new BufferedReader(new FileReader(ddlFile));
+        try {
+            if (Log.doTrace())
+                Log.traceEnter("TradeBuildDB:parseDDLToBuffer - " + ddlFile);
+
+            br = new BufferedReader(new FileReader(ddlFile));
             String s;
-			String sql = new String();
-            while ((s = br.readLine()) != null) 
-            {
-				s = s.trim();
-				if ((s.length() != 0) && (s.charAt(0) != '#'))  // Empty lines or lines starting with "#" are ignored
-				{
-					sql = sql +" "+ s;
-					if (s.endsWith(";")) // reached end of sql statement
-					{
-						sql = sql.replace(';', ' '); //remove the semicolon
-						//System.out.println (sql);
-						sqlBuffer.add(sql);
-						sql = "";
-					}
-				}
-            }
-        } 
-        catch (IOException ex)
-        {
-        	Log.error("TradeBuildDB:parseDDLToBuffer Exeception during open/read of File: " + ddlFile, ex);
-        	throw ex;
-        }
-        finally 
-        {
-            if (br != null) 
-            {
-                try 
+            String sql = new String();
+            while ((s = br.readLine()) != null) {
+                s = s.trim();
+                if ((s.length() != 0) && (s.charAt(0) != '#')) // Empty lines or lines starting with "#" are ignored
                 {
+                    sql = sql + " " + s;
+                    if (s.endsWith(";")) // reached end of sql statement
+                    {
+                        sql = sql.replace(';', ' '); // remove the semicolon
+                        // System.out.println (sql);
+                        sqlBuffer.add(sql);
+                        sql = "";
+                    }
+                }
+            }
+        } catch (IOException ex) {
+            Log.error("TradeBuildDB:parseDDLToBuffer Exeception during open/read of File: "
+                + ddlFile, ex);
+            throw ex;
+        } finally {
+            if (br != null) {
+                try {
                     br.close();
-                } catch(IOException ex) 
-                {
-                	Log.error("TradeBuildDB:parseDDLToBuffer Failed to close BufferedReader", ex);
+                } catch (IOException ex) {
+                    Log.error("TradeBuildDB:parseDDLToBuffer Failed to close BufferedReader",
+                        ex);
                 }
             }
         }
         return sqlBuffer.toArray();
-	}
-	
-	public static void main(String args[]) throws Exception {
-		new TradeBuildDB();
+    }
+
+    public static void main(String args[]) throws Exception {
+        new TradeBuildDB();
 
-	}
+    }
 }

Modified: geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeConfigServlet.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeConfigServlet.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeConfigServlet.java (original)
+++ geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeConfigServlet.java Tue Sep  1 19:22:30 2009
@@ -113,7 +113,7 @@
 				int i = Integer.parseInt(runTimeModeStr);
 				if ((i >= 0)
 					&& (i < TradeConfig.runTimeModeNames.length)) //Input validation
-					TradeConfig.runTimeMode = i;
+					TradeConfig.setRunTimeMode(i);
 			}
 			catch (Exception e)
 			{
@@ -126,7 +126,7 @@
 
 			} // If the value is bad, simply revert to current
 		}
-		currentConfigStr += "\t\tRunTimeMode:\t\t" + TradeConfig.runTimeModeNames[TradeConfig.runTimeMode] + "\n";
+		currentConfigStr += "\t\tRunTimeMode:\t\t" + TradeConfig.runTimeModeNames[TradeConfig.getRunTimeMode()] + "\n";
 		
 		/* Add JPA layer choice to avoid some ugly Hibernate bugs */
 		String jpaLayerStr = req.getParameter("JPALayer");
@@ -408,15 +408,14 @@
 			else if (action.equals("buildDB"))
 			{
 				resp.setContentType("text/html");
-                                new TradeBuildDB(resp.getWriter(), null);
+                new TradeBuildDB(resp.getWriter(), null);
 				result = "DayTrader Database Built - " + TradeConfig.getMAX_USERS() + "users created";
 			}
-                        else if (action.equals("buildDBTables"))
-                        {
- 
-                                resp.setContentType("text/html");
-                                new TradeBuildDB(resp.getWriter(), getServletConfig().getServletContext().getRealPath("/"));
-                        }
+            else if (action.equals("buildDBTables"))
+            {
+                resp.setContentType("text/html");
+                new TradeBuildDB(resp.getWriter(), getServletConfig().getServletContext().getRealPath("/"));
+            }
 			doConfigDisplay(req, resp, result + "Current DayTrader Configuration:");
 		}
 		catch (Exception e)

Modified: geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java (original)
+++ geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/TradeServletAction.java Tue Sep  1 19:22:30 2009
@@ -44,10 +44,15 @@
     private TradeServices tAction = null;
 
     TradeServletAction() {
-        if (TradeConfig.getAccessMode() == TradeConfig.STANDARD)
+        if (TradeConfig.getAccessMode() == TradeConfig.STANDARD) {
             tAction = new TradeAction();
-        else if (TradeConfig.getAccessMode() == TradeConfig.WEBSERVICES)
+        } else if (TradeConfig.getAccessMode() == TradeConfig.WEBSERVICES) {
             tAction = new TradeWebSoapProxy();
+        } else {
+            throw new IllegalArgumentException(
+                "TradeServletAction - Uknown TradeConfig accessMode=" +
+                TradeConfig.getAccessMode());
+        }
     }
 
     /**
@@ -272,8 +277,10 @@
     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 holdingDataBeans = tAction.getHoldings(userID);
@@ -290,41 +297,68 @@
             // 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
+        } 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");
+                + " 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) {
-            // 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));
+                .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);
+            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) {
-            // log the exception with error page
-            throw new ServletException("TradeServletAction.doHome(...)"
+            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

Modified: geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBQueue.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBQueue.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBQueue.java (original)
+++ geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBQueue.java Tue Sep  1 19:22:30 2009
@@ -38,8 +38,8 @@
 
 /**
  * This primitive is designed to run inside the TradeApplication and relies upon
- * the {@link org.apache.geronimo.samples.daytrader.TradeConfig} class to set
- * configuration parameters. PingServlet2MDBQueue tests key functionality of a
+ * the {@link org.apache.geronimo.samples.daytrader.util.TradeConfig} class to
+ * set config parameters. PingServlet2MDBQueue tests key functionality of a
  * servlet call to a post a message to an MDB Queue. The TradeBrokerMDB receives
  * the message This servlet makes use of the MDB EJB
  * {@link org.apache.geronimo.samples.daytrader.ejb.TradeBrokerMDB} by posting a

Modified: geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBTopic.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBTopic.java?rev=810185&r1=810184&r2=810185&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBTopic.java (original)
+++ geronimo/daytrader/trunk/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/ejb3/PingServlet2MDBTopic.java Tue Sep  1 19:22:30 2009
@@ -38,8 +38,8 @@
 
 /**
  * This primitive is designed to run inside the TradeApplication and relies upon
- * the {@link org.apache.geronimo.samples.daytrader.TradeConfig} class to set
- * configuration parameters. PingServlet2MDBQueue tests key functionality of a
+ * the {@link org.apache.geronimo.samples.daytrader.util.TradeConfig} class to
+ * set config parameters. PingServlet2MDBQueue tests key functionality of a
  * servlet call to a post a message to an MDB Topic. The TradeStreamerMDB (and
  * any other subscribers) receives the message This servlet makes use of the MDB
  * EJB {@link org.apache.geronimo.samples.daytrader.ejb.TradeStreamerMDB} by



Mime
View raw message