geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r290479 [9/16] - in /geronimo/trunk/sandbox/daytrader: ./ bin/ derby/ modules/ modules/core/ modules/core/src/ modules/core/src/conf/ modules/core/src/java/ modules/core/src/java/org/ modules/core/src/java/org/apache/ modules/core/src/java/...
Date Tue, 20 Sep 2005 16:08:17 GMT
Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2IncludeRcv.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2IncludeRcv.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2IncludeRcv.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2IncludeRcv.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,55 @@
+/**
+ *
+ * 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.*;
+
+/**
+ *
+ * PingServlet2Include tests servlet to servlet request dispatching. Servlet 1,
+ * the controller, creates a new JavaBean object forwards the servlet request with
+ * the JavaBean added to Servlet 2. Servlet 2 obtains access to the JavaBean through
+ * the Servlet request object and provides the dynamic HTML output based on the JavaBean
+ * data.
+ * PingServlet2Servlet is the initial servlet that sends a request to {@link PingServlet2ServletRcv}
+ *
+ */
+public class PingServlet2IncludeRcv extends HttpServlet {
+
+	/**
+	 * 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 ServletException, IOException {
+		// do nothing but get included by PingServlet2Include
+	}
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2JNDI.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2JNDI.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2JNDI.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2JNDI.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,109 @@
+/**
+ *
+ * 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.InitialContext;
+import javax.sql.DataSource;
+
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ * 
+ * PingServlet2JNDI performs a basic JNDI lookup of a JDBC DataSource
+ * 
+ */
+
+public class PingServlet2JNDI extends HttpServlet
+{
+
+	private static String initTime;
+	private static int hitCount;
+	
+	/**
+	 * 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 ServletException, IOException
+	{
+		res.setContentType("text/html");
+		java.io.PrintWriter out = res.getWriter();
+
+		StringBuffer output = new StringBuffer(100);
+
+		try
+			{
+
+			int iter = TradeConfig.getPrimIterations();
+			for (int ii = 0; ii < iter; ii++) {
+				InitialContext context = new InitialContext();
+				DataSource datasource = (DataSource) context.lookup(TradeConfig.DS_NAME);
+			}			
+
+			output.append(
+				"<html><head><title>Ping JNDI -- lookup of JDBC DataSource</title></head>"
+					+ "<body><HR><FONT size=\"+2\" color=\"#000066\">Ping JNDI -- lookup of JDBC DataSource</FONT><HR><FONT size=\"-1\" color=\"#000066\">Init time : "
+					+ initTime);
+			hitCount++;
+			output.append("</FONT><BR>Hit Count: " + hitCount);
+			output.append("<HR></body></html>");
+			out.println(output.toString());
+		}
+		catch (Exception e)
+		{
+			Log.error(e, "PingServlet2JNDI -- error look up of a JDBC DataSource");
+			res.sendError(500, "PingServlet2JNDI Exception caught: " + e.toString());
+		}
+
+	}
+	/** 
+	 * returns a string of information about the servlet
+	 * @return info String: contains info about the servlet
+	 **/
+	public String getServletInfo()
+	{
+		return "Basic JNDI look up of a JDBC DataSource";
+	}
+	/**
+	* 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;
+		initTime = new java.util.Date().toString();
+	}
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Jsp.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Jsp.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Jsp.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Jsp.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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 org.apache.geronimo.samples.daytrader.util.*;
+
+
+/**
+ *
+ * PingServlet2JSP tests a call from a servlet to a JavaServer Page providing server-side dynamic
+ * HTML through JSP scripting.
+ *
+ */
+public class PingServlet2Jsp extends HttpServlet {
+	private static int hitCount = 0;
+
+/**
+ * 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 ServletException, IOException {
+	PingBean ab;
+	try
+	{
+		ab = new PingBean();
+                hitCount++;
+		ab.setMsg("Hit Count: " + hitCount);
+		req.setAttribute("ab", ab);
+		
+		getServletConfig().getServletContext().getRequestDispatcher("/PingServlet2Jsp.jsp").forward(req, res);
+	}
+	catch (Exception ex)
+	{
+		Log.error(
+			ex,"PingServlet2Jsp.doGet(...): request error"); 
+		res.sendError(
+			500, 
+			"PingServlet2Jsp.doGet(...): request error"
+				+ ex.toString()); 
+
+	}
+}
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2MDBQueue.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2MDBQueue.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2MDBQueue.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2MDBQueue.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,186 @@
+/**
+ *
+ * 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.jms.*;
+
+import org.apache.geronimo.samples.daytrader.ejb.*;
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ *
+ * This primitive is designed to run inside the TradeApplication and relies upon
+ * the {@link trade_client.TradeConfig} class to set configuration 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 message to the MDB Queue
+ *
+ */
+public class PingServlet2MDBQueue extends HttpServlet {
+
+	private static String initTime;
+	private static int hitCount;
+	private static Connection conn;
+	private static ConnectionFactory connFactory;
+	private static Queue queue;
+
+/**
+ * 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();
+	Trade trade = null;
+	//use a stringbuffer to avoid concatenation of Strings
+	StringBuffer output = new StringBuffer(100);
+	output.append(
+		"<html><head><title>PingServlet2MDBQueue</title></head>"
+			+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2MDBQueue<BR></FONT>"
+			+ "<FONT size=\"-1\" color=\"#000066\">"
+			+ "Tests the basic operation of a servlet posting a message to an EJB MDB through a JMS Queue."); 
+
+	//we only want to look up the JMS resources once	
+	try
+	{
+		
+		if (conn == null)
+		{
+		
+			synchronized (lock)
+			{
+				if (conn == null)
+				{
+			
+					try 
+					{
+						output.append("<HR><B>Performing JNDI lookups and creating JMS Resources</B>");						
+						InitialContext context = new InitialContext();
+						connFactory = (ConnectionFactory) context.lookup("java:comp/env/jms/QueueConnectionFactory");
+						queue = (Queue) context.lookup("java:comp/env/jms/TradeBrokerQueue");
+						// TODO: Is this wrong as it only creates one shared connecton?
+						conn = connFactory.createConnection();
+		
+					}
+					catch (Exception e)
+					{
+						Log.error("PingServlet2MDBQueue:doGet() -- error on intialization of JMS factories, queues", e);
+						throw e;
+					}		
+				}
+			}
+		}
+		
+		try
+		{
+			TextMessage message = null;
+			int iter = TradeConfig.getPrimIterations();
+			for (int ii = 0; ii < iter; ii++) {
+				Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+				MessageProducer producer = sess.createProducer(queue);
+	
+				message = sess.createTextMessage();
+	
+				String command= "ping";
+				message.setStringProperty("command", command);
+				message.setLongProperty("publishTime", System.currentTimeMillis());			
+				message.setText("Ping message for queue java:comp/env/jms/TradeBrokerQueue sent from PingServlet2MDBQueue at " + new java.util.Date());
+				producer.send(message);
+				sess.close();
+			}
+			
+			//write out the output
+			output.append("<HR>initTime: " + initTime);
+			output.append("<BR>Hit Count: " + hitCount++);
+			output.append("<HR>Posted Text message to java:comp/env/jms/TradeBrokerQueue destination");
+			output.append("<BR>Message: " + message);
+			output.append("<BR><BR>Message text: " + message.getText());						
+			output.append(
+				"<BR><HR></FONT></BODY></HTML>"); 
+			out.println(output.toString());
+
+		}
+		catch (Exception e)
+		{
+			Log.error("PingServlet2MDBQueue.doGet(...):exception posting message to TradeBrokerQueue destination "); 
+			throw e;
+		}
+	} //this is where I actually handle the exceptions
+	catch (Exception e)
+	{
+		Log.error(e, "PingServlet2MDBQueue.doGet(...): error"); 
+		res.sendError(500, "PingServlet2MDBQueue.doGet(...): error, " + e.toString());
+
+	}
+}                           
+
+
+
+
+/** 
+ * returns a string of information about the servlet
+ * @return info String: contains info about the servlet
+ **/
+
+public String getServletInfo()
+{
+	return "web primitive, configured with trade runtime configs, tests Servlet to Session 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;
+	initTime = new java.util.Date().toString();
+	//for synchronization
+	lock = new Integer(99);
+}      
+
+
+
+
+;
+
+
+	private java.lang.Integer lock;}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2MDBTopic.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2MDBTopic.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2MDBTopic.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2MDBTopic.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,181 @@
+/**
+ *
+ * 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.jms.*;
+
+import org.apache.geronimo.samples.daytrader.ejb.*;
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ *
+ * This primitive is designed to run inside the TradeApplication and relies upon
+ * the {@link trade_client.TradeConfig} class to set configuration 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 posting a message to the MDB Topic
+ *
+ */
+public class PingServlet2MDBTopic extends HttpServlet {
+
+	private static String initTime;
+	private static int hitCount;
+	private static Connection conn;
+	private static ConnectionFactory connFactory;
+	private static Topic topic;
+
+/**
+ * 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();
+	Trade trade = null;
+	//use a stringbuffer to avoid concatenation of Strings
+	StringBuffer output = new StringBuffer(100);
+	output.append(
+		"<html><head><title>PingServlet2MDBTopic</title></head>"
+			+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2MDBTopic<BR></FONT>"
+			+ "<FONT size=\"-1\" color=\"#000066\">"
+			+ "Tests the basic operation of a servlet posting a message to an EJB MDB (and other subscribers) through a JMS Topic."); 
+
+	//we only want to look up the JMS resources once	
+	try
+	{
+		
+		if (conn == null)
+		{
+		
+			synchronized (lock)
+			{
+				if (conn == null)
+				{
+			
+					try 
+					{
+						output.append("<HR><B>Performing JNDI lookups and creating JMS Resources</B>");						
+						InitialContext context = new InitialContext();
+						connFactory = (ConnectionFactory) context.lookup("java:comp/env/jms/TopicConnectionFactory");
+						topic = (Topic) context.lookup("java:comp/env/jms/TradeStreamerTopic");
+						// TODO: Is this wrong as it only creates one shared connecton?
+						conn = connFactory.createConnection();		            			
+					}
+					catch (Exception e)
+					{
+						Log.error("PingServlet2MDBTopic:doGet() -- error on intialization of JMS factories, topics", e);
+						throw e;
+					}		
+				}
+			}
+		}
+		
+		try
+		{
+			TextMessage message = null;
+			int iter = TradeConfig.getPrimIterations();
+			for (int ii = 0; ii < iter; ii++) {
+				Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+				MessageProducer producer = sess.createProducer(topic);
+				message = sess.createTextMessage();
+	
+				String command= "ping";
+				message.setStringProperty("command", command);
+				message.setLongProperty("publishTime", System.currentTimeMillis());
+				message.setText("Ping message for topic java:comp/env/jms/TradeStreamerTopic sent from PingServlet2MDBTopic at " + new java.util.Date());
+	
+				producer.send(message);
+				sess.close();
+			}					
+
+			//write out the output
+			output.append("<HR>initTime: " + initTime);
+			output.append("<BR>Hit Count: " + hitCount++);
+			output.append("<HR>Posted Text message to java:comp/env/jms/TradeStreamerTopic topic");
+			output.append("<BR>Message: " + message);
+			output.append("<BR><BR>Message text: " + message.getText());			
+			output.append(
+				"<BR><HR></FONT></BODY></HTML>"); 
+			out.println(output.toString());
+
+		}
+		catch (Exception e)
+		{
+			Log.error("PingServlet2MDBTopic.doGet(...):exception posting message to TradeStreamerTopic topic"); 
+			throw e;
+		}
+	} //this is where I actually handle the exceptions
+	catch (Exception e)
+	{
+		Log.error(e, "PingServlet2MDBTopic.doGet(...): error"); 
+		res.sendError(500, "PingServlet2MDBTopic.doGet(...): error, " + e.toString());
+
+	}
+}                           
+
+
+
+
+/** 
+ * returns a string of information about the servlet
+ * @return info String: contains info about the servlet
+ **/
+
+public String getServletInfo()
+{
+	return "web primitive, configured with trade runtime configs, tests Servlet to Session 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;
+	initTime = new java.util.Date().toString();
+	//for synchronization
+	lock = new Integer(99);
+}      
+
+
+	private java.lang.Integer lock;}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Servlet.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Servlet.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Servlet.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Servlet.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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 org.apache.geronimo.samples.daytrader.util.*;
+
+
+/**
+ *
+ * PingServlet2Servlet tests servlet to servlet request dispatching. Servlet 1,
+ * the controller, creates a new JavaBean object forwards the servlet request with
+ * the JavaBean added to Servlet 2. Servlet 2 obtains access to the JavaBean through
+ * the Servlet request object and provides the dynamic HTML output based on the JavaBean
+ * data.
+ * PingServlet2Servlet is the initial servlet that sends a request to {@link PingServlet2ServletRcv}
+ *
+ */
+public class PingServlet2Servlet extends HttpServlet {
+	private static int hitCount = 0;
+
+/**
+ * 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 ServletException, IOException {
+	PingBean ab;
+	try
+	{
+		ab = new PingBean();
+		hitCount++;
+		ab.setMsg("Hit Count: " + hitCount);
+		req.setAttribute("ab", ab);
+		
+		getServletConfig().getServletContext().getRequestDispatcher("/servlet/PingServlet2ServletRcv").forward(req, res);
+	}
+	catch (Exception ex)
+	{
+		Log.error(
+			ex,	"PingServlet2Servlet.doGet(...): general exception"); 
+		res.sendError(500, "PingServlet2Servlet.doGet(...): general exception" + ex.toString()); 
+
+	}
+}   
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2ServletRcv.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2ServletRcv.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2ServletRcv.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2ServletRcv.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,92 @@
+/**
+ *
+ * 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 org.apache.geronimo.samples.daytrader.util.*;
+
+
+/**
+ *
+ * PingServlet2Servlet tests servlet to servlet request dispatching. Servlet 1,
+ * the controller, creates a new JavaBean object forwards the servlet request with
+ * the JavaBean added to Servlet 2. Servlet 2 obtains access to the JavaBean through
+ * the Servlet request object and provides the dynamic HTML output based on the JavaBean
+ * data.
+ * PingServlet2ServletRcv receives a request from {@link PingServlet2Servlet} and displays output.
+ *
+ */
+public class PingServlet2ServletRcv extends HttpServlet {
+	private static String initTime = null;
+
+/**
+ * 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 ServletException, IOException {
+	PingBean ab;
+	try
+	{
+		ab = (PingBean) req.getAttribute("ab");
+		res.setContentType("text/html");
+		PrintWriter out = res.getWriter();
+		out.println(
+			"<html><head><title>Ping Servlet2Servlet</title></head>"
+				+ "<body><HR><BR><FONT size=\"+2\" color=\"#000066\">PingServlet2Servlet:<BR></FONT><FONT size=\"+1\" color=\"#000066\">Init time: "
+				+ initTime
+				+ "</FONT><BR><BR><B>Message from Servlet: </B>"
+				+ ab.getMsg()
+				+ "</body></html>"); 
+	}
+	catch (Exception ex)
+	{
+		Log.error(ex, "PingServlet2ServletRcv.doGet(...): general exception"); 
+		res.sendError(
+			500, 
+			"PingServlet2ServletRcv.doGet(...): general exception"
+				+ ex.toString()); 
+	}
+
+}
+/**
+* called when the class is loaded to initialize the servlet
+* @param config ServletConfig:
+**/
+public void init(ServletConfig config) throws ServletException {
+	super.init(config);
+	initTime = new java.util.Date().toString();
+
+}
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,186 @@
+/**
+ *
+ * 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.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ *
+ * This primitive is designed to run inside the TradeApplication and relies upon
+ * the {@link trade_client.TradeConfig} class to set configuration parameters.
+ * PingServlet2SessionEJB tests key functionality of a servlet call to a 
+ * stateless SessionEJB.
+ * This servlet makes use of the Stateless Session EJB {@link trade.Trade} by calling
+ * calculateInvestmentReturn with three random numbers.
+ *
+ */
+public class PingServlet2Session extends HttpServlet {
+
+	private static String initTime;
+	private static int hitCount;
+	private static TradeHome tradeHome;
+
+
+/**
+ * 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();
+	Trade trade = null;
+	//use a stringbuffer to avoid concatenation of Strings
+	StringBuffer output = new StringBuffer(100);
+	output.append(
+		"<html><head><title>PingServlet2Session</title></head>"
+			+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2Session<BR></FONT>"
+			+ "<FONT size=\"-1\" color=\"#000066\">"
+			+ "Tests the basis path from a Servlet to a Session Bean."); 
+
+	//get a reference to the TradeBean (session bean) Home
+	try
+	{
+		//we only want to look up the home once
+		if (tradeHome == null)
+		{
+			//we only want one thread to create the EJBHome
+			synchronized (lock)
+		{
+				if (tradeHome == null)
+				{
+
+					output.append("<HR><B>Performing JNDI lookup to create a TradeHome</B>");
+					try
+					{
+						//I am going to use the sytem environment that is set by
+						//trade_client.TradeConfig. 
+						InitialContext ic = new InitialContext();
+
+						tradeHome = 
+							(TradeHome) PortableRemoteObject.narrow(
+								ic.lookup("java:comp/env/ejb/Trade"), 
+								TradeHome.class); 
+					}
+					catch (Exception ne)
+					{
+						Log.error(ne,"PingServlet2Session.doGet(...): errorj looking up TradeHome");
+						throw ne;
+					} //end of catch
+				}
+			}
+		}
+		//tradeHome will be a reference to TradeHome. 
+		try
+		{
+			//create a new Trade instance
+			trade = tradeHome.create();
+
+			//create three random numbers 
+			double rnd1 = Math.random() * 1000000;
+			double rnd2 = Math.random() * 1000000;
+			double rnd3 = Math.random() * 1000000;
+
+			//use a function to do some work.
+			double increase = 0.0;
+			int iter = TradeConfig.getPrimIterations();
+			for (int ii = 0; ii < iter; ii++) {
+				increase =  trade.investmentReturn(rnd1, rnd2);
+			}
+
+			//write out the output
+			output.append("<HR>initTime: " + initTime);
+			output.append("<BR>Hit Count: " + hitCount++);
+			output.append("<HR>Investment Return Information <BR><BR>investment: " + rnd1);
+			output.append("<BR>current Value: " + rnd2);
+			output.append(
+				"<BR>investment return " + increase + "<HR></FONT></BODY></HTML>"); 
+			out.println(output.toString());
+
+		}
+		catch (Exception e)
+		{
+			Log.error("PingServlet2Session.doGet(...):exception calling trade.investmentReturn "); 
+			throw e;
+		}
+	} //this is where I actually handle the exceptions
+	catch (Exception e)
+	{
+		Log.error(e, "PingServlet2Session.doGet(...): error"); 
+		res.sendError(500, "PingServlet2Session.doGet(...): error, " + e.toString());
+
+	}
+}                           
+
+
+
+
+/** 
+ * returns a string of information about the servlet
+ * @return info String: contains info about the servlet
+ **/
+
+public String getServletInfo()
+{
+	return "web primitive, configured with trade runtime configs, tests Servlet to Session 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;
+	initTime = new java.util.Date().toString();
+	tradeHome = null;
+	//for synchronization
+	lock = new Integer(99);
+}      
+
+
+
+
+;
+
+
+	private java.lang.Integer lock;}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2CMROne2Many.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2CMROne2Many.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2CMROne2Many.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2CMROne2Many.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,171 @@
+/**
+ *
+ * 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 java.util.Collection;
+import java.util.Iterator;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.naming.*;
+
+import org.apache.geronimo.samples.daytrader.ejb.*;
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ * Primitive to test Entity Container Managed Relationshiop  One to One
+ * Servlet will generate a random userID and get the profile for that user using a {@link trade.Account} Entity EJB 
+ * This tests the common path of a Servlet calling a Session to Entity EJB to get CMR One to One data
+ *
+ */
+
+public class PingServlet2Session2CMROne2Many extends HttpServlet
+{
+	private static String initTime;
+	private static int hitCount;
+	private static TradeHome tradeHome;
+
+	/**
+		 * 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();
+
+		Trade  trade = null;
+		String userID = null;
+
+		StringBuffer output = new StringBuffer(100);
+		output.append(
+			"<html><head><title>Servlet2Session2CMROne20ne</title></head>"
+				+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2Session2CMROne2Many<BR></FONT>"
+				+ "<FONT size=\"-1\" color=\"#000066\"><BR>PingServlet2Session2CMROne2Many uses the Trade Session EJB"
+				+ " to get the orders for a user using an EJB 2.0 Entity CMR one to many relationship");
+		try
+			{
+			//this is just a large general catch block.
+
+			//it is important only to look up the home once.
+			if (tradeHome == null)
+				{
+				//make sure that only one thread looks up the home
+				synchronized (lock)
+				{
+					if (tradeHome == null)
+						{
+						output.append(
+							"<HR>Performing JNDI lookup and creating reference to TradeHome</B>");
+						try
+							{
+							//do not pass an environment so that it uses the system env.
+							InitialContext ic = new InitialContext();
+							//lookup and narrow (cast) the reference to the ejbHome.  
+							tradeHome = (TradeHome) ic.lookup("java:comp/env/ejb/Trade");
+						}
+						catch (Exception ne)
+							{
+							//wrap and throw the exception for handling
+							Log.error(ne,"PingServlet2EntityCMROne2Many.doGet(...): error looking up TradeHome");
+							throw ne;
+						}
+					}
+				}
+			}
+			
+			Collection orderDataBeans = null;
+			int iter = TradeConfig.getPrimIterations();
+			for (int ii = 0; ii < iter; ii++) {
+				userID = TradeConfig.rndUserID();
+				trade = tradeHome.create();			
+
+				//get the users orders and print the output.
+				orderDataBeans = trade.getOrders(userID);
+			}			
+
+			output.append("<HR>initTime: " + initTime + "<BR>Hit Count: ").append(
+				hitCount++);
+			output
+				.append("<HR>One to Many CMR access of Account Orders from Account Entity<BR> ");
+			output.append("<HR>User: " + userID + " currently has " + orderDataBeans.size() + " stock orders:");
+			Iterator it = orderDataBeans.iterator();
+			while ( it.hasNext() )
+			{
+				OrderDataBean orderData = (OrderDataBean) it.next();
+				output.append("<BR>" + orderData.toHTML());
+			}				
+			output.append("</font><HR></body></html>");
+			out.println(output.toString());
+		}
+		catch (Exception e)
+			{
+			Log.error(e,"PingServlet2Session2CMROne2Many.doGet(...): error");
+			//this will send an Error to teh web applications defined error page.
+			res.sendError(
+				500,
+				"PingServlet2Session2CMROne2Many.doGet(...): error"
+					+ 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 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;
+		initTime = new java.util.Date().toString();
+		//set this to null, this will be initialized in the doGet method.
+		tradeHome = null;
+		//this lock is used to synchronize initialization of the EJBHome
+		lock = new Integer(99);
+
+	}
+	private java.lang.Integer lock;
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2CMROne2One.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2CMROne2One.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2CMROne2One.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2CMROne2One.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,161 @@
+/**
+ *
+ * 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 org.apache.geronimo.samples.daytrader.ejb.*;
+import org.apache.geronimo.samples.daytrader.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ * Primitive to test Entity Container Managed Relationshiop  One to One
+ * Servlet will generate a random userID and get the profile for that user using a {@link trade.Account} Entity EJB 
+ * This tests the common path of a Servlet calling a Session to Entity EJB to get CMR One to One data
+ *
+ */
+
+public class PingServlet2Session2CMROne2One extends HttpServlet
+{
+	private static String initTime;
+	private static int hitCount;
+	private static TradeHome tradeHome;
+
+	/**
+		 * 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();
+
+		Trade trade = null;
+		String userID = null;
+
+		StringBuffer output = new StringBuffer(100);
+		output.append(
+			"<html><head><title>Servlet2Session2CMROne20ne</title></head>"
+				+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2Session2CMROne2One<BR></FONT>"
+				+ "<FONT size=\"-1\" color=\"#000066\"><BR>PingServlet2Session2CMROne2One uses the Trade Session EJB"
+				+ " to get the profile for a user using an EJB 2.0 CMR one to one relationship");
+		try
+			{
+			//this is just a large general catch block.
+
+			//it is important only to look up the home once.
+			if (tradeHome == null)
+				{
+				//make sure that only one thread looks up the home
+				synchronized (lock)
+				{
+					if (tradeHome == null)
+						{
+						output.append(
+							"<HR>Performing JNDI lookup and creating reference to TradeHome</B>");
+						try
+							{
+							//do not pass an environment so that it uses the system env.
+							InitialContext ic = new InitialContext();
+							//lookup and narrow (cast) the reference to the ejbHome.  
+							tradeHome = (TradeHome) ic.lookup("java:comp/env/ejb/Trade");
+						}
+						catch (Exception ne)
+							{
+							//wrap and throw the exception for handling
+							Log.error(ne,"PingServlet2Session2CMROne2One.doGet(...): error looking up TradeHome");
+							throw ne;
+						}
+					}
+				}
+			}
+			
+			AccountProfileDataBean accountProfileData = null;
+			int iter = TradeConfig.getPrimIterations();
+			for (int ii = 0; ii < iter; ii++) {
+				userID = TradeConfig.rndUserID();
+				trade = tradeHome.create();
+				//get the price and print the output.
+				accountProfileData = trade.getAccountProfileData(userID);
+			}
+
+			output.append("<HR>initTime: " + initTime + "<BR>Hit Count: ").append(
+				hitCount++);
+			output
+				.append("<HR>One to One CMR access of AccountProfile Information from Account Entity<BR><BR> " + accountProfileData.toHTML());
+			output.append("</font><HR></body></html>");
+			out.println(output.toString());
+		}
+		catch (Exception e)
+			{
+			Log.error(e,"PingServlet2Session2CMROne2One.doGet(...): error");
+			//this will send an Error to teh web applications defined error page.
+			res.sendError(
+				500,
+				"PingServlet2Session2CMROne2One.doGet(...): error"
+					+ 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 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;
+		initTime = new java.util.Date().toString();
+		//set this to null, this will be initialized in the doGet method.
+		tradeHome = null;
+		//this lock is used to synchronize initialization of the EJBHome
+		lock = new Integer(99);
+
+	}
+	private java.lang.Integer lock;
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2Entity.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2Entity.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2Entity.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2Entity.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,174 @@
+/**
+ *
+ * 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.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ *
+ * 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 stock symbol.  The stocks
+ * price is looked up using the Quote Entity EJB.  
+ *
+ */
+public class PingServlet2Session2Entity extends HttpServlet
+{
+
+	private static String initTime;
+	private static int hitCount;
+	private static TradeHome tradeHome;
+
+	/**
+	 * 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;
+		Trade trade = null;
+		StringBuffer output = new StringBuffer(100);
+
+		output.append(
+			"<html><head><title>PingServlet2Session2Entity</title></head>"
+				+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2Session2Entity<BR></FONT>"
+				+ "<FONT size=\"-1\" color=\"#000066\">"
+				+ "PingServlet2Session2Entity tests the common path of a Servlet calling a Session EJB "
+				+ "which in turn calls an Entity EJB.<BR>");
+
+		try
+			{
+
+			//only want to do this once.
+			if (tradeHome == null)
+				{
+				//only want one thread to create the EjbHome
+				synchronized (lock)
+				{
+
+					if (tradeHome == 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();
+
+							tradeHome =
+								(TradeHome) PortableRemoteObject.narrow(
+									ic.lookup("java:comp/env/ejb/Trade"),
+									TradeHome.class);
+						}
+						catch (Exception ne)
+							
+						{
+							Log.error(ne, "PingServlet2Session2Entity.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
+					symbol = TradeConfig.rndSymbol();
+					trade = tradeHome.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, "PingServlet2Session2Entity.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, "PingServlet2Session2Entity.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;
+		tradeHome = 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

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2EntityCollection.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2EntityCollection.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2EntityCollection.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2Session2EntityCollection.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,181 @@
+/**
+ *
+ * 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.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ *
+ * 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 PingServlet2Session2EntityCollection extends HttpServlet
+{
+
+	private static String initTime;
+	private static int hitCount;
+	private static TradeHome tradeHome;
+
+	/**
+	 * 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;
+		Trade trade = null;
+		StringBuffer output = new StringBuffer(100);
+
+		output.append(
+			"<html><head><title>PingServlet2Session2EntityCollection</title></head>"
+				+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2Session2EntityCollection<BR></FONT>"
+				+ "<FONT size=\"-1\" color=\"#000066\">"
+				+ "PingServlet2Session2EntityCollection tests the common path of a Servlet calling a Session EJB "
+				+ "which in turn calls a finder on an Entity EJB returning a collection of Entity EJBs.<BR>");
+
+		try
+			{
+
+			//only want to do this once.
+			if (tradeHome == null)
+				{
+				//only want one thread to create the EjbHome
+				synchronized (lock)
+				{
+
+					if (tradeHome == 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();
+
+							tradeHome =
+								(TradeHome) PortableRemoteObject.narrow(
+									ic.lookup("java:comp/env/ejb/Trade"),
+									TradeHome.class);
+						}
+						catch (Exception ne)
+							
+						{
+							Log.error(ne, "PingServlet2Session2EntityCollection.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 = tradeHome.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, "PingServlet2Session2EntityCollection.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, "PingServlet2Session2EntityCollection.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;
+		tradeHome = 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

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2TwoPhase.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2TwoPhase.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2TwoPhase.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServlet2TwoPhase.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,174 @@
+/**
+ *
+ * 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.util.*;
+
+import org.apache.geronimo.samples.daytrader.*;
+
+/**
+ *
+ * PingServlet2TwoPhase tests key functionality of a TwoPhase commit
+ * In this primitive a servlet calls a Session EJB which begins a global txn
+ * The Session EJB then reads a DB row and sends a message to JMS Queue
+ * The txn is closed w/ a 2-phase commit
+ *
+ */
+public class PingServlet2TwoPhase extends HttpServlet
+{
+
+	private static String initTime;
+	private static int hitCount;
+	private static TradeHome tradeHome;
+
+	/**
+	 * 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;
+		Trade trade = null;
+		StringBuffer output = new StringBuffer(100);
+
+		output.append(
+			"<html><head><title>PingServlet2TwoPhase</title></head>"
+				+ "<body><HR><FONT size=\"+2\" color=\"#000066\">PingServlet2TwoPhase<BR></FONT>"
+				+ "<FONT size=\"-1\" color=\"#000066\">"
+				+ "PingServlet2TwoPhase tests the path of a Servlet calling a Session EJB "
+				+ "which in turn calls an Entity EJB to read a DB row (quote). The Session EJB "
+				+ "then posts a message to a JMS Queue. "
+				+ "<BR> These operations are wrapped in a 2-phase commit<BR>");
+
+		try
+			{
+
+			//only want to do this once.
+			if (tradeHome == null)
+				{
+				//only want one thread to create the EjbHome
+				synchronized (lock)
+				{
+
+					if (tradeHome == 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();
+
+							tradeHome =
+								(TradeHome) PortableRemoteObject.narrow(
+									ic.lookup("java:comp/env/ejb/Trade"),
+									TradeHome.class);
+						}
+						catch (Exception ne)
+							
+						{
+							Log.error(ne, "PingServlet2TwoPhase.goGet(...): exception caught looking up and narrowing 'TradeHome'");
+							throw ne;
+						}
+					}
+				}
+			}
+
+			try
+				{
+				int iter = TradeConfig.getPrimIterations();
+				for (int ii = 0; ii < iter; ii++) {
+					symbol = TradeConfig.rndSymbol();
+					trade = tradeHome.create();
+					//getQuote will call findQuote which will instaniate the Quote Entity Bean
+					//and then will return a QuoteObject
+					quoteData = trade.pingTwoPhase(symbol);
+					trade.remove();
+				}
+			}
+			catch (Exception ne)
+				{
+				Log.error(ne, "PingServlet2TwoPhase.goGet(...): exception getting QuoteData through Trade");
+				throw ne;
+			}
+
+			output.append("<HR>initTime: " + initTime).append(
+				"<BR>Hit Count: " + hitCount++);
+			output.append("<HR>Two phase ping selected a quote and sent a message to TradeBrokerQueue JMS queue<BR>Quote Information<BR><BR>" + quoteData.toHTML());
+			out.println(output.toString());
+
+		}
+		catch (Exception e)
+			{
+			Log.error(e, "PingServlet2TwoPhase.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 and JMS -- 2-phase commit 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;
+		tradeHome = 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

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServletWriter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServletWriter.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServletWriter.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingServletWriter.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,97 @@
+/**
+ *
+ * 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 org.apache.geronimo.samples.daytrader.util.*;
+
+
+/**
+ *
+ * PingServlet extends PingServlet by using a PrintWriter for formatted 
+ * output vs. the output stream used by {@link PingServlet}.
+ * 
+ */
+public class PingServletWriter extends HttpServlet {
+
+	private static String initTime;
+	private static int hitCount;
+
+	/**
+	 * 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 ServletException, IOException {
+		try
+		{
+			res.setContentType("text/html");
+
+			// The following 2 lines are the difference between PingServlet and PingServletWriter
+			//   the latter uses a PrintWriter for output versus a binary output stream.
+			//ServletOutputStream out = res.getOutputStream();
+			java.io.PrintWriter out = res.getWriter();
+                        hitCount++;
+			out.println(
+				"<html><head><title>Ping Servlet Writer</title></head>"
+					+ "<body><HR><BR><FONT size=\"+2\" color=\"#000066\">Ping Servlet Writer:<BR></FONT><FONT size=\"+1\" color=\"#000066\">Init time : "
+					+ initTime
+					+ "<BR><BR></FONT>  <B>Hit Count: "
+					+ hitCount
+					+ "</B></body></html>"); 
+		}
+		catch (Exception e)
+		{
+			Log.error(e, "PingServletWriter.doGet(...): general exception caught"); 
+			res.sendError(500, e.toString());
+		}
+	}
+	/** 
+	 * returns a string of information about the servlet
+	 * @return info String: contains info about the servlet
+	 **/
+
+	public String getServletInfo()
+	{
+		return "Basic dynamic HTML generation through a servlet using a PrintWriter";
+	}
+	/**
+	* 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;
+		initTime = new java.util.Date().toString();
+
+	}
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession1.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession1.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession1.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession1.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,127 @@
+/**
+ *
+ * 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 org.apache.geronimo.samples.daytrader.util.*;
+
+/**
+ *
+ * PingHTTPSession1 - SessionID tests fundamental HTTP session functionality 
+ * by creating a unique session ID for each individual user. The ID is stored 
+ * in the users session and is accessed and displayed on each user request.
+ *
+ */
+public class PingSession1 extends HttpServlet {
+	private static int count;
+	// For each new session created, add a session ID of the form "sessionID:" + count
+	private static String initTime;
+	private static int hitCount;
+/**
+ * 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 request, HttpServletResponse response)
+	throws ServletException, IOException {
+	HttpSession session = null;
+	try
+	{
+		try
+		{
+			//get the users session, if the user does not have a session create one.
+			session = request.getSession(true);
+		}
+		catch (Exception e)
+		{
+			Log.error(e, "PingSession1.doGet(...): error getting session"); 
+			//rethrow the exception for handling in one place.
+			throw e;
+		}
+
+		// Get the session data value
+		Integer ival = (Integer) session.getAttribute("sessiontest.counter");
+		//if their is not a counter create one.
+		if (ival == null)
+		{
+			ival = new Integer(count++);
+			session.setAttribute("sessiontest.counter", ival);
+		}
+		String SessionID = "SessionID:" + ival.toString();
+
+		// Output the page
+		response.setContentType("text/html");
+		response.setHeader("SessionKeyTest-SessionID", SessionID);
+
+		PrintWriter out = response.getWriter();
+		out.println(
+			"<html><head><title>HTTP Session Key Test</title></head><body><HR><BR><FONT size=\"+2\" color=\"#000066\">HTTP Session Test 1: Session Key<BR></FONT><FONT size=\"+1\" color=\"#000066\">Init time: "
+				+ initTime
+				+ "</FONT><BR><BR>");
+                hitCount++;
+		out.println(
+			"<B>Hit Count: "
+				+ hitCount
+				+ "<BR>Your HTTP Session key is "
+				+ SessionID
+				+ "</B></body></html>"); 
+	}
+	catch (Exception e)
+	{
+		//log the excecption
+		Log.error(e, "PingSession1.doGet(..l.): error."); 
+		//set the server responce to 500 and forward to the web app defined error page 
+		response.sendError(
+			500, 
+			"PingSession1.doGet(...): error. " + e.toString()); 
+	}
+}
+/** 
+ * returns a string of information about the servlet
+ * @return info String: contains info about the servlet
+ **/
+
+public String getServletInfo()
+{
+	return "HTTP Session Key: Tests management of a read only unique id";
+}
+/**
+* called when the class is loaded to initialize the servlet
+* @param config ServletConfig:
+**/
+public void init(ServletConfig config) throws ServletException {
+	super.init(config);
+	count = 0;
+	hitCount = 0;
+	initTime = new java.util.Date().toString();
+
+}
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession2.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession2.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession2.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession2.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,144 @@
+/**
+ *
+ * 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 org.apache.geronimo.samples.daytrader.util.*;
+
+/**
+ *
+ * PingHTTPSession2 session create/destroy further extends the previous test by
+ * invalidating the HTTP Session on every 5th user access. This results in testing
+ * HTTPSession create and destroy
+ *
+ */
+public class PingSession2 extends HttpServlet {
+
+	private static String initTime;
+	private static int hitCount;
+
+/**
+ * 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 request, HttpServletResponse response)
+	throws ServletException, IOException {
+	HttpSession session = null;
+	try
+	{
+		try
+		{
+			session = request.getSession(true);
+		}
+		catch (Exception e)
+		{
+			Log.error(e, "PingSession2.doGet(...): error getting session"); 
+			//rethrow the exception for handling in one place.
+			throw e;
+
+		}
+
+		// Get the session data value
+		Integer ival = (Integer) session.getAttribute("sessiontest.counter");
+		//if there is not a counter then create one.
+		if (ival == null)
+		{
+			ival = new Integer(1);
+		}
+		else
+		{
+			ival = new Integer(ival.intValue() + 1);
+		}
+		session.setAttribute("sessiontest.counter", ival);
+		//if the session count is equal to five invalidate the session
+		if (ival.intValue() == 5)
+		{
+			session.invalidate();
+		}
+
+		try
+		{
+			// Output the page
+			response.setContentType("text/html");
+			response.setHeader("SessionTrackingTest-counter", ival.toString());
+
+			PrintWriter out = response.getWriter();
+			out.println(
+				"<html><head><title>Session Tracking Test 2</title></head><body><HR><BR><FONT size=\"+2\" color=\"#000066\">HTTP Session Test 2: Session create/invalidate <BR></FONT><FONT size=\"+1\" color=\"#000066\">Init time: "
+					+ initTime
+					+ "</FONT><BR><BR>");
+                        hitCount++;
+			out.println(
+				"<B>Hit Count: "
+					+ hitCount
+					+ "<BR>Session hits: "
+					+ ival
+					+ "</B></body></html>"); 
+		}
+		catch (Exception e)
+		{
+			Log.error(e, "PingSession2.doGet(...): error getting session information"); 
+			//rethrow the exception for handling in one place.
+			throw e;
+		}
+
+	}
+
+	catch (Exception e)
+	{
+		//log the excecption
+		Log.error(e, "PingSession2.doGet(...): error."); 
+		//set the server responce to 500 and forward to the web app defined error page 
+		response.sendError(
+			500, 
+			"PingSession2.doGet(...): error. " + e.toString()); 
+	}
+} //end of the method
+/** 
+ * returns a string of information about the servlet
+ * @return info String: contains info about the servlet
+ **/
+public String getServletInfo()
+{
+	return "HTTP Session Key: Tests management of a read/write unique id";
+}
+/**
+* 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;
+	initTime = new java.util.Date().toString();
+
+}
+}
\ No newline at end of file

Added: geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java?rev=290479&view=auto
==============================================================================
--- geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java (added)
+++ geronimo/trunk/sandbox/daytrader/modules/web/src/java/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java Tue Sep 20 09:07:08 2005
@@ -0,0 +1,176 @@
+/**
+ *
+ * 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 org.apache.geronimo.samples.daytrader.util.*;
+
+/**
+ * 
+ * PingHTTPSession3 tests the servers ability to manage 
+ * and persist large HTTPSession data objects. The servlet creates the large custom 
+ * java object {@link PingSession3Object}. This large session object is 
+ * retrieved and stored to the session on each user request.  The default settings
+ * result in approx 2024 bits being retrieved and stored upon each request.
+ *
+ */
+public class PingSession3 extends HttpServlet {
+	private static int NUM_OBJECTS = 2;
+	private static String initTime = null;
+	private static int hitCount = 0;
+
+/**
+ * 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 request, HttpServletResponse response)
+	throws ServletException, IOException {
+
+	PrintWriter out = response.getWriter();
+	//Using a StringBuffer to output all at once.
+	StringBuffer outputBuffer = new StringBuffer();
+	HttpSession session = null;
+	PingSession3Object[] sessionData;
+	response.setContentType("text/html");
+
+	//this is a general try/catch block.  The catch block at the end of this will forward the responce
+	//to an error page if there is an exception
+	try
+	{
+
+		try
+		{
+			session = request.getSession(true);
+		}
+		catch (Exception e)
+		{
+			Log.error(e, "PingSession3.doGet(...): error getting session"); 
+			//rethrow the exception for handling in one place.
+			throw e;
+
+		}
+		// Each PingSession3Object in the PingSession3Object array is 1K in size
+		// NUM_OBJECTS sets the size of the array to allocate and thus set the size in KBytes of the session object
+		// NUM_OBJECTS can be initialized by the servlet
+		// Here we check for the request parameter to change the size and invalidate the session if it exists
+		// NOTE: Current user sessions will remain the same (i.e. when NUM_OBJECTS is changed, all user thread must be restarted
+		// for the change to fully take effect
+
+		String num_objects;
+		if ((num_objects = request.getParameter("num_objects")) != null)
+		{
+			//validate input
+			try
+			{
+				int x = Integer.parseInt(num_objects);
+				if (x > 0)
+				{
+					NUM_OBJECTS = x;
+				}
+			}
+			catch (Exception e)
+			{
+				Log.error(e, "PingSession3.doGet(...): input should be an integer, input=" + num_objects); 
+			} //  revert to current value on exception
+
+			outputBuffer.append(
+				"<html><head> Session object size set to "
+					+ NUM_OBJECTS
+					+ "K bytes </head><body></body></html>"); 
+			if (session != null)
+				session.invalidate();
+			out.print(outputBuffer.toString());
+			out.close();
+			return;
+		}
+
+		// Get the session data value
+		sessionData = 
+			(PingSession3Object[]) session.getAttribute("sessiontest.sessionData"); 
+		if (sessionData == null)
+		{
+			sessionData = new PingSession3Object[NUM_OBJECTS];
+			for (int i = 0; i < NUM_OBJECTS; i++)
+			{
+				sessionData[i] = new PingSession3Object();
+			}
+		}
+
+		session.setAttribute("sessiontest.sessionData", sessionData);
+
+		//Each PingSession3Object is about 1024 bits, there are 8 bits in a byte.
+		int num_bytes = (NUM_OBJECTS*1024)/8;
+		response.setHeader(
+			"SessionTrackingTest-largeSessionData", 
+			num_bytes + "bytes"); 
+
+		outputBuffer
+			.append("<html><head><title>Session Large Data Test</title></head><body><HR><BR><FONT size=\"+2\" color=\"#000066\">HTTP Session Test 3: Large Data<BR></FONT><FONT size=\"+1\" color=\"#000066\">Init time: ")
+			.append(initTime)
+			.append("</FONT><BR><BR>");
+                hitCount++;
+		outputBuffer.append("<B>Hit Count: ").append(hitCount).append(
+			"<BR>Session object updated. Session Object size = "
+				+ num_bytes
+				+ " bytes </B></body></html>"); 
+		//output the Buffer to the printWriter.
+		out.println(outputBuffer.toString());
+
+	}
+	catch (Exception e)
+	{
+		//log the excecption
+		Log.error(e, "PingSession3.doGet(..l.): error."); 
+		//set the server responce to 500 and forward to the web app defined error page 
+		response.sendError(
+			500, 
+			"PingSession3.doGet(...): error. " + e.toString()); 	}
+}
+/** 
+ * returns a string of information about the servlet
+ * @return info String: contains info about the servlet
+ **/
+public String getServletInfo()
+{
+	return "HTTP Session Object: Tests management of a large custom session class";
+}    
+/**
+* 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;
+	initTime = new java.util.Date().toString();
+
+}
+}
\ No newline at end of file



Mime
View raw message