geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hogst...@apache.org
Subject svn commit: r470600 - in /geronimo/daytrader/branches/1.2/modules: ejb/src/main/java/org/apache/geronimo/samples/daytrader/ ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/ ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/...
Date Thu, 02 Nov 2006 23:40:40 GMT
Author: hogstrom
Date: Thu Nov  2 15:40:39 2006
New Revision: 470600

URL: http://svn.apache.org/viewvc?view=rev&rev=470600
Log:
DAYTRADER-15 Added Stateless Session bean JDBC Mode

Added:
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBC.java   (with props)
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCBean.java   (with props)
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCHome.java   (with props)
    geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBC.java   (with props)
    geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBCCollection.java   (with props)
Modified:
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/KeySequenceDirect.java
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/resources/META-INF/ejb-jar.xml
    geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/WEB-INF/web.xml
    geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/web_prmtv.html

Modified: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java?view=diff&rev=470600&r1=470599&r2=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java (original)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java Thu Nov  2 15:40:39 2006
@@ -21,6 +21,7 @@
 
 import org.apache.geronimo.samples.daytrader.direct.*;
 import org.apache.geronimo.samples.daytrader.ejb.*;
+import org.apache.geronimo.samples.daytrader.session.TradeJDBCHome;
 import org.apache.geronimo.samples.daytrader.util.*;
 
 import java.rmi.RemoteException;
@@ -40,6 +41,7 @@
 public class TradeAction implements TradeServices {
 	private TradeServices trade = null;
 	private static TradeHome tradeHome = null;
+	private static TradeJDBCHome tradeJDBCHome = null;
 	
 
 	public TradeAction() {
@@ -80,6 +82,24 @@
 			}
 			catch (Exception e) {
 				Log.error("TradeAction:TradeAction() Creation of Trade Direct failed\n" + e);
+			}
+		} else if (TradeConfig.runTimeMode == TradeConfig.SESSION) {
+			try {
+				if (tradeHome == null) {
+					InitialContext ic = new InitialContext();
+					try {
+						tradeJDBCHome = (TradeJDBCHome) (javax.rmi.PortableRemoteObject.narrow(ic.lookup("java:comp/env/ejb/TradeJDBC"), TradeJDBCHome.class));
+					}
+					catch (Exception e) {
+						Log.log("TradeAction:createTrade lookup of java:comp/env/ejb/TradeJDBC failed. Reverting to JNDI lookup of Trade");
+						tradeJDBCHome = (TradeJDBCHome) (javax.rmi.PortableRemoteObject.narrow(ic.lookup("TradeJDBC"), TradeJDBCHome.class));
+					}
+				}
+				trade = tradeJDBCHome.create();
+			}
+			catch (Exception e) {
+				Log.error("TradeAction:TradeAction() Creation of Trade JDBC failed\n" + e);
+				e.printStackTrace();
 			}
 		}
 	}

Modified: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java?view=diff&rev=470600&r1=470599&r2=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java (original)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java Thu Nov  2 15:40:39 2006
@@ -36,9 +36,10 @@
 	/* Trade Runtime Configuration Parameters */
 
 	/* Trade Runtime Mode parameters */
-	public static String[] runTimeModeNames = { "EJB", "Direct" };
+	public static String[] runTimeModeNames = { "EJB", "Direct", "Session Direct"};
 	public static final int EJB = 0;
 	public static final int DIRECT = 1;
+	public static final int SESSION = 2;
 	public static int runTimeMode = DIRECT;
 
 	public static String[] orderProcessingModeNames =

Modified: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/KeySequenceDirect.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/KeySequenceDirect.java?view=diff&rev=470600&r1=470599&r2=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/KeySequenceDirect.java (original)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/KeySequenceDirect.java Thu Nov  2 15:40:39 2006
@@ -33,7 +33,7 @@
 
 	private static HashMap keyMap = new HashMap();
 
-    public static synchronized Integer getNextID(Connection conn, String keyName, boolean inGlobalTxn)
+    public static synchronized Integer getNextID(Connection conn, String keyName, boolean inSession, boolean inGlobalTxn)
 	throws Exception
     {
 		Integer nextID = null;
@@ -42,25 +42,25 @@
 		// Then verify the allocated block has not been depleted
 		// allocate a new block if necessary
 		if ( keyMap.containsKey(keyName) == false)
-			allocNewBlock(conn, keyName, inGlobalTxn);
+			allocNewBlock(conn, keyName, inSession, inGlobalTxn);
 		Collection block = 	(Collection) keyMap.get(keyName);
 		
 		Iterator ids = block.iterator();
 		if ( ids.hasNext() == false )
-			ids = allocNewBlock(conn, keyName, inGlobalTxn).iterator();
+			ids = allocNewBlock(conn, keyName, inSession, inGlobalTxn).iterator();
 		//get and return a new unique key
 		nextID = (Integer) ids.next();
 
-		if (Log.doTrace()) Log.trace("KeySequenceDirect:getNextID - return new PK ID for Entity type: " + keyName + " ID=" + nextID);
+		if (Log.doTrace()) Log.trace("KeySequenceDirect:getNextID inSession(" + inSession + ") - return new PK ID for Entity type: " + keyName + " ID=" + nextID);
 		return nextID;
 	}
 
