Added: geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java?rev=293214&view=auto ============================================================================== --- geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java (added) +++ geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java Sun Oct 2 19:34:49 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( + " Session object size set to " + + NUM_OBJECTS + + "K bytes "); + 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("Session Large Data Test

HTTP Session Test 3: Large Data
Init time: ") + .append(initTime) + .append("

"); + hitCount++; + outputBuffer.append("Hit Count: ").append(hitCount).append( + "
Session object updated. Session Object size = " + + num_bytes + + " bytes
"); + //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 Propchange: geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3Object.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3Object.java?rev=293214&view=auto ============================================================================== --- geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3Object.java (added) +++ geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3Object.java Sun Oct 2 19:34:49 2005 @@ -0,0 +1,90 @@ +/** + * + * 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.*; + +/** + * + * An object that contains approximately 1024 bits of information. This is used by + * {@link PingSession3} + * + */ +public class PingSession3Object implements Serializable { + // PingSession3Object represents a BLOB of session data of various. + // Each instantiation of this class is approximately 1K in size (not including overhead for arrays and Strings) + // Using different datatype exercises the various serialization algorithms for each type + + byte[] byteVal = new byte[16]; // 8 * 16 = 128 bits + char[] charVal = new char[8]; // 16 * 8 = 128 bits + int a, b, c, d; // 4 * 32 = 128 bits + float e, f, g, h; // 4 * 32 = 128 bits + double i, j; // 2 * 64 = 128 bits + // Primitive type size = ~5*128= 640 + + String s1 = new String("123456789012"); + String s2 = new String("abcdefghijkl"); +// String type size = ~2*12*16 = 384 +// Total blob size (w/o overhead) = 1024 + + +// The Session blob must be filled with data to avoid compression of the blob during serialization + PingSession3Object() + { + int index; + byte b = 0x8; + for (index=0; index<16; index++) + { + byteVal[index] = (byte) (b+2); + } + + char c = 'a'; + for (index=0; index<8; index++) + { + charVal[index] = (char) (c+2); + } + + a=1; b=2; c=3; d=5; + e = (float)7.0; f=(float)11.0; g=(float)13.0; h=(float)17.0; + i=(double)19.0; j=(double)23.0; + } +/** + * Main method to test the serialization of the Session Data blob object + * Creation date: (4/3/2000 3:07:34 PM) + * @param args java.lang.String[] + */ + +/** Since the following main method were written for testing purpose, we comment them out +*public static void main(String[] args) { +* try { +* PingSession3Object data = new PingSession3Object(); +* +* FileOutputStream ostream = new FileOutputStream("c:\\temp\\datablob.xxx"); +* ObjectOutputStream p = new ObjectOutputStream(ostream); +* p.writeObject(data); +* p.flush(); +* ostream.close(); +* } +* catch (Exception e) +* { +* System.out.println("Exception: " + e.toString()); +* } +*} +*/ + +} \ No newline at end of file Propchange: geronimo/trunk/sandbox/daytrader/modules/web/src/webapp/WEB-INF/classes/org/apache/geronimo/samples/daytrader/web/prims/PingSession3Object.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/trunk/sandbox/daytrader/project.properties URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/daytrader/project.properties?rev=293214&r1=293213&r2=293214&view=diff ============================================================================== --- geronimo/trunk/sandbox/daytrader/project.properties (original) +++ geronimo/trunk/sandbox/daytrader/project.properties Sun Oct 2 19:34:49 2005 @@ -1,5 +1,7 @@ maven.xdoc.date=left -maven.multiproject.includes=components/*/*/project.xml -maven.multiproject.war.includes=components/wars/*/project.xml -maven.multiproject.ejb.includes=components/ejbs/*/project.xml -maven.multiproject.ear.includes=components/ears/*/project.xml +maven.multiproject.includes=modules/**/project.xml +maven.multiproject.war.includes=modules/web/project.xml +maven.multiproject.ejb.includes=modules/ejb/project.xml +maven.multiproject.ear.includes=modules/ear/project.xml +maven.multiproject.streamer.includes=modules/streamer/project.xml +maven.multiproject.jar.includes=modules/core/project.xml,modules/wsappclient/project.xml \ No newline at end of file