aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r1075106 [7/18] - in /aries/tags/samples-0.1-incubating: ./ ariestrader/ ariestrader/assemblies/ ariestrader/assemblies/ariestrader-all-eba/ ariestrader/assemblies/ariestrader-jdbc-eba/ ariestrader/assemblies/equinox-test-harness/ ariestrad...
Date Sun, 27 Feb 2011 18:28:41 GMT
Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/KeyBlock.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/KeyBlock.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/KeyBlock.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/KeyBlock.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,129 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.util;
+
+import java.util.AbstractSequentialList;
+import java.util.ListIterator;
+public class KeyBlock extends AbstractSequentialList 
+{
+
+	// min and max provide range of valid primary keys for this KeyBlock
+	private int min = 0;
+	private int max = 0;
+	private int index = 0;
+
+	/**
+	 * Constructor for KeyBlock
+	 */
+	public KeyBlock() {
+		super();
+		min = 0;
+		max = 0;
+		index = min;
+	}
+
+	/**
+	 * Constructor for KeyBlock 
+	 */
+	public KeyBlock(int min, int max) {
+		super();
+		this.min = min;
+		this.max = max;
+		index = min;
+	}
+
+	/**
+	 * @see AbstractCollection#size()
+	 */
+	public int size() {
+		return (max - min) + 1;
+	}
+
+	/**
+	 * @see AbstractSequentialList#listIterator(int)
+	 */
+	public ListIterator listIterator(int arg0) {
+		return new KeyBlockIterator();
+	}
+
+	class KeyBlockIterator implements ListIterator {
+
+		/**
+		 * @see ListIterator#hasNext()
+		 */
+		public boolean hasNext() {
+			return index <= max;
+		}
+
+		/**
+		 * @see ListIterator#next()
+		 */
+		public synchronized Object next() {
+			if (index > max)
+				throw new java.lang.RuntimeException("KeyBlock:next() -- Error KeyBlock depleted");
+			return new Integer(index++);
+		}
+
+		/**
+		 * @see ListIterator#hasPrevious()
+		 */
+		public boolean hasPrevious() {
+			return index > min;
+		}
+
+		/**
+		 * @see ListIterator#previous()
+		 */
+		public Object previous() {
+			return new Integer(--index);
+		}
+
+		/**
+		 * @see ListIterator#nextIndex()
+		 */
+		public int nextIndex() {
+			return index-min;
+		}
+
+		/**
+		 * @see ListIterator#previousIndex()
+		 */
+		public int previousIndex() {
+			throw new UnsupportedOperationException("KeyBlock: previousIndex() not supported");
+		}
+
+		/**
+		 * @see ListIterator#add()
+		 */
+		public void add(Object o) {
+			throw new UnsupportedOperationException("KeyBlock: add() not supported");
+		}
+
+		/**
+		 * @see ListIterator#remove()
+		 */
+		public void remove() {
+			throw new UnsupportedOperationException("KeyBlock: remove() not supported");
+		}
+
+		/**
+		 * @see ListIterator#set(Object)
+		 */
+		public void set(Object arg0) {
+		}
+	}
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/Log.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/Log.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/Log.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/Log.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,212 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+public class Log {
+	private final static Logger log = LoggerFactory.getLogger(Log.class);
+//A general purpose, high performance logging, tracing, statistic service
+
+	public static void log(String message)
+	{
+        log.debug("AriesTrader Log:" + new java.util.Date() + "------\n\t ");
+		log.debug(message);
+	}
+	public static void log(String msg1, String msg2)
+	{
+		log(msg1+msg2);
+	}
+	public static void log(String msg1, String msg2, String msg3)
+	{
+		log(msg1+msg2+msg3);
+	}
+	
+	public static void error(String message)
+	{
+		message = "Error: " + message;
+		log.error(message);
+	}
+	public static void error(String message, Throwable e)
+	{
+		error(message+"\n\t"+e.toString());
+		e.printStackTrace(System.out);
+	}
+	public static void error(String msg1, String msg2, Throwable e)
+	{
+		error(msg1+"\n"+msg2+"\n\t", e);
+	}
+	public static void error(String msg1, String msg2, String msg3, Throwable e)
+	{
+		error(msg1+"\n"+msg2+"\n"+msg3+"\n\t", e);
+	}
+	public static void error(Throwable e, String message)
+	{
+		error(message+"\n\t",e);
+		e.printStackTrace(System.out);
+	}
+	public static void error(Throwable e, String msg1, String msg2)
+	{
+		error(msg1+"\n"+msg2+"\n\t",e);
+	}
+	public static void error(Throwable e, String msg1, String msg2, String msg3)
+	{
+		error(msg1+"\n"+msg2+"\n"+msg3+"\n\t", e);
+	}
+	
+	
+	public static void trace(String message)
+	{
+		log.trace(message + " threadID="+ Thread.currentThread());
+	}
+
+	public static void trace(String message, Object parm1)
+	{
+		trace(message+"("+parm1+")");
+	}
+
+	public static void trace(String message, Object parm1, Object parm2)
+	{
+		trace(message+"("+parm1+", "+parm2+")");
+	}
+
+	public static void trace(String message, Object parm1, Object parm2, Object parm3)
+	{
+		trace(message+"("+parm1+", "+parm2+", "+parm3+")");
+	}
+	public static void trace(String message, Object parm1, Object parm2, Object parm3, Object parm4)
+	{
+		trace(message+"("+parm1+", "+parm2+", "+parm3+")"+", "+parm4);
+	}
+	public static void trace(String message, Object parm1, Object parm2, Object parm3, Object parm4, Object parm5)
+	{
+		trace(message+"("+parm1+", "+parm2+", "+parm3+")"+", "+parm4+", "+parm5);
+	}
+	public static void trace(String message, Object parm1, Object parm2, Object parm3, Object parm4, 
+								Object parm5, Object parm6)
+	{
+		trace(message+"("+parm1+", "+parm2+", "+parm3+")"+", "+parm4+", "+parm5+", "+parm6);
+	}
+	public static void trace(String message, Object parm1, Object parm2, Object parm3, Object parm4, 
+	          					Object parm5, Object parm6, Object parm7)
+	{
+		trace(message+"("+parm1+", "+parm2+", "+parm3+")"+", "+parm4+", "+parm5+", "+parm6+", "+parm7);
+	}
+	public static void traceEnter(String message)
+	{
+		log.trace("Method enter --" + message);
+	}
+	public static void traceExit(String message)
+	{
+		log.trace("Method exit  --" + message);
+	}
+	
+	
+	public static void stat(String message)
+	{
+		log(message);
+	}
+
+	public static void debug(String message)
+	{
+		log.debug(message);
+	}
+
+	public static void print(String message)
+	{
+		log(message);
+	}
+	
+	public static void printObject(Object o)
+	{
+		log("\t"+o.toString());
+	}
+		
+	public static void printCollection(Collection c)
+	{
+		log("\t---Log.printCollection -- collection size=" + c.size());
+		Iterator it = c.iterator();
+		while ( it.hasNext() )
+		{
+			log("\t\t"+it.next().toString());
+		}
+		log("\t---Log.printCollection -- complete");		
+	}
+	
+	public static void printCollection(String message, Collection c)
+	{
+		log(message);
+		printCollection(c);
+	}
+	
+	public static boolean doActionTrace()
+	{
+		return getTrace() || getActionTrace();
+	}
+
+	public static boolean doTrace()
+	{
+		return getTrace();
+	}
+	
+	public static boolean doDebug()
+	{
+		return true;
+	}
+	
+	public static boolean doStat()
+	{
+		return true;
+	}		
+	
+	/**
+	 * Gets the trace
+	 * @return Returns a boolean
+	 */
+	public static boolean getTrace() {
+		return TradeConfig.getTrace();
+	}
+	/**
+	 * Gets the trace value for Trade actions only
+	 * @return Returns a boolean
+	 */
+	public static boolean getActionTrace() {
+		return TradeConfig.getActionTrace();
+	}
+		
+	/**
+	 * Sets the trace
+	 * @param traceValue The trace to set
+	 */
+	public static void setTrace(boolean traceValue)
+	{
+		TradeConfig.setTrace(traceValue);
+	}
+	/**
+	 * Sets the trace value for Trade actions only
+	 * @param traceValue The trace to set
+	 */
+	public static void setActionTrace(boolean traceValue)
+	{
+		TradeConfig.setActionTrace(traceValue);
+	}
+}
+

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/MDBStats.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/MDBStats.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/MDBStats.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/MDBStats.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,72 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.util;
+
+
+/**
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class MDBStats extends java.util.HashMap {
+	
+	
+	//Singleton class
+	private static MDBStats mdbStats = null;
+	private MDBStats()
+	{
+	}
+	
+	public static synchronized MDBStats getInstance()
+	{
+		if (mdbStats == null)
+			mdbStats = new MDBStats();
+		return mdbStats;
+	}
+	
+	public TimerStat addTiming(String type, long sendTime, long recvTime)
+	{
+		TimerStat stats = null;
+		synchronized (type)
+		{
+
+			stats = (TimerStat) get(type);
+			if (stats == null) stats = new TimerStat();
+
+			long time =  recvTime - sendTime;	        					
+			if ( time > stats.getMax() ) stats.setMax(time);
+			if ( time < stats.getMin() ) stats.setMin(time);
+	        stats.setCount(stats.getCount()+1);
+			stats.setTotalTime(stats.getTotalTime() + time);
+			
+			put(type, stats);
+		}
+		return stats;
+	}
+
+
+
+	public synchronized void reset()
+	{
+		clear();
+	}	
+	
+
+
+}

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/ServiceUtilities.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/ServiceUtilities.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/ServiceUtilities.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/ServiceUtilities.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,67 @@
+/**
+ *  Licensed to4the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership. The ASF licenses this file to
+ *  You under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the
+ *  License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.util;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * ServiceUtilities provides servlet specific client side
+ * utility functions.
+ */
+public class ServiceUtilities {
+
+    /**
+     * Lookup and return an osgi service
+     * 
+     * @return Object
+     * @exception javax.io.IOException
+     *                If an exception occurs during the service
+     *                lookup
+     * 
+     */
+    public static final Object getOSGIService(String serviceName) {
+        if (Log.doTrace())
+            Log.trace("ServiceUtilities:getOSGIService()", serviceName);
+        return getOSGIService(serviceName, null);
+    }
+
+    /**
+     * Lookup and return an osgi service
+     * 
+     * @return Object
+     * 
+     */
+    public static final Object getOSGIService(String serviceName, String filter) {
+        if (Log.doTrace())
+            Log.trace("ServiceUtilities:getOSGIService()", serviceName, filter);
+        String name = TradeConfig.OSGI_SERVICE_PREFIX + serviceName;
+        if (filter != null) {
+            name = name + "/" + filter;
+        }
+
+        try {
+            InitialContext ic = new InitialContext();
+            return ic.lookup(name);
+        } catch (NamingException e) {
+            Log.error("ServiceUtilities:getOSGIService() -- NamingException on OSGI service lookup", name, e);
+            e.printStackTrace();
+            return null;
+        }
+    }
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/TimerStat.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/TimerStat.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/TimerStat.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/TimerStat.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,121 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.util;
+
+/**
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class TimerStat {
+
+		private double min=1000000000.0, max=0.0, totalTime=0.0;
+		private int count;
+		/**
+		 * Returns the count.
+		 * @return int
+		 */
+		public int getCount() {
+			return count;
+		}
+
+		/**
+		 * Returns the max.
+		 * @return double
+		 */
+		public double getMax() {
+			return max;
+		}
+
+		/**
+		 * Returns the min.
+		 * @return double
+		 */
+		public double getMin() {
+			return min;
+		}
+
+		/**
+		 * Sets the count.
+		 * @param count The count to set
+		 */
+		public void setCount(int count) {
+			this.count = count;
+		}
+
+		/**
+		 * Sets the max.
+		 * @param max The max to set
+		 */
+		public void setMax(double max) {
+			this.max = max;
+		}
+
+		/**
+		 * Sets the min.
+		 * @param min The min to set
+		 */
+		public void setMin(double min) {
+			this.min = min;
+		}
+
+		/**
+		 * Returns the totalTime.
+		 * @return double
+		 */
+		public double getTotalTime() {
+			return totalTime;
+		}
+
+		/**
+		 * Sets the totalTime.
+		 * @param totalTime The totalTime to set
+		 */
+		public void setTotalTime(double totalTime) {
+			this.totalTime = totalTime;
+		}
+
+		/**
+		 * Returns the max in Secs
+		 * @return double
+		 */
+		public double getMaxSecs() {
+			return max/1000.0;
+		}
+
+		/**
+		 * Returns the min in Secs
+		 * @return double
+		 */
+		public double getMinSecs() {
+			return min/1000.0;
+		}
+		
+		/**
+		 * Returns the average time in Secs
+		 * @return double
+		 */
+		public double getAvgSecs() {
+			
+			double avg =  (double)getTotalTime() / (double)getCount();
+			return avg / 1000.0;
+		}		
+		
+
+}

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/TradeConfig.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/TradeConfig.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/TradeConfig.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-util/src/main/java/org/apache/aries/samples/ariestrader/util/TradeConfig.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,884 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.util;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Random;
+
+
+/**
+ * TradeConfig is a JavaBean holding all configuration and runtime parameters for the Trade application
+ * TradeConfig sets runtime parameters such as the RunTimeMode (EJB3, DIRECT, SESSION3, JDBC, JPA)
+ *
+ */
+
+public class TradeConfig {
+
+	/* Trade Runtime Configuration Parameters */
+
+	/* Trade Runtime Mode parameters */
+    public static String[] runTimeModeNames = { "JDBC", 
+                                                "JPA App Managed",
+                                                "JPA Container Managed"};
+    public static enum ModeType{JDBC,JPA_AM,JPA_CM}
+    public static ModeType runTimeMode = ModeType.JDBC;
+	
+    /* Trade JPA Layer parameters */
+	public static String[] jpaLayerNames = {"OpenJPA", "Hibernate"};
+	public static final int OPENJPA = 0;
+	public static final int HIBERNATE = 1;
+	public static int jpaLayer = OPENJPA;
+
+	public static String[] orderProcessingModeNames =
+		{ "Synchronous", "Asynchronous_2-Phase" };
+	public static final int SYNCH = 0;
+	public static final int ASYNCH_2PHASE = 1;
+	public static int orderProcessingMode = SYNCH;
+
+	public static String[] accessModeNames = { "Standard", "WebServices" };
+	public static final int STANDARD = 0;
+	public static final int WEBSERVICES = 1;
+	private static int accessMode = STANDARD;
+
+	/* Trade Scenario Workload parameters */
+	public static String[] workloadMixNames = { "Standard", "High-Volume", };
+	public final static int SCENARIOMIX_STANDARD = 0;
+	public final static int SCENARIOMIX_HIGHVOLUME = 1;
+	public static int workloadMix = SCENARIOMIX_STANDARD;
+
+	/* Trade Web Interface parameters */
+	public static String[] webInterfaceNames = { "JSP", "JSP-Images" };
+	public static final int JSP = 0;
+	public static final int JSP_Images = 1;
+	public static int webInterface = JSP;
+
+	/* Trade Caching Type parameters */
+	public static String[] cachingTypeNames = { "DistributedMap", "Command Caching", "No Caching" };
+	public static final int DISTRIBUTEDMAP = 0;
+	public static final int COMMAND_CACHING = 1;
+	public static final int NO_CACHING = 2;
+	public static int cachingType = NO_CACHING;
+	
+	/* Trade Database Scaling parameters*/
+	private static int MAX_USERS = 200;
+	private static int MAX_QUOTES = 400;
+
+	/* Trade Database specific parameters */
+	public static String JDBC_UID = null;
+	public static String JDBC_PWD = null;
+
+        /* OSGi specific parameters */
+	public static String OSGI_SERVICE_PREFIX = "aries:services/";
+        public static String OSGI_DS_NAME_FILTER = "(osgi.jndi.service.name=jdbc/NoTxTradeDataSource)";
+
+	/*Trade SOAP specific parameters */
+	private static String SoapURL =
+		"http://localhost:8080/ariestrader/services/TradeWSServices";
+
+	/*Trade XA Datasource specific parameters */
+	public static boolean JDBCDriverNeedsGlobalTransaction = false;
+
+	/* Trade Config Miscellaneous items */
+	public static int KEYBLOCKSIZE = 1000;
+	public static int QUOTES_PER_PAGE = 10;
+	public static boolean RND_USER = true;
+	private static int MAX_HOLDINGS = 10;
+	private static int count = 0;
+	private static Object userID_count_semaphore = new Object();
+	private static int userID_count = 0;
+	private static String hostName = null;
+	private static Random r0 = new Random(System.currentTimeMillis());
+	private static Random randomNumberGenerator = r0;
+	public static final String newUserPrefix = "ru:";
+	public static final int verifyPercent = 5;
+	private static boolean trace = false;
+	private static boolean actionTrace = false;
+	private static boolean updateQuotePrices = true;
+	private static int primIterations = 1;
+	private static boolean longRun = true;
+	private static boolean publishQuotePriceChange = false;
+	
+	/**
+	 *   -1 means every operation
+	 *    0 means never perform a market summary
+	 *  > 0 means number of seconds between summaries.  These will be
+	 *      synchronized so only one transaction in this period will create a summary and 
+	 *      will cache its results.
+	 */
+	private static int  marketSummaryInterval = 20;
+
+	/*
+	 * Penny stocks is a problem where the random price change factor gets a stock
+	 * down to $.01.  In this case trade jumpstarts the price back to $6.00 to
+	 * keep the math interesting.
+	 */
+	public static BigDecimal PENNY_STOCK_PRICE;
+	public static BigDecimal PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER;
+	static {
+		PENNY_STOCK_PRICE = new BigDecimal(0.01);
+		PENNY_STOCK_PRICE =
+			PENNY_STOCK_PRICE.setScale(2, BigDecimal.ROUND_HALF_UP);
+		PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER = new BigDecimal(600.0);
+		PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER.setScale(
+			2,
+			BigDecimal.ROUND_HALF_UP);
+	}
+
+	/* CJB (DAYTRADER-25) - Also need to impose a ceiling on the quote price to ensure
+	 * prevent account and holding balances from exceeding the databases decimal precision.
+	 * At some point, this maximum value can be used to trigger a stock split.
+	 */
+
+	public static BigDecimal MAXIMUM_STOCK_PRICE;
+	public static BigDecimal MAXIMUM_STOCK_SPLIT_MULTIPLIER;
+	static {
+		MAXIMUM_STOCK_PRICE = new BigDecimal(400);
+		MAXIMUM_STOCK_PRICE.setScale(2, BigDecimal.ROUND_HALF_UP);
+		MAXIMUM_STOCK_SPLIT_MULTIPLIER = new BigDecimal(0.5);
+		MAXIMUM_STOCK_SPLIT_MULTIPLIER.setScale(2, BigDecimal.ROUND_HALF_UP);
+	}
+
+	/* Trade Scenario actions mixes. Each of the array rows represents a specific Trade Scenario Mix. 
+	   The columns give the percentages for each action in the column header. Note: "login" is always 0. 
+	   logout represents both login and logout (because each logout operation will cause a new login when
+	   the user context attempts the next action.
+	 */
+	/* Trade Scenario Workload parameters */
+	public final static int HOME_OP = 0;
+	public final static int QUOTE_OP = 1;
+	public final static int LOGIN_OP = 2;
+	public final static int LOGOUT_OP = 3;
+	public final static int REGISTER_OP = 4;
+	public final static int ACCOUNT_OP = 5;
+	public final static int PORTFOLIO_OP = 6;
+	public final static int BUY_OP = 7;
+	public final static int SELL_OP = 8;
+	public final static int UPDATEACCOUNT_OP = 9;
+
+	private static int scenarioMixes[][] = {
+		//	h	q	l	o	r	a	p	b	s	u
+		{ 20, 40, 0, 4, 2, 10, 12, 4, 4, 4 }, //STANDARD
+		{
+			20, 40, 0, 4, 2, 7, 7, 7, 7, 6 }, //High Volume
+	};
+	private static char actions[] =
+		{ 'h', 'q', 'l', 'o', 'r', 'a', 'p', 'b', 's', 'u' };
+	private static int sellDeficit = 0;
+	//Tracks the number of buys over sell when a users portfolio is empty
+	// Used to maintain the correct ratio of buys/sells
+
+	/* JSP pages for all Trade Actions */
+
+	public final static int WELCOME_PAGE = 0;
+	public final static int REGISTER_PAGE = 1;
+	public final static int PORTFOLIO_PAGE = 2;
+	public final static int QUOTE_PAGE = 3;
+	public final static int HOME_PAGE = 4;
+	public final static int ACCOUNT_PAGE = 5;
+	public final static int ORDER_PAGE = 6;
+	public final static int CONFIG_PAGE = 7;
+	public final static int STATS_PAGE = 8;
+
+	//FUTURE Add XML/XSL View
+	public static String webUI[][] =
+		{
+			{
+				"/welcome.jsp",
+				"/register.jsp",
+				"/portfolio.jsp",
+				"/quote.jsp",
+				"/tradehome.jsp",
+				"/account.jsp",
+				"/order.jsp",
+				"/config.jsp",
+				"/runStats.jsp" },
+		//JSP Interface
+		{
+			"/welcomeImg.jsp",
+				"/registerImg.jsp",
+				"/portfolioImg.jsp",
+				"/quoteImg.jsp",
+				"/tradehomeImg.jsp",
+				"/accountImg.jsp",
+				"/orderImg.jsp",
+				"/config.jsp",
+				"/runStats.jsp" },
+		//JSP Interface	
+	};
+
+	/**
+	 * Return the hostname for this system
+	 * Creation date: (2/16/2000 9:02:25 PM)
+	 */
+
+	private static String getHostname() {
+		try {
+			if (hostName == null) {
+				hostName = java.net.InetAddress.getLocalHost().getHostName();
+				//Strip of fully qualified domain if necessary
+				try {
+					hostName = hostName.substring(0, hostName.indexOf('.'));
+				} catch (Exception e) {
+				}
+			}
+		} catch (Exception e) {
+			Log.error(
+				"Exception getting local host name using 'localhost' - ",
+				e);
+			hostName = "localhost";
+		}
+		return hostName;
+	}
+
+	/**
+	 * Return a Trade UI Web page based on the current configuration
+	 * This may return a JSP page or a Servlet page 
+	 * Creation date: (3/14/2000 9:08:34 PM)
+	 */
+
+	public static String getPage(int pageNumber) {
+		return webUI[webInterface][pageNumber];
+	}
+
+	/**
+	 * Return the list of run time mode names
+	 * Creation date: (3/8/2000 5:58:34 PM)
+	 * @return java.lang.String[]
+	 */
+	public static java.lang.String[] getRunTimeModeNames() {
+		return runTimeModeNames;
+	}
+
+	private static int scenarioCount = 0;
+
+	/**
+	 * Return a Trade Scenario Operation based on the setting of the current mix (TradeScenarioMix)
+	 * Creation date: (2/10/2000 9:08:34 PM)
+	 */
+
+	public static char getScenarioAction(boolean newUser) {
+		int r = rndInt(100); //0 to 99 = 100
+		int i = 0;
+		int sum = scenarioMixes[workloadMix][i];
+		while (sum <= r) {
+			i++;
+			sum += scenarioMixes[workloadMix][i];
+		}
+
+		incrementScenarioCount();
+
+		/* In TradeScenarioServlet, if a sell action is selected, but the users portfolio is empty,
+		 * a buy is executed instead and sellDefecit is incremented. This allows the number of buy/sell
+		 * operations to stay in sync w/ the given Trade mix.
+		 */
+
+		if ((!newUser) && (actions[i] == 'b')) {
+			synchronized (TradeConfig.class) {
+				if (sellDeficit > 0) {
+					sellDeficit--;
+					return 's';
+					//Special case for TradeScenarioServlet to note this is a buy switched to a sell to fix sellDeficit
+				}
+			}
+		}
+
+		return actions[i];
+	}
+
+	public static String getUserID() {
+		String userID;
+		if (RND_USER) {
+			userID = rndUserID();
+		} else {
+			userID = nextUserID();
+		}
+		return userID;
+	}
+	private static final BigDecimal orderFee = new BigDecimal("24.95");
+	private static final BigDecimal cashFee = new BigDecimal("0.0");
+	public static BigDecimal getOrderFee(String orderType) {
+		if ((orderType.compareToIgnoreCase("BUY") == 0)
+			|| (orderType.compareToIgnoreCase("SELL") == 0))
+			return orderFee;
+
+		return cashFee;
+
+	}
+
+	/**
+	 * Increment the sell deficit counter
+	 * Creation date: (6/21/2000 11:33:45 AM)
+	 */
+	public synchronized static void incrementSellDeficit() {
+		sellDeficit++;
+	}
+
+	public static String nextUserID() {
+		String userID;
+		synchronized (userID_count_semaphore) {
+			userID = "uid:" + userID_count;
+			userID_count++;
+			if (userID_count % MAX_USERS == 0) {
+				userID_count = 0;
+			}
+		}
+		return userID;
+	}
+	public static double random() {
+		return randomNumberGenerator.nextDouble();
+	}
+	public static String rndAddress() {
+		return rndInt(1000) + " Oak St.";
+	}
+	public static String rndBalance() {
+		//Give all new users a cool mill in which to trade
+		return "1000000";
+	}
+	public static String rndCreditCard() {
+		return rndInt(100)
+			+ "-"
+			+ rndInt(1000)
+			+ "-"
+			+ rndInt(1000)
+			+ "-"
+			+ rndInt(1000);
+	}
+	public static String rndEmail(String userID) {
+		return userID + "@" + rndInt(100) + ".com";
+	}
+	public static String rndFullName() {
+		return "first:" + rndInt(1000) + " last:" + rndInt(5000);
+	}
+	public static int rndInt(int i) {
+		return (new Float(random() * i)).intValue();
+	}
+	public static float rndFloat(int i) {
+		return (new Float(random() * i)).floatValue();
+	}
+	public static BigDecimal rndBigDecimal(float f) {
+		return (new BigDecimal(random() * f)).setScale(
+			2,
+			BigDecimal.ROUND_HALF_UP);
+	}
+
+	public static boolean rndBoolean() {
+		return randomNumberGenerator.nextBoolean();
+	}
+
+	/**
+	 * Returns a new Trade user
+	 * Creation date: (2/16/2000 8:50:35 PM)
+	 */
+	public synchronized static String rndNewUserID() {
+
+		return newUserPrefix
+			+ getHostname()
+			+ System.currentTimeMillis()
+			+ count++;
+	}
+
+	public static float rndPrice() {
+		return ((new Integer(rndInt(200))).floatValue()) + 1.0f;
+	}
+	private final static BigDecimal ONE = new BigDecimal(1.0);
+	public static BigDecimal getRandomPriceChangeFactor() {
+		double percentGain = rndFloat(1) * 0.2;
+		if (random() < .5)
+			percentGain *= -1;
+		percentGain += 1;
+
+		// change factor is between +/- 20%
+		BigDecimal percentGainBD =
+			(new BigDecimal(percentGain)).setScale(2, BigDecimal.ROUND_HALF_UP);
+		if (percentGainBD.doubleValue() <= 0.0)
+			percentGainBD = ONE;
+
+		return percentGainBD;
+	}
+
+	public static float rndQuantity() {
+		return ((new Integer(rndInt(200))).floatValue()) + 1.0f;
+	}
+
+	public static String rndSymbol() {
+		return "s:" + rndInt(MAX_QUOTES - 1);
+	}
+	public static String rndSymbols() {
+
+		String symbols = "";
+		int num_symbols = rndInt(QUOTES_PER_PAGE);
+
+		for (int i = 0; i <= num_symbols; i++) {
+			symbols += "s:" + rndInt(MAX_QUOTES - 1);
+			if (i < num_symbols)
+				symbols += ",";
+		}
+		return symbols;
+	}
+
+	public static String rndUserID() {
+		String nextUser = getNextUserIDFromDeck();
+		if (Log.doTrace())
+			Log.trace("TradeConfig:rndUserID -- new trader = " + nextUser);
+
+		return nextUser;
+	}
+
+	private static synchronized String getNextUserIDFromDeck() {
+		int numUsers = getMAX_USERS();
+		if (deck == null) {
+			deck = new ArrayList(numUsers);
+			for (int i = 0; i < numUsers; i++)
+				deck.add(i, new Integer(i));
+			java.util.Collections.shuffle(deck, r0);
+		}
+		if (card >= numUsers)
+			card = 0;
+		return "uid:" + deck.get(card++);
+
+	}
+
+	//Trade implements a card deck approach to selecting 
+	// users for trading with tradescenarioservlet
+	private static ArrayList deck = null;
+	private static int card = 0;
+
+	/**
+	 * Set the list of run time mode names
+	 * Creation date: (3/8/2000 5:58:34 PM)
+	 * @param newRunTimeModeNames java.lang.String[]
+	 */
+	public static void setRunTimeModeNames(
+		java.lang.String[] newRunTimeModeNames) {
+		runTimeModeNames = newRunTimeModeNames;
+	}
+	/**
+	 * This is a convenience method for servlets to set Trade configuration parameters
+	 * from servlet initialization parameters. The servlet provides the init param and its
+	 * value as strings. This method then parses the parameter, converts the value to the
+	 * correct type and sets the corresponding TradeConfig parameter to the converted value
+	 * 
+	 */
+	public static void setConfigParam(String parm, String value) {
+		Log.log("TradeConfig setting parameter: " + parm + "=" + value);
+		// Compare the parm value to valid TradeConfig parameters that can be set
+		// by servlet initialization
+
+		// First check the proposed new parm and value - if empty or null ignore it
+		if (parm == null)
+			return;
+		parm = parm.trim();
+		if (parm.length() <= 0)
+			return;
+		if (value == null)
+			return;
+		value = value.trim();
+
+		if (parm.equalsIgnoreCase("runTimeMode")) {
+			try {
+				for (int i = 0; i < runTimeModeNames.length; i++) {
+					if (value.equalsIgnoreCase(runTimeModeNames[i])) {
+						setRunTimeMode(ModeType.values()[i]);
+						break;
+					}
+				}
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "trying to set runtimemode to "
+						+ value
+						+ "reverting to current value: "
+						+ runTimeModeNames[getRunTimeMode().ordinal()],
+					e);
+			} // If the value is bad, simply revert to current
+		} else if (parm.equalsIgnoreCase("orderProcessingMode")) {
+			try {
+				for (int i = 0; i < orderProcessingModeNames.length; i++) {
+					if (value.equalsIgnoreCase(orderProcessingModeNames[i])) {
+						orderProcessingMode = i;
+						break;
+					}
+				}
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "trying to set orderProcessingMode to "
+						+ value
+						+ "reverting to current value: "
+						+ orderProcessingModeNames[orderProcessingMode],
+					e);
+			} // If the value is bad, simply revert to current
+		} else if (parm.equalsIgnoreCase("accessMode")) {		
+			try {
+				for (int i = 0; i < accessModeNames.length; i++) {
+					if (value.equalsIgnoreCase(accessModeNames[i])) {
+						accessMode = i;
+						break;
+					}
+				}
+			}
+			catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "trying to set accessMode to "
+						+ value
+						+ "reverting to current value: "
+						+ accessModeNames[accessMode],
+					e);
+			}
+		} else if (parm.equalsIgnoreCase("webServicesEndpoint")) {
+			try {
+				setSoapURL(value);
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "Setting web services endpoint",
+					e);
+			} //On error, revert to saved		
+		} else if (parm.equalsIgnoreCase("workloadMix")) {
+			try {
+				for (int i = 0; i < workloadMixNames.length; i++) {
+					if (value.equalsIgnoreCase(workloadMixNames[i])) {
+						workloadMix = i;
+						break;
+					}
+				}
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "trying to set workloadMix to "
+						+ value
+						+ "reverting to current value: "
+						+ workloadMixNames[workloadMix],
+					e);
+			} // If the value is bad, simply revert to current		
+		} else if (parm.equalsIgnoreCase("WebInterface")) {
+			try {
+				for (int i = 0; i < webInterfaceNames.length; i++) {
+					if (value.equalsIgnoreCase(webInterfaceNames[i])) {
+						webInterface = i;
+						break;
+					}
+				}
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "trying to set WebInterface to "
+						+ value
+						+ "reverting to current value: "
+						+ webInterfaceNames[webInterface],
+					e);
+
+			} // If the value is bad, simply revert to current
+		} else if (parm.equalsIgnoreCase("CachingType")) {
+			try {
+				for (int i = 0; i < cachingTypeNames.length; i++) {
+					if (value.equalsIgnoreCase(cachingTypeNames[i])) {
+						cachingType = i;
+						break;
+					}
+				}
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "trying to set CachingType to "
+						+ value
+						+ "reverting to current value: "
+						+ cachingTypeNames[cachingType],
+					e);
+			} // If the value is bad, simply revert to current
+		} else if (parm.equalsIgnoreCase("maxUsers")) {
+			try {
+				MAX_USERS = Integer.parseInt(value);
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "Setting maxusers, error parsing string to int:"
+						+ value
+						+ "revering to current value: "
+						+ MAX_USERS,
+					e);
+			} //On error, revert to saved		
+		} else if (parm.equalsIgnoreCase("maxQuotes")) {
+			try {
+				MAX_QUOTES = Integer.parseInt(value);
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(...) minor exception caught"
+						+ "Setting max_quotes, error parsing string to int "
+						+ value
+						+ "reverting to current value: "
+						+ MAX_QUOTES,
+					e);
+			} //On error, revert to saved		
+		} else if (parm.equalsIgnoreCase("primIterations")) {
+			try {
+				primIterations = Integer.parseInt(value);
+			} catch (Exception e) {
+				Log.error(
+					"TradeConfig.setConfigParm(..): minor exception caught"
+						+ "Setting primIterations, error parsing string to int:"
+						+ value
+						+ "revering to current value: "
+						+ primIterations,
+					e);
+			} //On error, revert to saved
+		}		
+	}
+
+	/**
+	 * Gets the orderProcessingModeNames
+	 * @return Returns a String[]
+	 */
+	public static String[] getOrderProcessingModeNames() {
+		return orderProcessingModeNames;
+	}
+
+	/**
+	 * Gets the workloadMixNames
+	 * @return Returns a String[]
+	 */
+	public static String[] getWorkloadMixNames() {
+		return workloadMixNames;
+	}
+
+	/**
+	 * Gets the webInterfaceNames
+	 * @return Returns a String[]
+	 */
+	public static String[] getWebInterfaceNames() {
+		return webInterfaceNames;
+	}
+
+	/**
+	 * Gets the webInterfaceNames
+	 * @return Returns a String[]
+	 */
+	public static String[] getCachingTypeNames() {
+		return cachingTypeNames;
+	}
+
+	/**
+	 * Gets the scenarioMixes
+	 * @return Returns a int[][]
+	 */
+	public static int[][] getScenarioMixes() {
+		return scenarioMixes;
+	}
+
+	/**
+	 * Gets the trace
+	 * @return Returns a boolean
+	 */
+	public static boolean getTrace() {
+		return trace;
+	}
+	/**
+	 * Sets the trace
+	 * @param trace The trace to set
+	 */
+	public static void setTrace(boolean traceValue) {
+		trace = traceValue;
+	}
+
+	/**
+	 * Gets the mAX_USERS.
+	 * @return Returns a int
+	 */
+	public static int getMAX_USERS() {
+		return MAX_USERS;
+	}
+
+	/**
+	 * Sets the mAX_USERS.
+	 * @param mAX_USERS The mAX_USERS to set
+	 */
+	public static void setMAX_USERS(int mAX_USERS) {
+		MAX_USERS = mAX_USERS;
+		deck = null; // reset the card deck for selecting users
+	}
+
+	/**
+	 * Gets the mAX_QUOTES.
+	 * @return Returns a int
+	 */
+	public static int getMAX_QUOTES() {
+		return MAX_QUOTES;
+	}
+
+	/**
+	 * Sets the mAX_QUOTES.
+	 * @param mAX_QUOTES The mAX_QUOTES to set
+	 */
+	public static void setMAX_QUOTES(int mAX_QUOTES) {
+		MAX_QUOTES = mAX_QUOTES;
+	}
+
+	/**
+	 * Gets the mAX_HOLDINGS.
+	 * @return Returns a int
+	 */
+	public static int getMAX_HOLDINGS() {
+		return MAX_HOLDINGS;
+	}
+
+	/**
+	 * Sets the mAX_HOLDINGS.
+	 * @param mAX_HOLDINGS The mAX_HOLDINGS to set
+	 */
+	public static void setMAX_HOLDINGS(int mAX_HOLDINGS) {
+		MAX_HOLDINGS = mAX_HOLDINGS;
+	}
+
+	/**
+	 * Gets the actionTrace.
+	 * @return Returns a boolean
+	 */
+	public static boolean getActionTrace() {
+		return actionTrace;
+	}
+
+	/**
+	 * Sets the actionTrace.
+	 * @param actionTrace The actionTrace to set
+	 */
+	public static void setActionTrace(boolean actionTrace) {
+		TradeConfig.actionTrace = actionTrace;
+	}
+
+	/**
+	 * Gets the scenarioCount.
+	 * @return Returns a int
+	 */
+	public static int getScenarioCount() {
+		return scenarioCount;
+	}
+
+	/**
+	 * Sets the scenarioCount.
+	 * @param scenarioCount The scenarioCount to set
+	 */
+	public static void setScenarioCount(int scenarioCount) {
+		TradeConfig.scenarioCount = scenarioCount;
+	}
+
+	public static synchronized void incrementScenarioCount() {
+		scenarioCount++;
+	}
+
+	/**
+	 * Gets the jdbc driver needs global transaction
+	 * Some XA Drivers require a global transaction to be started
+	 * for all SQL calls.  To work around this, set this to true
+	 * to cause the direct mode to start a user transaction.
+	 * @return Returns a boolean
+	 */
+	public static boolean getJDBCDriverNeedsGlobalTransaction() {
+		return JDBCDriverNeedsGlobalTransaction;
+	}
+
+	/**
+	 * Sets the jdbc driver needs global transaction
+         * @param JDBCDriverNeedsGlobalTransactionVal the value
+	 */
+	public static void setJDBCDriverNeedsGlobalTransaction(boolean JDBCDriverNeedsGlobalTransactionVal) {
+		JDBCDriverNeedsGlobalTransaction = JDBCDriverNeedsGlobalTransactionVal;
+	}
+
+	/**
+	 * Gets the updateQuotePrices.
+	 * @return Returns a boolean
+	 */
+	public static boolean getUpdateQuotePrices() {
+		return updateQuotePrices;
+	}
+
+	/**
+	 * Sets the updateQuotePrices.
+	 * @param updateQuotePrices The updateQuotePrices to set
+	 */
+	public static void setUpdateQuotePrices(boolean updateQuotePrices) {
+		TradeConfig.updateQuotePrices = updateQuotePrices;
+	}
+	
+	public static String getSoapURL() {
+		return SoapURL;
+	}
+	
+	public static void setSoapURL(String value) {
+		SoapURL = value;
+	}
+	
+	public static int getAccessMode() {
+		return accessMode;
+	}
+	
+	public static void setAccessMode(int value) {
+		accessMode = value;
+	}
+
+    public static ModeType getRunTimeMode() {
+        return runTimeMode;
+    }
+    
+    public static void setRunTimeMode(ModeType value) {
+        runTimeMode = value;
+    }
+
+	public static int getPrimIterations() {
+		return primIterations;
+	}
+	
+	public static void setPrimIterations(int iter) {
+		primIterations = iter;
+	}	
+
+    public static boolean getLongRun() {
+        return longRun;
+    }
+
+    public static void setLongRun(boolean longRun) {
+        TradeConfig.longRun = longRun;
+    }
+
+    public static void setPublishQuotePriceChange(boolean publishQuotePriceChange) {
+        TradeConfig.publishQuotePriceChange = publishQuotePriceChange;
+    }
+    
+    public static boolean getPublishQuotePriceChange() {
+        return publishQuotePriceChange;
+    }
+
+    public static void setMarketSummaryInterval(int seconds) {
+        TradeConfig.marketSummaryInterval = seconds;
+    }
+    
+    public static  int getMarketSummaryInterval() {
+        return TradeConfig.marketSummaryInterval;
+    }
+    
+    /**
+	 * Return the list of JPA Layer names
+	 * Creation date: (01/10/2009)
+	 * @return java.lang.String[]
+	 */
+	public static java.lang.String[] getJPALayerNames() {
+		return jpaLayerNames;
+    }
+
+}

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/pom.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/pom.xml (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/pom.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    
+    <parent>
+        <groupId>org.apache.aries.samples.ariestrader</groupId>
+        <artifactId>modules</artifactId>
+        <version>0.1-incubating</version>
+    </parent>
+    
+    <groupId>org.apache.aries.samples.ariestrader</groupId>
+    <artifactId>org.apache.aries.samples.ariestrader.web</artifactId>    
+    <packaging>bundle</packaging>
+    <name>AriesTrader :: Modules - Web </name>
+    <description>A version of AriesTrader for basic Web containers</description>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.samples.ariestrader</groupId>
+            <artifactId>org.apache.aries.samples.ariestrader.util</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.samples.ariestrader</groupId>
+            <artifactId>org.apache.aries.samples.ariestrader.api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- web container provided specs -->
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jsp_2.1_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+              <groupId>org.apache.felix</groupId>
+              <artifactId>maven-bundle-plugin</artifactId>
+              <configuration>
+                <instructions>
+                  <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                  <Bundle-Version>${pom.version}</Bundle-Version>
+                  <Web-ContextPath>/ariestrader</Web-ContextPath>
+                  <Web-JSPExtractLocation>/</Web-JSPExtractLocation>
+                  <Private-Package>org.apache.aries.samples.ariestrader.web.*</Private-Package>
+                  <Export-Package>!org.apache.aries.samples.ariestrader.web.*</Export-Package>
+                  <Import-Package>
+                    javax.servlet*;version=2.5,
+                    *
+                  </Import-Package>
+                </instructions>
+              </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+</project>

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/OrdersAlertFilter.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/OrdersAlertFilter.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/OrdersAlertFilter.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/OrdersAlertFilter.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,103 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.web;
+
+import java.io.IOException;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.aries.samples.ariestrader.api.TradeServicesManager;
+import org.apache.aries.samples.ariestrader.api.TradeServiceUtilities;
+import org.apache.aries.samples.ariestrader.api.TradeServices;
+import org.apache.aries.samples.ariestrader.util.*;
+
+public class OrdersAlertFilter implements Filter {
+
+    private static TradeServicesManager tradeServicesManager = null;
+
+    /**
+     * Constructor for CompletedOrdersAlertFilter
+     */
+    public OrdersAlertFilter() {
+        super();
+    }
+
+    /**
+     * @see Filter#init(FilterConfig)
+     */
+    private FilterConfig filterConfig = null;
+    public void init(FilterConfig filterConfig) throws ServletException {
+        this.filterConfig = filterConfig;
+    }
+
+    /**
+     * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
+     */
+    public void doFilter(
+                        ServletRequest req,
+                        ServletResponse resp,
+                        FilterChain chain)
+    throws IOException, ServletException {
+        if (filterConfig == null)
+            return;
+
+        if (tradeServicesManager == null) {
+            tradeServicesManager = TradeServiceUtilities.getTradeServicesManager();
+        }
+        TradeServices tradeServices = tradeServicesManager.getTradeServices();
+
+        try {
+            String action = req.getParameter("action");
+            if ( action != null ) {
+                action = action.trim();
+                if ( (action.length() > 0) && (!action.equals("logout")) ) {
+                    String userID;
+                    if ( action.equals("login") )
+                        userID = req.getParameter("uid");
+                    else
+                        userID = (String) ((HttpServletRequest) req).getSession().getAttribute("uidBean");
+                    if ( (userID != null) && (userID.trim().length()>0) ) {
+
+                        java.util.Collection closedOrders = tradeServices.getClosedOrders(userID);
+                        if ( (closedOrders!=null) && (closedOrders.size() > 0) ) {
+                            req.setAttribute("closedOrders", closedOrders);
+                        }
+                        if (Log.doTrace()) {
+                            Log.printCollection("OrdersAlertFilter: userID="+userID+" closedOrders=", closedOrders);
+                        }
+                    }
+                }
+            }
+        }
+        catch (Exception e) {
+            Log.error(e, "OrdersAlertFilter - Error checking for closedOrders");
+        }
+
+        ServletContext sc = filterConfig.getServletContext();
+        chain.doFilter(req, resp/*wrapper*/);        
+
+    }
+
+    /**
+     * @see Filter#destroy()
+     */
+    public void destroy() {
+        this.filterConfig = null;   
+    }
+
+}
+

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeAppServlet.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeAppServlet.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeAppServlet.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeAppServlet.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,193 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.web;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import org.apache.aries.samples.ariestrader.api.TradeServicesManager;
+import org.apache.aries.samples.ariestrader.api.TradeServiceUtilities;
+import org.apache.aries.samples.ariestrader.api.TradeServices;
+import org.apache.aries.samples.ariestrader.util.*;
+
+import java.io.IOException;
+
+
+/**
+ * 
+ * TradeAppServlet provides the standard web interface to Trade and can be
+ * accessed with the Go Trade! link. Driving benchmark load using this interface
+ * requires a sophisticated web load generator that is capable of filling HTML
+ * forms and posting dynamic data.
+ */
+
+public class TradeAppServlet extends HttpServlet {
+
+    private static TradeServicesManager tradeServicesManager = null;
+
+    /**
+     * Servlet initialization method.
+     */
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        java.util.Enumeration en = config.getInitParameterNames();
+        while (en.hasMoreElements()) {
+            String parm = (String) en.nextElement();
+            String value = config.getInitParameter(parm);
+            TradeConfig.setConfigParam(parm, value);
+        }
+    }
+
+    /**
+     * Returns a string that contains information about TradeScenarioServlet
+     * 
+     * @return The servlet information
+     */
+    public java.lang.String getServletInfo() {
+        return "TradeAppServlet provides the standard web interface to Trade";
+    }
+
+    /**
+     * Process incoming HTTP GET requests
+     * 
+     * @param request
+     *            Object that encapsulates the request to the servlet
+     * @param response
+     *            Object that encapsulates the response from the servlet
+     */
+    public void doGet(javax.servlet.http.HttpServletRequest request,
+            javax.servlet.http.HttpServletResponse response)
+            throws ServletException, IOException {
+        performTask(request, response);
+    }
+
+    /**
+     * Process incoming HTTP POST requests
+     * 
+     * @param request
+     *            Object that encapsulates the request to the servlet
+     * @param response
+     *            Object that encapsulates the response from the servlet
+     */
+    public void doPost(javax.servlet.http.HttpServletRequest request,
+            javax.servlet.http.HttpServletResponse response)
+            throws ServletException, IOException {
+        performTask(request, response);
+    }
+
+    /**
+     * Main service method for TradeAppServlet
+     * 
+     * @param request
+     *            Object that encapsulates the request to the servlet
+     * @param response
+     *            Object that encapsulates the response from the servlet
+     */
+    public void performTask(HttpServletRequest req, HttpServletResponse resp)
+            throws ServletException, IOException {
+
+        String action = null;
+        String userID = null;
+        resp.setContentType("text/html");
+
+        if (tradeServicesManager == null) {
+            tradeServicesManager = TradeServiceUtilities.getTradeServicesManager();
+        }
+        TradeServices tradeServices = tradeServicesManager.getTradeServices();
+
+        TradeServletAction tsAction = new TradeServletAction(tradeServices);
+
+        // Dyna - need status string - prepended to output
+        action = req.getParameter("action");
+
+        ServletContext ctx = getServletConfig().getServletContext();
+
+        if (action == null) {
+            tsAction.doWelcome(ctx, req, resp, "");
+            return;
+        } else if (action.equals("login")) {
+            userID = req.getParameter("uid");
+            String passwd = req.getParameter("passwd");
+            tsAction.doLogin(ctx, req, resp, userID, passwd);
+            return;
+        } else if (action.equals("register")) {
+            userID = req.getParameter("user id");
+            String passwd = req.getParameter("passwd");
+            String cpasswd = req.getParameter("confirm passwd");
+            String fullname = req.getParameter("Full Name");
+            String ccn = req.getParameter("Credit Card Number");
+            String money = req.getParameter("money");
+            String email = req.getParameter("email");
+            String smail = req.getParameter("snail mail");
+            tsAction.doRegister(ctx, req, resp, userID, passwd, cpasswd,
+                    fullname, ccn, money, email, smail);
+            return;
+        }
+
+        // The rest of the operations require the user to be logged in -
+        // Get the Session and validate the user.
+        HttpSession session = req.getSession();
+        userID = (String) session.getAttribute("uidBean");
+
+        if (userID == null) {
+            System.out
+                    .println("TradeAppServlet service error: User Not Logged in");
+            tsAction.doWelcome(ctx, req, resp, "User Not Logged in");
+            return;
+        }
+        if (action.equals("quotes")) {
+            String symbols = req.getParameter("symbols");
+            tsAction.doQuotes(ctx, req, resp, userID, symbols);
+        } else if (action.equals("buy")) {
+            String symbol = req.getParameter("symbol");
+            String quantity = req.getParameter("quantity");
+            tsAction.doBuy(ctx, req, resp, userID, symbol, quantity);
+        } else if (action.equals("sell")) {
+            int holdingID = Integer.parseInt(req.getParameter("holdingID"));
+            tsAction.doSell(ctx, req, resp, userID, new Integer(holdingID));
+        } else if (action.equals("portfolio")
+                || action.equals("portfolioNoEdge")) {
+            tsAction.doPortfolio(ctx, req, resp, userID, "Portfolio as of "
+                    + new java.util.Date());
+        } else if (action.equals("logout")) {
+            tsAction.doLogout(ctx, req, resp, userID);
+        } else if (action.equals("home")) {
+            tsAction.doHome(ctx, req, resp, userID, "Ready to Trade");
+        } else if (action.equals("account")) {
+            tsAction.doAccount(ctx, req, resp, userID, "");
+        } else if (action.equals("update_profile")) {
+            String password = req.getParameter("password");
+            String cpassword = req.getParameter("cpassword");
+            String fullName = req.getParameter("fullname");
+            String address = req.getParameter("address");
+            String creditcard = req.getParameter("creditcard");
+            String email = req.getParameter("email");
+            tsAction.doAccountUpdate(ctx, req, resp, userID,
+                    password == null ? "" : password.trim(),
+                    cpassword == null ? "" : cpassword.trim(),
+                    fullName == null ? "" : fullName.trim(),
+                    address == null ? "" : address.trim(),
+                    creditcard == null ? "" : creditcard.trim(),
+                    email == null ? "" : email.trim());
+        } else {
+            System.out.println("TradeAppServlet: Invalid Action=" + action);
+            tsAction.doWelcome(ctx, req, resp,
+                    "TradeAppServlet: Invalid Action" + action);
+        }
+    }
+
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java (added)
+++ aries/tags/samples-0.1-incubating/ariestrader/modules/ariestrader-web/src/main/java/org/apache/aries/samples/ariestrader/web/TradeBuildDB.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,305 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.samples.ariestrader.web;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+
+import org.apache.aries.samples.ariestrader.api.TradeDBManager;
+import org.apache.aries.samples.ariestrader.api.TradeServicesManager;
+import org.apache.aries.samples.ariestrader.api.TradeServiceUtilities;
+import org.apache.aries.samples.ariestrader.api.TradeServices;
+import org.apache.aries.samples.ariestrader.api.persistence.*;
+import org.apache.aries.samples.ariestrader.util.*;
+
+/**
+ * TradeBuildDB uses operations provided by the TradeApplication to 
+ *   (a) create the Database tables 
+ *   (b) populate a AriesTrader database without creating the tables. 
+ * Specifically, a new AriesTrader User population is created using
+ * UserIDs of the form "uid:xxx" where xxx is a sequential number 
+ * (e.g. uid:0, uid:1, etc.). New stocks are also created of the form "s:xxx",
+ * again where xxx represents sequential numbers (e.g. s:1, s:2, etc.)
+ */
+public class TradeBuildDB {
+
+    private static TradeServicesManager tradeServicesManager = null;
+    private static TradeDBManager tradeDBManager = null;
+
+    /**
+     * Populate a Trade DB using standard out as a log
+     */
+    public TradeBuildDB() throws Exception {
+        this(new java.io.PrintWriter(System.out), null);
+    }
+
+    /**
+     * Re-create the AriesTrader db tables and populate them OR just populate a 
+     * AriesTrader DB, logging to the provided output stream
+     */
+    public TradeBuildDB(java.io.PrintWriter out, String warPath)
+        throws Exception {
+        String symbol, companyName;
+        int errorCount = 0; // Give up gracefully after 10 errors
+        if (tradeServicesManager == null) {
+            tradeServicesManager = TradeServiceUtilities.getTradeServicesManager();
+        }
+        TradeServices tradeServices = tradeServicesManager.getTradeServices();
+
+        if (tradeDBManager == null) {
+            tradeDBManager = TradeServiceUtilities.getTradeDBManager();
+        }
+
+        // TradeStatistics.statisticsEnabled=false; // disable statistics
+        out.println("<HEAD><BR><EM> TradeBuildDB: Building AriesTrader Database...</EM><BR>"
+            + "This operation will take several minutes. Please wait...</HEAD>");
+        out.println("<BODY>");
+
+        if (warPath != null) {
+            boolean success = false;
+            String dbProductName = null;
+            File ddlFile = null;
+            Object[] sqlBuffer = null;
+
+            // Find out the Database being used
+            try {
+                dbProductName = tradeDBManager.checkDBProductName();
+            } catch (Exception e) {
+                Log.error(e, "TradeBuildDB: Unable to check DB Product name");
+            }
+            if (dbProductName == null) {
+                out.println("<BR>TradeBuildDB: **** Unable to check DB Product name,"
+                    + "please check Database/AppServer configuration and retry ****</BR></BODY>");
+                return;
+            }
+
+            // Locate DDL file for the specified database
+            try {
+                out.println("<BR>TradeBuildDB: **** Database Product detected: "
+                    + dbProductName + " ****</BR>");
+                if (dbProductName.startsWith("DB2/")) { // if db is DB2
+                    ddlFile = new File(warPath + File.separatorChar + "dbscripts"
+                        + File.separatorChar + "db2" + File.separatorChar + "Table.ddl");
+                } else if (dbProductName.startsWith("Apache Derby")) { // if db is Derby
+                    ddlFile = new File(warPath + File.separatorChar + "dbscripts"
+                        + File.separatorChar + "derby" + File.separatorChar + "Table.ddl");
+                } else if (dbProductName.startsWith("Oracle")) { // if the Db is Oracle
+                    ddlFile = new File(warPath + File.separatorChar + "dbscripts"
+                        + File.separatorChar + "oracle" + File.separatorChar + "Table.ddl");
+                } else { // Unsupported "Other" Database
+                    ddlFile = new File(warPath + File.separatorChar + "dbscripts"
+                        + File.separatorChar + "other" + File.separatorChar + "Table.ddl");
+                    out.println("<BR>TradeBuildDB: **** This Database is "
+                        + "unsupported/untested use at your own risk ****</BR>");
+                }
+
+                if (!ddlFile.exists()) {
+                    Log.error("TradeBuildDB: DDL file doesnt exist at path "
+                        + ddlFile.getCanonicalPath()
+                        + " , please provide the file and retry");
+                    out.println("<BR>TradeBuildDB: DDL file doesnt exist at path <I>"
+                        + ddlFile.getCanonicalPath() +
+                        "</I> , please provide the file and retry ****</BR></BODY>");
+                    return;
+                }
+                out.println("<BR>TradeBuildDB: **** The DDL file at path <I>"
+                    + ddlFile.getCanonicalPath()
+                    + "</I> will be used ****</BR>");
+                out.flush();
+            } catch (Exception e) {
+                Log.error(e,
+                    "TradeBuildDB: Unable to locate DDL file for the specified database");
+                out.println("<BR>TradeBuildDB: **** Unable to locate DDL file for "
+                    + "the specified database ****</BR></BODY>");
+                return;
+            }
+
+            // parse the DDL file and fill the SQL commands into a buffer
+            try {
+                sqlBuffer = parseDDLToBuffer(ddlFile);
+            } catch (Exception e) {
+                Log.error(e, "TradeBuildDB: Unable to parse DDL file");
+                out.println("<BR>TradeBuildDB: **** Unable to parse DDL file for the specified "+
+                    "database ****</BR></BODY>");
+                return;
+            }
+            if ((sqlBuffer == null) || (sqlBuffer.length == 0)) {
+                out.println("<BR>TradeBuildDB: **** Parsing DDL file returned empty buffer, please check "+
+                    "that a valid DB specific DDL file is available and retry ****</BR></BODY>");
+                return;
+            }
+
+            // send the sql commands buffer to drop and recreate the AriesTrader tables
+            out.println("<BR>TradeBuildDB: **** Dropping and Recreating the AriesTrader tables... ****</BR>");
+            try {
+                success = tradeDBManager.recreateDBTables(sqlBuffer, out);
+            } catch (Exception e) {
+                Log.error(e,
+                    "TradeBuildDB: Unable to drop and recreate AriesTrader Db Tables, "+
+                    "please check for database consistency before continuing");
+            }
+            if (!success) {
+                out.println("<BR>TradeBuildDB: **** Unable to drop and recreate AriesTrader Db Tables, "+
+                    "please check for database consistency before continuing ****</BR></BODY>");
+                return;
+            }
+            out.println("<BR>TradeBuildDB: **** AriesTrader tables successfully created! ****</BR><BR><b> "+
+                "Please Stop and Re-start your AriesTrader application (or your application server) and then use "+
+                "the \"Repopulate AriesTrader Database\" link to populate your database.</b></BR><BR><BR></BODY>");
+            return;
+        } // end of createDBTables
+
+        out.println("<BR>TradeBuildDB: **** Creating "
+            + TradeConfig.getMAX_QUOTES() + " Quotes ****</BR>");
+        // Attempt to delete all of the Trade users and Trade Quotes first
+        try {
+            tradeDBManager.resetTrade(true);
+        } catch (Exception e) {
+            Log.error(e, "TradeBuildDB: Unable to delete Trade users "+
+                "(uid:0, uid:1, ...) and Trade Quotes (s:0, s:1, ...)");
+        }
+        for (int i = 0; i < TradeConfig.getMAX_QUOTES(); i++) {
+            symbol = "s:" + i;
+            companyName = "S" + i + " Incorporated";
+            try {
+                tradeServices.createQuote(symbol, companyName,
+				    new java.math.BigDecimal(TradeConfig.rndPrice()));
+                if (i % 10 == 0) {
+                    out.print("....." + symbol);
+                    if (i % 100 == 0) {
+                        out.println(" -<BR>");
+                        out.flush();
+                    }
+                }
+            } catch (Exception e) {
+                if (errorCount++ >= 10) {
+                    String error = "Populate Trade DB aborting after 10 create quote errors. Check "+
+                        "the EJB datasource configuration. Check the log for details <BR><BR> Exception is: <BR> "
+                        + e.toString();
+                    Log.error(e, error);
+                    throw e;
+                }
+            }
+        }
+        out.println("<BR>");
+        out.println("<BR>**** Registering " + TradeConfig.getMAX_USERS()
+            + " Users **** ");
+        errorCount = 0; // reset for user registrations
+
+        // Registration is a formal operation in Trade 2.
+        for (int i = 0; i < TradeConfig.getMAX_USERS(); i++) {
+            String userID = "uid:" + i;
+            String fullname = TradeConfig.rndFullName();
+            String email = TradeConfig.rndEmail(userID);
+            String address = TradeConfig.rndAddress();
+            String creditcard = TradeConfig.rndCreditCard();
+            double initialBalance =
+                (double) (TradeConfig.rndInt(100000)) + 200000;
+            if (i == 0) {
+                initialBalance = 1000000; // uid:0 starts with a cool million.
+            }
+            try {
+                AccountDataBean accountData =
+                    tradeServices.register(userID, "xxx", fullname, address,
+                        email, creditcard, new BigDecimal(initialBalance));
+                if (accountData != null) {
+                    if (i % 50 == 0) {
+                        out.print("<BR>Account# " + accountData.getAccountID()
+                            + " userID=" + userID);
+                    }
+
+                    // 0-MAX_HOLDING (inclusive), avg holdings per user = (MAX-0)/2
+                    int holdings = TradeConfig.rndInt(TradeConfig.getMAX_HOLDINGS() + 1); 
+                    double quantity = 0;
+                    for (int j = 0; j < holdings; j++) {
+                        symbol = TradeConfig.rndSymbol();
+                        quantity = TradeConfig.rndQuantity();
+                        tradeServices.buy(userID, symbol, quantity,
+						    TradeConfig.orderProcessingMode);
+                    }
+                    if (i % 50 == 0) {
+                        out.println(" has " + holdings + " holdings.");
+                        out.flush();
+                    }
+                } else {
+                    out.println("<BR>UID " + userID
+                        + " already registered.</BR>");
+                    out.flush();
+                }
+
+            } catch (Exception e) {
+                if (errorCount++ >= 10) {
+                    String error = "Populate Trade DB aborting after 10 user registration errors. "+
+                        "Check the log for details. <BR><BR> Exception is: <BR>" + e.toString();
+                    Log.error(e, error);
+                    throw e;
+                }
+            }
+        } // end-for
+        out.println("</BODY>");
+    }
+
+    public Object[] parseDDLToBuffer(File ddlFile) throws Exception {
+        BufferedReader br = null;
+        ArrayList sqlBuffer = new ArrayList(30); // initial capacity 30 assuming we have 30 ddl-sql statements to read
+
+        try {
+            if (Log.doTrace())
+                Log.traceEnter("TradeBuildDB:parseDDLToBuffer - " + ddlFile);
+
+            br = new BufferedReader(new FileReader(ddlFile));
+            String s;
+            String sql = new String();
+            while ((s = br.readLine()) != null) {
+                s = s.trim();
+                if ((s.length() != 0) && (s.charAt(0) != '#')) // Empty lines or lines starting with "#" are ignored
+                {
+                    sql = sql + " " + s;
+                    if (s.endsWith(";")) // reached end of sql statement
+                    {
+                        sql = sql.replace(';', ' '); // remove the semicolon
+                        sqlBuffer.add(sql);
+                        sql = "";
+                    }
+                }
+            }
+        } catch (IOException ex) {
+            Log.error("TradeBuildDB:parseDDLToBuffer Exeception during open/read of File: "
+                + ddlFile, ex);
+            throw ex;
+        } finally {
+            if (br != null) {
+                try {
+                    br.close();
+                } catch (IOException ex) {
+                    Log.error("TradeBuildDB:parseDDLToBuffer Failed to close BufferedReader",
+                        ex);
+                }
+            }
+        }
+        return sqlBuffer.toArray();
+    }
+
+    public static void main(String args[]) throws Exception {
+        new TradeBuildDB();
+
+    }
+}



Mime
View raw message