-	private static Collection allocNewBlock(Connection conn, String keyName, boolean inGlobalTxn)  
+	private static Collection allocNewBlock(Connection conn, String keyName, boolean inSession, boolean inGlobalTxn)  
 	throws Exception
 	{
 		try 
 		{
-			if (inGlobalTxn == false) conn.commit();  // commit any pending txns
+			if (inGlobalTxn == false && !inSession) conn.commit();  // commit any pending txns
 			PreparedStatement stmt = conn.prepareStatement(getKeyForUpdateSQL);
 			stmt.setString(1, keyName);
 			ResultSet rs = stmt.executeQuery();
@@ -92,7 +92,7 @@
 
 			Collection block = new KeyBlock(keyVal, keyVal+TradeConfig.KEYBLOCKSIZE-1);
 			keyMap.put(keyName, block);
-			if (inGlobalTxn == false) conn.commit();
+			if (inGlobalTxn == false && !inSession) conn.commit();
 			return block;			
 		}
 		catch (Exception e)

Modified: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java?view=diff&rev=470600&r1=470599&r2=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java (original)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java Thu Nov  2 15:40:39 2006
@@ -61,6 +61,8 @@
 	private static DataSource datasource = null;
 	private static BigDecimal ZERO = new BigDecimal(0.0);
 	private boolean inGlobalTxn = false;
+	private boolean inSession = false;
+
 
 	/**
 	 * Zero arg constructor for TradeDirect
@@ -69,6 +71,13 @@
 	    if (initialized==false) init();
 	}
 
+	public TradeDirect(boolean inSession) {
+		if (initialized == false)
+			init();
+
+		this.inSession = inSession;
+	}
+
 	/**
 	 * @see TradeServices#getMarketSummary()
 	 */
@@ -78,7 +87,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getMarketSummary");
+			if (Log.doTrace()) Log.trace("TradeDirect:getMarketSummary - inSession(" + this.inSession + ")");
 			
 			conn = getConn();
             PreparedStatement stmt = getStatement(conn, getTSIAQuotesOrderByChangeSQL, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
@@ -191,9 +200,9 @@
 		try
 		{
 			if (Log.doTrace()) 
-				Log.trace("TradeDirect:buy", userID, symbol, new Double(quantity));
+				Log.trace("TradeDirect:buy - inSession(" + this.inSession + ")", userID, symbol, new Double(quantity));
 			
-			if ( orderProcessingMode == TradeConfig.ASYNCH_2PHASE )
+			if ( !inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE )
 			{
 				if ( Log.doTrace() )
 					Log.trace("TradeDirect:buy create/begin global transaction");		
@@ -278,9 +287,9 @@
 		try
 		{
 			if (Log.doTrace()) 
-				Log.trace("TradeDirect:sell", userID, holdingID);
+				Log.trace("TradeDirect:sell - inSession(" + this.inSession + ")", userID, holdingID);
 
-			if ( orderProcessingMode == TradeConfig.ASYNCH_2PHASE )
+			if ( !inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE )
 			{
 				if ( Log.doTrace() )
 					Log.trace("TradeDirect:sell create/begin global transaction");		
@@ -370,7 +379,7 @@
 	 */
 	public void queueOrder(Integer orderID, boolean twoPhase) throws Exception 
 	{
-		if (Log.doTrace() ) Log.trace("TradeDirect:queueOrder", orderID);
+		if (Log.doTrace() ) Log.trace("TradeDirect:queueOrder - inSession(" + this.inSession + ")", orderID);
 
 		javax.jms.Connection conn = null;	
 		Session sess = null;
@@ -427,8 +436,8 @@
 		try  //twoPhase
 		{
 
-			if (Log.doTrace()) Log.trace("TradeDirect:completeOrder", orderID);
-			setInGlobalTxn(twoPhase);
+			if (Log.doTrace()) Log.trace("TradeDirect:completeOrder - inSession(" + this.inSession + ")", orderID);
+			setInGlobalTxn(!inSession && twoPhase);
 			conn = getConn();
 			orderData = completeOrder(conn, orderID);
 			commit(conn);
@@ -454,7 +463,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:completeOrderOnePhase", orderID);
+			if (Log.doTrace()) Log.trace("TradeDirect:completeOrderOnePhase - inSession(" + this.inSession + ")", orderID);
 			setInGlobalTxn(false);
 			conn = getConn();
 			orderData = completeOrder(conn, orderID);
@@ -482,7 +491,7 @@
 	{
 			
 		OrderDataBean orderData = null;
-		if (Log.doTrace()) Log.trace("TradeDirect:completeOrderInternal", orderID);
+		if (Log.doTrace()) Log.trace("TradeDirect:completeOrderInternal - inSession(" + this.inSession + ")", orderID);
 
 		PreparedStatement stmt = getStatement(conn, getOrderSQL);
         stmt.setInt(1, orderID.intValue());
@@ -589,8 +598,8 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:cancelOrder", orderID);
-			setInGlobalTxn(twoPhase);
+			if (Log.doTrace()) Log.trace("TradeDirect:cancelOrder - inSession(" + this.inSession + ")", orderID);
+			setInGlobalTxn(!inSession && twoPhase);
 			conn = getConn();
 			cancelOrder(conn, orderID);
 			commit(conn);
@@ -613,7 +622,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:cancelOrderOnePhase", orderID);
+			if (Log.doTrace()) Log.trace("TradeDirect:cancelOrderOnePhase - inSession(" + this.inSession + ")", orderID);
 			setInGlobalTxn(false);
 			conn = getConn();
 			cancelOrder(conn, orderID);
@@ -652,7 +661,7 @@
 		Timestamp purchaseDate = new Timestamp(System.currentTimeMillis());
 		PreparedStatement stmt = getStatement(conn, createHoldingSQL);
 	
-		Integer holdingID = KeySequenceDirect.getNextID(conn, "holding", getInGlobalTxn());
+		Integer holdingID = KeySequenceDirect.getNextID(conn, "holding", inSession, getInGlobalTxn());
 		stmt.setInt(1, holdingID.intValue());
 		stmt.setTimestamp(2, purchaseDate);
 		stmt.setBigDecimal(3, purchasePrice);
@@ -694,7 +703,7 @@
 		PreparedStatement stmt = getStatement(conn, createOrderSQL);
 	
 
-		Integer orderID = KeySequenceDirect.getNextID(conn, "order", getInGlobalTxn());
+		Integer orderID = KeySequenceDirect.getNextID(conn, "order", inSession, getInGlobalTxn());
 		stmt.setInt(1, orderID.intValue());
 		stmt.setString(2, orderType);
 		stmt.setString(3, "open");
@@ -722,7 +731,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getOrders", userID);
+			if (Log.doTrace()) Log.trace("TradeDirect:getOrders - inSession(" + this.inSession + ")", userID);
 			
 			conn = getConn();
             PreparedStatement stmt = getStatement(conn, getOrdersByUserSQL);
@@ -763,7 +772,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getClosedOrders", userID);
+			if (Log.doTrace()) Log.trace("TradeDirect:getClosedOrders - inSession(" + this.inSession + ")", userID);
 			
 			conn = getConn();
             PreparedStatement stmt = getStatement(conn, getClosedOrdersSQL);
@@ -808,7 +817,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.traceEnter("TradeDirect:createQuote");
+			if (Log.doTrace()) Log.traceEnter("TradeDirect:createQuote - inSession(" + this.inSession + ")");
 			
 			price = price.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND);
 			double volume=0.0, change=0.0;
@@ -852,7 +861,7 @@
 		UserTransaction txn = null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getQuote", symbol);
+			if (Log.doTrace()) Log.trace("TradeDirect:getQuote - inSession(" + this.inSession + ")", symbol);
 
 			conn = getConn();
 			quoteData = getQuote(conn, symbol);			
@@ -951,7 +960,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getHoldings", userID);
+			if (Log.doTrace()) Log.trace("TradeDirect:getHoldings - inSession(" + this.inSession + ")", userID);
 			
 			conn = getConn();
             PreparedStatement stmt = getStatement(conn, getHoldingsForUserSQL);
@@ -989,7 +998,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getHolding", holdingID);
+			if (Log.doTrace()) Log.trace("TradeDirect:getHolding - inSession(" + this.inSession + ")", holdingID);
 			
 			conn = getConn();
 			holdingData = getHoldingData(holdingID.intValue());
@@ -1020,7 +1029,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getAccountData", userID);
+			if (Log.doTrace()) Log.trace("TradeDirect:getAccountData - inSession(" + this.inSession + ")", userID);
 			
 			conn = getConn();
 			accountData = getAccountData(conn, userID);
@@ -1072,7 +1081,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getAccountData", new Integer(accountID));
+			if (Log.doTrace()) Log.trace("TradeDirect:getAccountData - inSession(" + this.inSession + ")", new Integer(accountID));
 			
 			conn = getConn();
 			accountData = getAccountData(accountID, conn);
@@ -1236,7 +1245,7 @@
 	
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getAccountProfileData", userID);
+			if (Log.doTrace()) Log.trace("TradeDirect:getAccountProfileData - inSession(" + this.inSession + ")", userID);
 			
 			conn = getConn();
 			accountProfileData = getAccountProfileData(conn, userID);
@@ -1316,7 +1325,7 @@
 	
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:updateAccountProfileData", profileData.getUserID());
+			if (Log.doTrace()) Log.trace("TradeDirect:updateAccountProfileData - inSession(" + this.inSession + ")", profileData.getUserID());
 			
 			conn = getConn();
 			updateAccountProfile(conn, profileData);	
@@ -1439,7 +1448,7 @@
 		UserTransaction txn = null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:updateQuotePriceVolume", symbol, changeFactor, new Double(sharesTraded));		
+			if (Log.doTrace()) Log.trace("TradeDirect:updateQuotePriceVolume - inSession(" + this.inSession + ")", symbol, changeFactor, new Double(sharesTraded));		
 
 			conn = getConn();
 
@@ -1551,7 +1560,7 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.trace("TradeDirect:login", userID, password);
+			if (Log.doTrace()) Log.trace("TradeDirect:login - inSession(" + this.inSession + ")", userID, password);
 			
 			conn = getConn();
             PreparedStatement stmt = getStatement(conn, getAccountProfileSQL);
@@ -1613,7 +1622,7 @@
 	 * @see TradeServices#logout(String)
 	 */
 	public void logout(String userID) throws Exception {
-		if (Log.doTrace()) Log.trace("TradeDirect:logout", userID);
+		if (Log.doTrace()) Log.trace("TradeDirect:logout - inSession(" + this.inSession + ")", userID);
 		Connection conn=null;
 		try
 		{		
@@ -1654,12 +1663,12 @@
 		Connection conn=null;
 		try
 		{
-			if (Log.doTrace()) Log.traceEnter("TradeDirect:register");
+			if (Log.doTrace()) Log.traceEnter("TradeDirect:register - inSession(" + this.inSession + ")");
 			
 			conn = getConn();
             PreparedStatement stmt = getStatement(conn, createAccountSQL);
 
-			Integer accountID = KeySequenceDirect.getNextID(conn, "account", getInGlobalTxn());
+			Integer accountID = KeySequenceDirect.getNextID(conn, "account", inSession, getInGlobalTxn());
 			BigDecimal balance = openBalance;
 			Timestamp creationDate = new Timestamp(System.currentTimeMillis());
 			Timestamp lastLogin  = creationDate;
@@ -2071,8 +2080,10 @@
 	private void commit(Connection conn)
 	throws Exception
 	{
-		if ( (getInGlobalTxn()==false) && (conn != null) )
-			conn.commit();
+		if (!inSession) {
+			if ( (getInGlobalTxn()==false) && (conn != null) )
+				conn.commit();
+		}
 	}
 	
 
@@ -2083,12 +2094,14 @@
    private void rollBack(Connection conn, Exception e) 
    throws Exception 
    {
-   		Log.log("TradeDirect:rollBack -- rolling back conn due to previously caught exception -- inGlobalTxn=" + getInGlobalTxn());
-		if ( (getInGlobalTxn()==false) && (conn != null) )
-	        conn.rollback();
-	    else
-	    	throw e;  // Throw the exception 
-	    			  // so the Global txn manager will rollBack
+		if (!inSession) {
+   			Log.log("TradeDirect:rollBack -- rolling back conn due to previously caught exception -- inGlobalTxn=" + getInGlobalTxn());
+			if ( (getInGlobalTxn()==false) && (conn != null) )
+	        	conn.rollback();
+	    	else
+	    		throw e;  // Throw the exception 
+	    				  // so the Global txn manager will rollBack
+   		} 	
    } 	
 	
    /*

Added: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBC.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBC.java?view=auto&rev=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBC.java (added)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBC.java Thu Nov  2 15:40:39 2006
@@ -0,0 +1,120 @@
+package org.apache.geronimo.samples.daytrader.session;
+
+import javax.ejb.EJBObject;
+import java.rmi.Remote;
+import org.apache.geronimo.samples.daytrader.*;
+
+public interface TradeJDBC extends EJBObject, TradeServices, Remote {
+
+	   /**
+		 * Queue the Order identified by orderID to be processed in a One Phase commit
+		 * 
+		 * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
+		 * 2-phase commit transaction across Entity and MDB access
+		 * 
+		 * Orders are submitted through JMS to a Trading Broker
+		 * and completed asynchronously. This method queues the order for processing
+		 *
+		 * @param orderID the Order being queued for processing
+		 * @return OrderDataBean providing the status of the completed order
+		 */
+		//public void queueOrderOnePhase(Integer orderID) throws Exception;
+	   /**
+		 * Complete the Order identified by orderID in a One Phase commit
+		 * 
+		 * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
+		 * 2-phase commit transaction across Entity and MDB access
+		 * 
+		 * Orders are submitted through JMS to a Trading agent
+		 * and completed asynchronously. This method completes the order
+		 * For a buy, the stock is purchased creating a holding and the users account is debited
+		 * For a sell, the stock holding is removed and the users account is credited with the proceeds
+		 *
+		 * @param orderID the Order to complete
+		 * @return OrderDataBean providing the status of the completed order
+		 */
+		public OrderDataBean completeOrderOnePhase(Integer orderID) throws Exception;
+		
+	   /**
+		 * Complete the Order identified by orderID in a One Phase commit
+		 * using TradeDirect to complete the Order
+		 * 
+		 * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
+		 * 2-phase commit transaction across DB and MDB access
+		 * The EJB method is used only to start a new transaction so the direct runtime mode
+		 * for the completeOrder will run in a 1-phase commit
+		 * 
+		 * Orders are submitted through JMS to a Trading agent
+		 * and completed asynchronously. This method completes the order using TradeDirect
+		 * For a buy, the stock is purchased creating a holding and the users account is debited
+		 * For a sell, the stock holding is removed and the users account is credited with the proceeds
+		 *
+		 * @param orderID the Order to complete
+		 * @return OrderDataBean providing the status of the completed order
+		 */	
+	    //public OrderDataBean completeOrderOnePhaseDirect(Integer orderID) throws Exception;
+
+	   /**
+		 * Cancel the Order identefied by orderID
+		 * 
+		 * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
+		 * 2-phase commit transaction across Entity and MDB access
+		 * 
+		 * The boolean twoPhase specifies to the server implementation whether or not the
+		 * method is to participate in a global transaction
+		 *
+		 * @param orderID the Order to complete
+		 * @return OrderDataBean providing the status of the completed order
+		 */
+		public void cancelOrderOnePhase(Integer orderID) throws Exception;
+
+	   /**
+		 * Cancel the Order identefied by orderID
+		 * using TradeDirect to complete the Order
+		 * 
+		 * In short, this method is deployed as TXN REQUIRES NEW to avoid a 
+		 * 2-phase commit transaction across DB and MDB access
+		 * The EJB method is used only to start a new transaction so the direct runtime mode
+		 * for the cancleOrder will run in a 1-phase commit
+		 * 
+		 * The boolean twoPhase specifies to the server implementation whether or not the
+		 * method is to participate in a global transaction
+		 *
+		 * @param orderID the Order to complete
+		 * @return OrderDataBean providing the status of the completed order
+		 */
+		//public void cancelOrderOnePhaseDirect(Integer orderID) throws Exception;
+		
+	   /**
+		 * Publish to the QuoteChange Message topic when a stock
+		 * price and volume are updated
+		 * 
+		 * This method is deployed as TXN REQUIRES NEW to avoid a 
+		 * 2-phase commit transaction across the DB update and MDB access
+		 * (i.e. a failure to publish will not cause the stock update to fail
+		 *
+		 * @param quoteData - the updated Quote
+		 * @param oldPrice - the price of the Quote before the update
+		 * @param sharesTraded - the quantity of sharesTraded
+		 */
+		public void publishQuotePriceChange(QuoteDataBean quoteData, java.math.BigDecimal oldPrice, java.math.BigDecimal changeFactor,  double sharesTraded) throws Exception;
+		
+		/**
+		 * provides a simple session method with no database access to test performance of a simple
+		 * path through a stateless session 
+		 * @param investment amount
+		 * @param NetValue current value
+		 * @return return on investment as a percentage
+		 */
+		public double investmentReturn(double investment, double NetValue) throws Exception;	
+
+		/**
+		 * This method provides a ping test for a 2-phase commit operation
+		 * 
+		 * @param symbol to lookup
+		 * @return quoteData after sending JMS message
+		 */	
+		//public QuoteDataBean pingTwoPhase(String symbol) throws Exception;
+
+	}
+

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBC.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBC.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBC.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCBean.java?view=auto&rev=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCBean.java (added)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCBean.java Thu Nov  2 15:40:39 2006
@@ -0,0 +1,133 @@
+package org.apache.geronimo.samples.daytrader.session;
+
+import java.math.BigDecimal;
+import java.rmi.RemoteException;
+import java.util.Collection;
+
+import org.apache.geronimo.samples.daytrader.*;
+import org.apache.geronimo.samples.daytrader.direct.TradeDirect;
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import javax.ejb.*;
+
+
+public class TradeJDBCBean implements SessionBean {
+	private SessionContext context = null;
+	private TradeDirect tradeDirect = null;
+
+	public TradeJDBCBean() {
+	}
+
+	public void ejbCreate() throws CreateException {
+		if (Log.doTrace())
+			Log.trace("TradeJDBCBean:ejbCreate");
+	}
+
+	public void ejbRemove() {
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeJDBCBean:ejbRemove");
+		} catch (Exception e) {
+			Log.error(e, "Unable to close Queue or Topic connection on Session EJB remove");
+		}
+	}
+
+	public void ejbActivate() {
+	}
+
+	public void ejbPassivate() {
+	}
+
+	public void setSessionContext(SessionContext sc) {
+		this.context = sc;
+	}
+
+	public MarketSummaryDataBean getMarketSummary() throws Exception, RemoteException {
+		return (new TradeDirect(true)).getMarketSummary();
+	}
+
+
+	public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode) throws Exception, RemoteException {
+		return (new TradeDirect(true)).buy(userID, symbol, quantity, orderProcessingMode);
+	}
+
+	public OrderDataBean sell(String userID, Integer holdingID, int orderProcessingMode) throws Exception, RemoteException {
+		return (new TradeDirect(true)).sell(userID, holdingID, orderProcessingMode);
+	}
+
+	public void queueOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
+		(new TradeDirect(true)).queueOrder(orderID, twoPhase);
+	}
+
+	public OrderDataBean completeOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
+		return (new TradeDirect(true)).completeOrder(orderID, twoPhase);
+	}
+
+	public void cancelOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
+		(new TradeDirect(true)).cancelOrder(orderID, twoPhase);
+	}
+
+	public void orderCompleted(String userID, Integer orderID) throws Exception, RemoteException {
+		(new TradeDirect(true)).orderCompleted(userID, orderID);
+	}
+
+	public Collection getOrders(String userID) throws Exception, RemoteException {
+		return (new TradeDirect(true)).getOrders(userID);
+	}
+
+	public Collection getClosedOrders(String userID) throws Exception, RemoteException {
+		return (new TradeDirect(true)).getClosedOrders(userID);
+	}
+
+	public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price) throws Exception, RemoteException {
+		return (new TradeDirect(true)).createQuote(symbol, companyName, price);
+	}
+
+	public QuoteDataBean getQuote(String symbol) throws Exception, RemoteException {
+		return (new TradeDirect(true)).getQuote(symbol);
+	}
+
+	public Collection getAllQuotes() throws Exception, RemoteException {
+		return (new TradeDirect(true)).getAllQuotes();
+	}
+
+	public QuoteDataBean updateQuotePriceVolume(String symbol, BigDecimal newPrice, double sharesTraded) throws Exception, RemoteException {
+		return (new TradeDirect(true)).updateQuotePriceVolume(symbol, newPrice, sharesTraded);
+	}
+
+	public Collection getHoldings(String userID) throws Exception, RemoteException {
+		return (new TradeDirect(true)).getHoldings(userID);
+	}
+
+	public HoldingDataBean getHolding(Integer holdingID) throws Exception, RemoteException {
+		return (new TradeDirect(true)).getHolding(holdingID);
+	}
+
+	public AccountDataBean getAccountData(String userID) throws javax.ejb.FinderException, Exception {
+		return (new TradeDirect(true)).getAccountData(userID);
+	}
+
+	public AccountProfileDataBean getAccountProfileData(String userID) throws Exception, RemoteException {
+		return (new TradeDirect(true)).getAccountProfileData(userID);
+	}
+
+	public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData) throws Exception, RemoteException {
+		return (new TradeDirect(true)).updateAccountProfile(profileData);
+	}
+
+	public AccountDataBean login(String userID, String password) throws Exception, RemoteException {
+		return (new TradeDirect(true)).login(userID, password);
+	}
+
+	public void logout(String userID) throws Exception, RemoteException {
+		(new TradeDirect(true)).logout(userID);
+	}
+
+	public AccountDataBean register(String userID, String password, String fullname, String address, String email, String creditcard, BigDecimal openBalance) throws Exception, RemoteException {
+		return (new TradeDirect(true)).register(userID, password, fullname, address, email, creditcard, openBalance);
+	}
+
+	public RunStatsDataBean resetTrade(boolean deleteAll) throws Exception, RemoteException {
+		return (new TradeDirect(true)).resetTrade(deleteAll);
+	}
+}

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCHome.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCHome.java?view=auto&rev=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCHome.java (added)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCHome.java Thu Nov  2 15:40:39 2006
@@ -0,0 +1,12 @@
+package org.apache.geronimo.samples.daytrader.session;
+
+import java.rmi.RemoteException;
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+public interface TradeJDBCHome extends EJBHome {
+ 
+    TradeJDBC create() throws RemoteException, CreateException;
+
+}
+

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCHome.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCHome.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/session/TradeJDBCHome.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/daytrader/branches/1.2/modules/ejb/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=470600&r1=470599&r2=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/resources/META-INF/ejb-jar.xml (original)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/resources/META-INF/ejb-jar.xml Thu Nov  2 15:40:39 2006
@@ -112,6 +112,20 @@
                 <use-caller-identity/>
             </security-identity>
         </session>
+        <session>
+            <description>Trade JDBC Session EJB manages all Trading services</description>
+            <display-name>TradeJDBC</display-name>
+            <ejb-name>TradeJDBC</ejb-name>
+            <home>org.apache.geronimo.samples.daytrader.session.TradeJDBCHome</home>
+            <remote>org.apache.geronimo.samples.daytrader.session.TradeJDBC</remote>
+            <ejb-class>org.apache.geronimo.samples.daytrader.session.TradeJDBCBean</ejb-class>
+            <session-type>Stateless</session-type>
+            <transaction-type>Container</transaction-type>
+            <security-identity>
+                <description/>
+                <use-caller-identity/>
+            </security-identity>
+        </session>
         <entity>
             <display-name>HoldingEJB</display-name>
             <ejb-name>HoldingEJB</ejb-name>
@@ -818,6 +832,10 @@
                 <ejb-name>TradeEJB</ejb-name>
                 <method-name>*</method-name>
             </method>
+            <method>
+                <ejb-name>TradeJDBC</ejb-name>
+                <method-name>*</method-name>
+            </method>
         </method-permission>
         <container-transaction>
             <method>
@@ -855,6 +873,41 @@
                     <method-param>java.lang.Integer</method-param>
                 </method-params>
             </method>
+            <method>
+        		<ejb-name>TradeJDBC</ejb-name>
+        		<method-intf>Remote</method-intf>
+        		<method-name>cancelOrderOnePhase</method-name>
+        		<method-params>
+        			<method-param>java.lang.Integer</method-param>
+        		</method-params>
+        	</method>
+        	<method>
+        		<ejb-name>TradeJDBC</ejb-name>
+        		<method-intf>Remote</method-intf>
+        		<method-name>completeOrderOnePhaseDirect</method-name>
+        		<method-params>
+        			<method-param>java.lang.Integer</method-param>
+        		</method-params>
+        	</method>
+        	<method>
+        		<ejb-name>TradeJDBC</ejb-name>
+        		<method-intf>Remote</method-intf>
+        		<method-name>publishQuotePriceChange</method-name>
+        		<method-params>
+        			<method-param>com.ibm.websphere.samples.trade.QuoteDataBean</method-param>
+        			<method-param>java.math.BigDecimal</method-param>
+        			<method-param>java.math.BigDecimal</method-param>
+        			<method-param>double</method-param>
+        		</method-params>
+        	</method>
+        	<method>
+        		<ejb-name>TradeJDBC</ejb-name>
+        		<method-intf>Remote</method-intf>
+        		<method-name>queueOrderOnePhase</method-name>
+        		<method-params>
+        			<method-param>java.lang.Integer</method-param>
+        		</method-params>
+        	</method>
             <trans-attribute>RequiresNew</trans-attribute>
         </container-transaction>
         <container-transaction>
@@ -882,6 +935,30 @@
                     <method-param>boolean</method-param>
                 </method-params>
             </method>
+            <method>
+        		<ejb-name>TradeJDBC</ejb-name>
+        		<method-intf>Remote</method-intf>
+        		<method-name>cancelOrderOnePhaseDirect</method-name>
+        		<method-params>
+        			<method-param>java.lang.Integer</method-param>
+        		</method-params>
+        	</method>
+        	<method>
+        		<ejb-name>TradeJDBC</ejb-name>
+        		<method-intf>Remote</method-intf>
+        		<method-name>completeOrderOnePhaseDirect</method-name>
+        		<method-params>
+        			<method-param>java.lang.Integer</method-param>
+        		</method-params>
+        	</method>
+        	<method>
+        		<ejb-name>TradeJDBC</ejb-name>
+        		<method-intf>Remote</method-intf>
+        		<method-name>resetTrade</method-name>
+        		<method-params>
+        			<method-param>boolean</method-param>
+        		</method-params>
+        	</method>
             <trans-attribute>NotSupported</trans-attribute>
         </container-transaction>
         <container-transaction>
@@ -925,6 +1002,10 @@
                 <ejb-name>TradeStreamerMDB</ejb-name>
                 <method-name>*</method-name>
             </method>
+            <method>
+        		<ejb-name>TradeJDBC</ejb-name>
+        		<method-name>*</method-name>
+        	</method>
             <trans-attribute>Required</trans-attribute>
         </container-transaction>
         <message-destination>

Added: geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBC.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBC.java?view=auto&rev=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBC.java (added)
+++ geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBC.java Thu Nov  2 15:40:39 2006
@@ -0,0 +1,177 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable 
+ *
+ *  Licensed 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.web.prims;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.naming.*;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.geronimo.samples.daytrader.ejb.*;
+import org.apache.geronimo.samples.daytrader.session.TradeJDBC;
+import org.apache.geronimo.samples.daytrader.session.TradeJDBCHome;
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+// TODO: fix comments
+/**
+ *
+ * PingServlet2Session2JDBC tests key functionality of a servlet call to a 
+ * stateless SessionEJB, and then to a Entity EJB representing data in a database.
+ * This servlet makes use of the Stateless Session EJB {@link Trade}, and then
+ * uses {@link TradeConfig} to generate a random stock symbol.  The stocks
+ * price is looked up using the Quote Entity EJB.  
+ *
+ */
+public class PingServlet2Session2JDBC extends HttpServlet
+{
+
+	private static String initTime;
+	private static int hitCount;
+	private static TradeJDBCHome tradeJDBCHome;
+
+	/**
+	 * forwards post requests to the doGet method
+	 * Creation date: (11/6/2000 10:52:39 AM)
+	 * @param res javax.servlet.http.HttpServletRequest
+	 * @param res2 javax.servlet.http.HttpServletResponse
+	 */
+	public void doPost(HttpServletRequest req, HttpServletResponse res)
+		throws ServletException, IOException
+	{
+		doGet(req, res);
+	}
+
+	/**
+	* this is the main method of the servlet that will service all get requests.
+	* @param request HttpServletRequest
+	* @param responce HttpServletResponce
+	**/
+	public void doGet(HttpServletRequest req, HttpServletResponse res)
+		throws IOException, ServletException
+	{
+
+		res.setContentType("text/html");
+		java.io.PrintWriter out = res.getWriter();
+		String symbol = null;
+		QuoteDataBean quoteData = null;
+		TradeJDBC trade = null;
+		StringBuffer output = new StringBuffer(100);
+
+		output.append(
+			"<html><head><title>PingServlet2Session2JDBC</title></head>"
+				+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2Session2JDBC<BR></FONT>"
+				+ "<FONT size=\"-1\" color=\"#000066\">"
+				+ "PingServlet2Session2JDBC tests the common path of a Servlet calling a Session EJB "
+				+ "which in turn calls JDBC.<BR>");
+
+		try
+			{
+
+			//only want to do this once.
+			if (tradeJDBCHome == null)
+				{
+				//only want one thread to create the EjbHome
+				synchronized (lock)
+				{
+
+					if (tradeJDBCHome == null)
+						{
+
+						//out.println("doing JNDI lookup and creating new reference to trade.TradeHome");
+						output.append("<HR><B>Performing JNDI lookup to create new tradeHome</B>");
+
+						try
+							{
+							//I am going to use the System env. that is set through TradeConfig
+							InitialContext ic = new InitialContext();
+
+							tradeJDBCHome =
+								(TradeJDBCHome) PortableRemoteObject.narrow(
+									ic.lookup("java:comp/env/ejb/TradeJDBC"),
+									TradeJDBCHome.class);
+						}
+						catch (Exception ne)
+							
+						{
+							Log.error(ne, "PingServlet2Session2JDBC.goGet(...): exception caught looking up and narrowing 'TradeJDBCHome'");
+							throw ne;
+						}
+					}
+				}
+			}
+
+			try
+				{
+				int iter = TradeConfig.getPrimIterations();
+				for (int ii = 0; ii < iter; ii++) {
+					//I have the TradeBean Home, now I want to get an instance every time
+					symbol = TradeConfig.rndSymbol();
+					trade = tradeJDBCHome.create();
+					//getQuote will call findQuote which will instaniate the Quote Entity Bean
+					//and then will return a QuoteObject
+					quoteData = trade.getQuote(symbol);
+					trade.remove();
+				}
+			}
+			catch (Exception ne)
+				{
+				Log.error(ne, "PingServlet2Session2JDBC.goGet(...): exception getting QuoteData through Trade");
+				throw ne;
+			}
+
+			output.append("<HR>initTime: " + initTime).append(
+				"<BR>Hit Count: " + hitCount++);
+			output.append("<HR>Quote Information<BR><BR>" + quoteData.toHTML());
+			out.println(output.toString());
+
+		}
+		catch (Exception e)
+			{
+			Log.error(e, "PingServlet2Session2JDBC.doGet(...): General Exception caught");
+			res.sendError(500, "General Exception caught, " + e.toString());
+		}
+	}
+
+	/** 
+	 * returns a string of information about the servlet
+	 * @return info String: contains info about the servlet
+	 **/
+
+	public String getServletInfo()
+	{
+		return "web primitive, tests Servlet to Session to Entity EJB path";
+
+	}
+	/**
+	* called when the class is loaded to initialize the servlet
+	* @param config ServletConfig:
+	**/
+	public void init(ServletConfig config) throws ServletException
+	{
+		super.init(config);
+		hitCount = 0;
+		tradeJDBCHome = null;
+		initTime = new java.util.Date().toString();
+		//this is for synchronization
+		lock = new Integer(99);
+	}
+	private java.lang.Integer lock;
+}
\ No newline at end of file

Propchange: geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBC.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBC.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBC.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBCCollection.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBCCollection.java?view=auto&rev=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBCCollection.java (added)
+++ geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBCCollection.java Thu Nov  2 15:40:39 2006
@@ -0,0 +1,184 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable 
+ *
+ *  Licensed 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.web.prims;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import java.util.Collection;
+import java.util.Iterator;
+import javax.naming.*;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.geronimo.samples.daytrader.ejb.*;
+import org.apache.geronimo.samples.daytrader.session.TradeJDBC;
+import org.apache.geronimo.samples.daytrader.session.TradeJDBCHome;
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+// TODO: Fix comments
+/**
+ *
+ * PingServlet2Session2Entity tests key functionality of a servlet call to a 
+ * stateless SessionEJB, and then to a Entity EJB representing data in a database.
+ * This servlet makes use of the Stateless Session EJB {@link Trade}, and then
+ * uses {@link TradeConfig} to generate a random user.  The users
+ * portfolio is looked up using the Holding Entity EJB returnin a collection of Holdings
+ *
+ */
+public class PingServlet2Session2JDBCCollection extends HttpServlet
+{
+
+	private static String initTime;
+	private static int hitCount;
+	private static TradeJDBCHome tradeJDBCHome;
+
+	/**
+	 * forwards post requests to the doGet method
+	 * Creation date: (11/6/2000 10:52:39 AM)
+	 * @param res javax.servlet.http.HttpServletRequest
+	 * @param res2 javax.servlet.http.HttpServletResponse
+	 */
+	public void doPost(HttpServletRequest req, HttpServletResponse res)
+		throws ServletException, IOException
+	{
+		doGet(req, res);
+	}
+
+	/**
+	* this is the main method of the servlet that will service all get requests.
+	* @param request HttpServletRequest
+	* @param responce HttpServletResponce
+	**/
+	public void doGet(HttpServletRequest req, HttpServletResponse res)
+		throws IOException, ServletException
+	{
+
+		res.setContentType("text/html");
+		java.io.PrintWriter out = res.getWriter();
+		String userID = null;
+		Collection holdingDataBeans = null;
+		TradeJDBC trade = null;
+		StringBuffer output = new StringBuffer(100);
+
+		output.append(
+			"<html><head><title>PingServlet2Session2JDBCCollection</title></head>"
+				+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2Session2JDBCCollection<BR></FONT>"
+				+ "<FONT size=\"-1\" color=\"#000066\">"
+				+ "PingServlet2Session2JDBCCollection tests the common path of a Servlet calling a Session EJB "
+				+ "which perform a multi-row JDBC query.<BR>");
+
+		try
+			{
+
+			//only want to do this once.
+			if (tradeJDBCHome == null)
+				{
+				//only want one thread to create the EjbHome
+				synchronized (lock)
+				{
+
+					if (tradeJDBCHome == null)
+						{
+
+						//out.println("doing JNDI lookup and creating new reference to trade.TradeHome");
+						output.append("<HR><B>Performing JNDI lookup to create new tradeHome</B>");
+
+						try
+							{
+							//I am going to use the System env. that is set through TradeConfig
+							InitialContext ic = new InitialContext();
+
+							tradeJDBCHome =
+								(TradeJDBCHome) PortableRemoteObject.narrow(
+									ic.lookup("java:comp/env/ejb/TradeJDBC"),
+									TradeJDBCHome.class);
+						}
+						catch (Exception ne)
+							
+						{
+							Log.error(ne, "PingServlet2Session2JDBCCollection.goGet(...): exception caught looking up and narrowing 'TradeHome'");
+							throw ne;
+						}
+					}
+				}
+			}
+
+			try
+				{
+				int iter = TradeConfig.getPrimIterations();
+				for (int ii = 0; ii < iter; ii++) {
+					//I have the TradeBean Home, now I want to get an instance every time
+					userID = TradeConfig.rndUserID();
+					trade = tradeJDBCHome.create();
+					//getQuote will call findQuote which will instaniate the Quote Entity Bean
+					//and then will return a QuoteObject
+					holdingDataBeans = trade.getHoldings(userID);
+					trade.remove();
+				}
+			}
+			catch (Exception ne)
+				{
+				Log.error(ne, "PingServlet2Session2JDBCCollection.goGet(...): exception getting HoldingData collection through Trade for user "+ userID);
+				throw ne;
+			}
+
+			output.append("<HR>initTime: " + initTime).append(
+				"<BR>Hit Count: " + hitCount++);
+			output.append("<HR>User: " + userID + " is currently holding " + holdingDataBeans.size() + " stock holdings:");
+			Iterator it = holdingDataBeans.iterator();
+			while ( it.hasNext() )
+			{
+				HoldingDataBean holdingData = (HoldingDataBean) it.next();
+				output.append("<BR>" + holdingData.toHTML());
+			}
+			out.println(output.toString());
+
+		}
+		catch (Exception e)
+			{
+			Log.error(e, "PingServlet2Session2JDBCCollection.doGet(...): General Exception caught");
+			res.sendError(500, "General Exception caught, " + e.toString());
+		}
+	}
+
+	/** 
+	 * returns a string of information about the servlet
+	 * @return info String: contains info about the servlet
+	 **/
+
+	public String getServletInfo()
+	{
+		return "web primitive, tests Servlet to Session to Entity returning a collection of Entity EJBs";
+	}
+	/**
+	* called when the class is loaded to initialize the servlet
+	* @param config ServletConfig:
+	**/
+	public void init(ServletConfig config) throws ServletException
+	{
+		super.init(config);
+		hitCount = 0;
+		tradeJDBCHome = null;
+		initTime = new java.util.Date().toString();
+		//this is for synchronization
+		lock = new Integer(99);
+	}
+	private java.lang.Integer lock;
+}
\ No newline at end of file

Propchange: geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBCCollection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBCCollection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/daytrader/branches/1.2/modules/web/src/main/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2JDBCCollection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/WEB-INF/web.xml?view=diff&rev=470600&r1=470599&r2=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/WEB-INF/web.xml (original)
+++ geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/WEB-INF/web.xml Thu Nov  2 15:40:39 2006
@@ -199,6 +199,16 @@
          <servlet-class>org.apache.geronimo.samples.daytrader.web.prims.PingServlet2Session2EntityCollection</servlet-class>
       </servlet>
       <servlet>
+         <display-name>PingServlet2Session2JDBC</display-name>
+         <servlet-name>PingServlet2Session2JDBC</servlet-name>
+         <servlet-class>org.apache.geronimo.samples.daytrader.web.prims.PingServlet2Session2JDBC</servlet-class>
+      </servlet>
+      <servlet>
+         <display-name>PingServlet2Session2JDBCCollection</display-name>
+         <servlet-name>PingServlet2Session2JDBCCollection</servlet-name>
+         <servlet-class>org.apache.geronimo.samples.daytrader.web.prims.PingServlet2Session2JDBCCollection</servlet-class>
+      </servlet>
+      <servlet>
          <display-name>PingServlet2Session2CMROne2One</display-name>
          <servlet-name>PingServlet2Session2CMROne2One</servlet-name>
          <servlet-class>org.apache.geronimo.samples.daytrader.web.prims.PingServlet2Session2CMROne2One</servlet-class>
@@ -331,6 +341,14 @@
          <url-pattern>/servlet/PingServlet2Session2EntityCollection</url-pattern>
       </servlet-mapping>
       <servlet-mapping>
+         <servlet-name>PingServlet2Session2JDBC</servlet-name>
+         <url-pattern>/servlet/PingServlet2Session2JDBC</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping>
+         <servlet-name>PingServlet2Session2JDBCCollection</servlet-name>
+         <url-pattern>/servlet/PingServlet2Session2JDBCCollection</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping>
          <servlet-name>PingServlet2Session2CMROne2One</servlet-name>
          <url-pattern>/servlet/PingServlet2Session2CMROne2One</url-pattern>
       </servlet-mapping>
@@ -396,6 +414,13 @@
          <home>org.apache.geronimo.samples.daytrader.ejb.TradeHome</home>
          <remote>org.apache.geronimo.samples.daytrader.ejb.Trade</remote>
          <ejb-link>TradeEJB</ejb-link>
+      </ejb-ref>
+      <ejb-ref>
+         <ejb-ref-name>ejb/TradeJDBC</ejb-ref-name>
+         <ejb-ref-type>Session</ejb-ref-type>
+         <home>org.apache.geronimo.samples.daytrader.session.TradeJDBCHome</home>
+         <remote>org.apache.geronimo.samples.daytrader.session.TradeJDBC</remote>
+         <ejb-link>TradeJDBC</ejb-link>
       </ejb-ref>
       <ejb-ref>
          <ejb-ref-name>ejb/Quote</ejb-ref-name>

Modified: geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/web_prmtv.html
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/web_prmtv.html?view=diff&rev=470600&r1=470599&r2=470600
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/web_prmtv.html (original)
+++ geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/web_prmtv.html Thu Nov  2 15:40:39 2006
@@ -215,6 +215,20 @@
 			Entity EJB's data through an EJB 2.0 CMR One to Many relationship </FONT></TD>
 		</TR>
 		<TR>
+			<TD align="center"><A href="servlet/PingServlet2Session2JDBC"><FONT
+				size="-1">PingServlet2Session2JDBC</FONT></A><FONT COLOR="#FF0000">*</FONT></TD>
+			<TD><FONT size="-1">This tests the full servlet to Session EJB to
+			JDBC path to retrieve a single row from the database.</FONT></TD>
+		</TR>
+		<TR>
+			<TD align="center"><A
+				href="servlet/PingServlet2Session2JDBCCollection"><FONT size="-1">PingServlet2Session2<BR>
+			JDBCCollection</FONT></A><FONT COLOR="#FF0000">*</FONT></TD>
+			<TD><FONT size="-1">This test extends the previous JDBC test by
+			calling a Session EJB to JDBC path which returns multiple rows
+			from the database.</FONT></TD>
+		</TR>
+		<TR>
 			<TD align="center"><A href="servlet/PingServlet2MDBQueue"><FONT
 				size="-1">PingServlet2MDBQueue</FONT></A><FONT COLOR="#FF0000">*</FONT></TD>
 			<TD><FONT size="-1">PingServlet2MDBQueue drives messages to a Queue



Mime
View raw message