001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.samples.daytrader.web.prims;
018    
019    import java.io.*;
020    
021    /**
022     * 
023     * An object that contains approximately 1024 bits of information.  This is used by
024     * {@link PingSession3}
025     *
026     */
027    public class PingSession3Object implements Serializable {
028            // PingSession3Object represents a BLOB of session data of various. 
029            // Each instantiation of this class is approximately 1K in size (not including overhead for arrays and Strings)
030            // Using different datatype exercises the various serialization algorithms for each type
031    
032            byte[] byteVal = new byte[16]; // 8 * 16 = 128 bits
033            char[] charVal = new char[8]; // 16 * 8 = 128 bits
034            int a, b, c, d; // 4 * 32 = 128 bits
035            float e, f, g, h; // 4 * 32 = 128 bits
036            double i, j; // 2 * 64 = 128 bits
037            // Primitive type size = ~5*128=   640
038    
039            String s1 = new String("123456789012");  
040            String s2 = new String("abcdefghijkl");
041    //                                                                               String type size = ~2*12*16 =   384
042    //                                                                               Total blob size (w/o overhead) =  1024
043    
044    
045    //       The Session blob must be filled with data to avoid compression of the blob during serialization
046            PingSession3Object()
047            {
048                    int index;
049                    byte b = 0x8;
050                    for (index=0; index<16; index++)
051                    {
052                            byteVal[index] = (byte) (b+2);
053                    }
054    
055                    char c = 'a';
056                    for (index=0; index<8; index++)
057                    {
058                            charVal[index] = (char) (c+2);
059                    }
060    
061                    a=1; b=2; c=3; d=5;
062                    e = (float)7.0; f=(float)11.0; g=(float)13.0; h=(float)17.0;
063                    i=(double)19.0; j=(double)23.0;
064            }
065    /**
066     * Main method to test the serialization of the Session Data blob object
067     * Creation date: (4/3/2000 3:07:34 PM)
068     * @param args java.lang.String[]
069     */
070    
071    /** Since the following main method were written for testing purpose, we comment them out
072    *public static void main(String[] args) {
073    *       try {
074    *               PingSession3Object data = new PingSession3Object();
075    *
076    *               FileOutputStream ostream = new FileOutputStream("c:\\temp\\datablob.xxx");
077    *               ObjectOutputStream p = new ObjectOutputStream(ostream);
078    *               p.writeObject(data);
079    *               p.flush();
080    *               ostream.close();
081    *       }
082    *       catch (Exception e)
083    *       {
084    *               System.out.println("Exception: " + e.toString());
085    *       }
086    *}
087    */
088    
089    }