geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r809686 [3/6] - in /geronimo/daytrader/trunk/modules: ./ beans/ beans/src/ beans/src/main/ beans/src/main/java/ beans/src/main/java/org/ beans/src/main/java/org/apache/ beans/src/main/java/org/apache/geronimo/ beans/src/main/java/org/apache...
Date Mon, 31 Aug 2009 18:48:45 GMT
Copied: geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java (from r809008, geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java)
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java?p2=geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java&p1=geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java&r1=809008&r2=809686&rev=809686&view=diff
==============================================================================
--- geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java (original)
+++ geronimo/daytrader/trunk/modules/core/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeJEEDirect.java Mon Aug 31 18:48:41 2009
@@ -39,7 +39,7 @@
 import org.apache.geronimo.samples.daytrader.*;
 
 /**
- * TradeDirect uses direct JDBC and JMS access to a
+ * TradeJEEDirect uses direct JDBC and JMS access to a
  * <code>javax.sql.DataSource</code> to implement the business methods of the
  * Trade online broker application. These business methods represent the
  * features and operations that can be performed by customers of the brokerage
@@ -56,1282 +56,1164 @@
  * 
  */
 
-public class TradeDirect implements TradeServices
+public class TradeJEEDirect implements TradeServices {
 
-{
-	private static String dsName = TradeConfig.DATASOURCE;
+    private static String dsName = TradeConfig.DATASOURCE;
 
-	private static DataSource datasource = null;
+    private static DataSource datasource = null;
 
-	private static BigDecimal ZERO = new BigDecimal(0.0);
+    private static BigDecimal ZERO = new BigDecimal(0.0);
 
-	private boolean inGlobalTxn = false;
+    private boolean inGlobalTxn = false;
 
-	private boolean inSession = false;
+    private boolean inSession = false;
 
-	/**
-     * Zero arg constructor for TradeDirect
+    /**
+     * Zero arg constructor for TradeJEEDirect
      */
-	public TradeDirect() {
-		if (initialized == false)
-			init();
-	}
-
-	public TradeDirect(boolean inSession) {
-		if (initialized == false)
-			init();
+    public TradeJEEDirect() {
+        if (initialized == false)
+            init();
+    }
+
+    public TradeJEEDirect(boolean inSession) {
+        if (initialized == false)
+            init();
 
-		this.inSession = inSession;
-	}
+        this.inSession = inSession;
+    }
 
     /**
      * @see TradeServices#getMarketSummary()
      */
-	public MarketSummaryDataBean getMarketSummary() throws Exception {
+    public MarketSummaryDataBean getMarketSummary() throws Exception {
 
-		MarketSummaryDataBean marketSummaryData = null;
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getMarketSummary - inSession("
-						+ this.inSession + ")");
-
-			conn = getConn();
-			PreparedStatement stmt = getStatement(conn,
-					getTSIAQuotesOrderByChangeSQL,
-					ResultSet.TYPE_SCROLL_INSENSITIVE,
-					ResultSet.CONCUR_READ_ONLY);
-
-			ArrayList topGainersData = new ArrayList(5);
-			ArrayList topLosersData = new ArrayList(5);
-
-			ResultSet rs = stmt.executeQuery();
-
-			int count = 0;
-			while (rs.next() && (count++ < 5)) {
-				QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
-				topLosersData.add(quoteData);
-			}
-
-			stmt.close();
-			stmt = getStatement(
-					conn,
-					"select * from quoteejb q where q.symbol like 's:1__' order by q.change1 DESC",
-					ResultSet.TYPE_SCROLL_INSENSITIVE,
-					ResultSet.CONCUR_READ_ONLY);
-			rs = stmt.executeQuery();
-
-			count = 0;
-			while (rs.next() && (count++ < 5)) {
-				QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
-				topGainersData.add(quoteData);
-			}
-
-			/*
-             * rs.last(); count = 0; while (rs.previous() && (count++ < 5) ) {
-             * QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
-             * topGainersData.add(quoteData); }
+        MarketSummaryDataBean marketSummaryData = null;
+        Connection conn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getMarketSummary - inSession(" + this.inSession + ")");
+
+            conn = getConn();
+            PreparedStatement stmt =
+                getStatement(conn, getTSIAQuotesOrderByChangeSQL, ResultSet.TYPE_SCROLL_INSENSITIVE,
+                    ResultSet.CONCUR_READ_ONLY);
+
+            ArrayList topGainersData = new ArrayList(5);
+            ArrayList topLosersData = new ArrayList(5);
+
+            ResultSet rs = stmt.executeQuery();
+
+            int count = 0;
+            while (rs.next() && (count++ < 5)) {
+                QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
+                topLosersData.add(quoteData);
+            }
+
+            stmt.close();
+            stmt =
+                getStatement(conn, "select * from quoteejb q where q.symbol like 's:1__' order by q.change1 DESC",
+                    ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+            rs = stmt.executeQuery();
+
+            count = 0;
+            while (rs.next() && (count++ < 5)) {
+                QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
+                topGainersData.add(quoteData);
+            }
+
+            /*
+             * rs.last(); count = 0; while (rs.previous() && (count++ < 5) ) { QuoteDataBean quoteData =
+             * getQuoteDataFromResultSet(rs); topGainersData.add(quoteData); }
              */
 
-			stmt.close();
+            stmt.close();
 
-			BigDecimal TSIA = ZERO;
-			BigDecimal openTSIA = ZERO;
-			double volume = 0.0;
-
-			if ((topGainersData.size() > 0) || (topLosersData.size() > 0)) {
-
-				stmt = getStatement(conn, getTSIASQL);
-				rs = stmt.executeQuery();
-
-				if (!rs.next())
-					Log
-							.error("TradeDirect:getMarketSummary -- error w/ getTSIASQL -- no results");
-				else
-					TSIA = rs.getBigDecimal("TSIA");
-				stmt.close();
-
-				stmt = getStatement(conn, getOpenTSIASQL);
-				rs = stmt.executeQuery();
-
-				if (!rs.next())
-					Log
-							.error("TradeDirect:getMarketSummary -- error w/ getOpenTSIASQL -- no results");
-				else
-					openTSIA = rs.getBigDecimal("openTSIA");
-				stmt.close();
-
-				stmt = getStatement(conn, getTSIATotalVolumeSQL);
-				rs = stmt.executeQuery();
-
-				if (!rs.next())
-					Log
-							.error("TradeDirect:getMarketSummary -- error w/ getTSIATotalVolumeSQL -- no results");
-				else
-					volume = rs.getDouble("totalVolume");
-				stmt.close();
-			}
-			commit(conn);
-
-			marketSummaryData = new MarketSummaryDataBean(TSIA, openTSIA,
-					volume, topGainersData, topLosersData);
-
-		}
-
-		catch (Exception e) {
-			Log.error("TradeDirect:login -- error logging in user", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return marketSummaryData;
+            BigDecimal TSIA = ZERO;
+            BigDecimal openTSIA = ZERO;
+            double volume = 0.0;
+
+            if ((topGainersData.size() > 0) || (topLosersData.size() > 0)) {
+
+                stmt = getStatement(conn, getTSIASQL);
+                rs = stmt.executeQuery();
+
+                if (!rs.next())
+                    Log.error("TradeDirect:getMarketSummary -- error w/ getTSIASQL -- no results");
+                else
+                    TSIA = rs.getBigDecimal("TSIA");
+                stmt.close();
+
+                stmt = getStatement(conn, getOpenTSIASQL);
+                rs = stmt.executeQuery();
+
+                if (!rs.next())
+                    Log.error("TradeDirect:getMarketSummary -- error w/ getOpenTSIASQL -- no results");
+                else
+                    openTSIA = rs.getBigDecimal("openTSIA");
+                stmt.close();
+
+                stmt = getStatement(conn, getTSIATotalVolumeSQL);
+                rs = stmt.executeQuery();
+
+                if (!rs.next())
+                    Log.error("TradeDirect:getMarketSummary -- error w/ getTSIATotalVolumeSQL -- no results");
+                else
+                    volume = rs.getDouble("totalVolume");
+                stmt.close();
+            }
+            commit(conn);
+
+            marketSummaryData = new MarketSummaryDataBean(TSIA, openTSIA, volume, topGainersData, topLosersData);
+
+        }
+
+        catch (Exception e) {
+            Log.error("TradeDirect:login -- error logging in user", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return marketSummaryData;
 
-	}
+    }
 
-	/**
+    /**
      * @see TradeServices#buy(String, String, double)
      */
-	public OrderDataBean buy(String userID, String symbol, double quantity,
-			int orderProcessingMode) throws Exception {
+    public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode) throws Exception {
 
-		Connection conn = null;
-		OrderDataBean orderData = null;
-		UserTransaction txn = null;
+        Connection conn = null;
+        OrderDataBean orderData = null;
+        UserTransaction txn = null;
 
-		/*
+        /*
          * total = (quantity * purchasePrice) + orderFee
          */
-		BigDecimal total;
+        BigDecimal total;
 
-		try {
-			if (Log.doTrace())
-				Log.trace(
-						"TradeDirect:buy - inSession(" + this.inSession + ")",
-						userID, symbol, new Double(quantity));
-
-			if (!inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE) {
-				if (Log.doTrace())
-					Log
-							.trace("TradeDirect:buy create/begin global transaction");
-				// FUTURE the UserTransaction be looked up once
-				txn = (javax.transaction.UserTransaction) context
-						.lookup("java:comp/UserTransaction");
-				txn.begin();
-				setInGlobalTxn(true);
-			}
-
-			conn = getConn();
-
-			AccountDataBean accountData = getAccountData(conn, userID);
-			QuoteDataBean quoteData = getQuoteData(conn, symbol);
-			HoldingDataBean holdingData = null; // the buy operation will create
-                                                // the holding
-
-			orderData = createOrder(conn, accountData, quoteData, holdingData,
-					"buy", quantity);
-
-			// Update -- account should be credited during completeOrder
-			BigDecimal price = quoteData.getPrice();
-			BigDecimal orderFee = orderData.getOrderFee();
-			total = (new BigDecimal(quantity).multiply(price)).add(orderFee);
-			// subtract total from account balance
-			creditAccountBalance(conn, accountData, total.negate());
-
-			try {
-				if (orderProcessingMode == TradeConfig.SYNCH)
-					completeOrder(conn, orderData.getOrderID());
-				else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE)
-					queueOrder(orderData.getOrderID(), true); // 2-phase
-                                                                // commit
-			} catch (JMSException je) {
-				Log.error("TradeBean:buy(" + userID + "," + symbol + ","
-						+ quantity + ") --> failed to queueOrder", je);
-				/* On exception - cancel the order */
-
-				cancelOrder(conn, orderData.getOrderID());
-			}
-
-			orderData = getOrderData(conn, orderData.getOrderID().intValue());
-
-			if (txn != null) {
-				if (Log.doTrace())
-					Log.trace("TradeDirect:buy committing global transaction");
-				txn.commit();
-				setInGlobalTxn(false);
-			} else
-				commit(conn);
-		} catch (Exception e) {
-			Log.error("TradeDirect:buy error - rolling back", e);
-			if (getInGlobalTxn())
-				txn.rollback();
-			else
-				rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:buy - inSession(" + this.inSession + ")", userID, symbol, new Double(quantity));
+
+            if (!inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE) {
+                if (Log.doTrace())
+                    Log.trace("TradeDirect:buy create/begin global transaction");
+                // FUTURE the UserTransaction be looked up once
+                txn = (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
+                txn.begin();
+                setInGlobalTxn(true);
+            }
+
+            conn = getConn();
+
+            AccountDataBean accountData = getAccountData(conn, userID);
+            QuoteDataBean quoteData = getQuoteData(conn, symbol);
+            HoldingDataBean holdingData = null; // the buy operation will create
+            // the holding
+
+            orderData = createOrder(conn, accountData, quoteData, holdingData, "buy", quantity);
+
+            // Update -- account should be credited during completeOrder
+            BigDecimal price = quoteData.getPrice();
+            BigDecimal orderFee = orderData.getOrderFee();
+            total = (new BigDecimal(quantity).multiply(price)).add(orderFee);
+            // subtract total from account balance
+            creditAccountBalance(conn, accountData, total.negate());
+
+            try {
+                if (orderProcessingMode == TradeConfig.SYNCH)
+                    completeOrder(conn, orderData.getOrderID());
+                else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE)
+                    queueOrder(orderData.getOrderID(), true); // 2-phase
+                // commit
+            } catch (JMSException je) {
+                Log.error("TradeBean:buy(" + userID + "," + symbol + "," + quantity + ") --> failed to queueOrder", je);
+                /* On exception - cancel the order */
+
+                cancelOrder(conn, orderData.getOrderID());
+            }
+
+            orderData = getOrderData(conn, orderData.getOrderID().intValue());
+
+            if (txn != null) {
+                if (Log.doTrace())
+                    Log.trace("TradeDirect:buy committing global transaction");
+                txn.commit();
+                setInGlobalTxn(false);
+            } else
+                commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:buy error - rolling back", e);
+            if (getInGlobalTxn())
+                txn.rollback();
+            else
+                rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
 
-		return orderData;
-	}
+        return orderData;
+    }
 
-	/**
+    /**
      * @see TradeServices#sell(String, Integer)
      */
-	public OrderDataBean sell(String userID, Integer holdingID,
-			int orderProcessingMode) throws Exception {
-		Connection conn = null;
-		OrderDataBean orderData = null;
-		UserTransaction txn = null;
+    public OrderDataBean sell(String userID, Integer holdingID, int orderProcessingMode) throws Exception {
+        Connection conn = null;
+        OrderDataBean orderData = null;
+        UserTransaction txn = null;
 
-		/*
+        /*
          * total = (quantity * purchasePrice) + orderFee
          */
-		BigDecimal total;
+        BigDecimal total;
 
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:sell - inSession(" + this.inSession
-						+ ")", userID, holdingID);
-
-			if (!inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE) {
-				if (Log.doTrace())
-					Log
-							.trace("TradeDirect:sell create/begin global transaction");
-				// FUTURE the UserTransaction be looked up once
-
-				txn = (javax.transaction.UserTransaction) context
-						.lookup("java:comp/UserTransaction");
-				txn.begin();
-				setInGlobalTxn(true);
-			}
-
-			conn = getConn();
-
-			AccountDataBean accountData = getAccountData(conn, userID);
-			HoldingDataBean holdingData = getHoldingData(conn, holdingID
-					.intValue());
-			QuoteDataBean quoteData = null;
-			if (holdingData != null)
-				quoteData = getQuoteData(conn, holdingData.getQuoteID());
-
-			if ((accountData == null) || (holdingData == null)
-					|| (quoteData == null)) {
-				String error = "TradeDirect:sell -- error selling stock -- unable to find:  \n\taccount="
-						+ accountData
-						+ "\n\tholding="
-						+ holdingData
-						+ "\n\tquote="
-						+ quoteData
-						+ "\nfor user: "
-						+ userID
-						+ " and holdingID: " + holdingID;
-				Log.error(error);
-				if (getInGlobalTxn())
-					txn.rollback();
-				else
-					rollBack(conn, new Exception(error));
-				return orderData;
-			}
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:sell - inSession(" + this.inSession + ")", userID, holdingID);
+
+            if (!inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE) {
+                if (Log.doTrace())
+                    Log.trace("TradeDirect:sell create/begin global transaction");
+                // FUTURE the UserTransaction be looked up once
+
+                txn = (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
+                txn.begin();
+                setInGlobalTxn(true);
+            }
+
+            conn = getConn();
+
+            AccountDataBean accountData = getAccountData(conn, userID);
+            HoldingDataBean holdingData = getHoldingData(conn, holdingID.intValue());
+            QuoteDataBean quoteData = null;
+            if (holdingData != null)
+                quoteData = getQuoteData(conn, holdingData.getQuoteID());
+
+            if ((accountData == null) || (holdingData == null) || (quoteData == null)) {
+                String error =
+                    "TradeDirect:sell -- error selling stock -- unable to find:  \n\taccount=" + accountData
+                        + "\n\tholding=" + holdingData + "\n\tquote=" + quoteData + "\nfor user: " + userID
+                        + " and holdingID: " + holdingID;
+                Log.error(error);
+                if (getInGlobalTxn())
+                    txn.rollback();
+                else
+                    rollBack(conn, new Exception(error));
+                return orderData;
+            }
 
-			double quantity = holdingData.getQuantity();
+            double quantity = holdingData.getQuantity();
 
-			orderData = createOrder(conn, accountData, quoteData, holdingData,
-					"sell", quantity);
+            orderData = createOrder(conn, accountData, quoteData, holdingData, "sell", quantity);
 
-			// Set the holdingSymbol purchaseDate to selling to signify the sell
+            // Set the holdingSymbol purchaseDate to selling to signify the sell
             // is "inflight"
-			updateHoldingStatus(conn, holdingData.getHoldingID(), holdingData
-					.getQuoteID());
+            updateHoldingStatus(conn, holdingData.getHoldingID(), holdingData.getQuoteID());
 
-			// UPDATE -- account should be credited during completeOrder
-			BigDecimal price = quoteData.getPrice();
-			BigDecimal orderFee = orderData.getOrderFee();
-			total = (new BigDecimal(quantity).multiply(price))
-					.subtract(orderFee);
-			creditAccountBalance(conn, accountData, total);
-
-			try {
-				if (orderProcessingMode == TradeConfig.SYNCH)
-					completeOrder(conn, orderData.getOrderID());
-				else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE)
-					queueOrder(orderData.getOrderID(), true); // 2-phase
-                                                                // commit
-			} catch (JMSException je) {
-				Log.error("TradeBean:sell(" + userID + "," + holdingID
-						+ ") --> failed to queueOrder", je);
-				/* On exception - cancel the order */
-
-				cancelOrder(conn, orderData.getOrderID());
-			}
-
-			orderData = getOrderData(conn, orderData.getOrderID().intValue());
-
-			if (txn != null) {
-				if (Log.doTrace())
-					Log.trace("TradeDirect:sell committing global transaction");
-				txn.commit();
-				setInGlobalTxn(false);
-			} else
-				commit(conn);
-		} catch (Exception e) {
-			Log.error("TradeDirect:sell error", e);
-			if (getInGlobalTxn())
-				txn.rollback();
-			else
-				rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
+            // UPDATE -- account should be credited during completeOrder
+            BigDecimal price = quoteData.getPrice();
+            BigDecimal orderFee = orderData.getOrderFee();
+            total = (new BigDecimal(quantity).multiply(price)).subtract(orderFee);
+            creditAccountBalance(conn, accountData, total);
+
+            try {
+                if (orderProcessingMode == TradeConfig.SYNCH)
+                    completeOrder(conn, orderData.getOrderID());
+                else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE)
+                    queueOrder(orderData.getOrderID(), true); // 2-phase
+                // commit
+            } catch (JMSException je) {
+                Log.error("TradeBean:sell(" + userID + "," + holdingID + ") --> failed to queueOrder", je);
+                /* On exception - cancel the order */
+
+                cancelOrder(conn, orderData.getOrderID());
+            }
+
+            orderData = getOrderData(conn, orderData.getOrderID().intValue());
+
+            if (txn != null) {
+                if (Log.doTrace())
+                    Log.trace("TradeDirect:sell committing global transaction");
+                txn.commit();
+                setInGlobalTxn(false);
+            } else
+                commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:sell error", e);
+            if (getInGlobalTxn())
+                txn.rollback();
+            else
+                rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
 
-		return orderData;
-	}
+        return orderData;
+    }
 
-	/**
+    /**
      * @see TradeServices#queueOrder(Integer)
      */
-	public void queueOrder(Integer orderID, boolean twoPhase) throws Exception {
-		if (Log.doTrace())
-			Log.trace("TradeDirect:queueOrder - inSession(" + this.inSession
-					+ ")", orderID);
-
-		javax.jms.Connection conn = null;
-		Session sess = null;
-
-		try {
-			conn = qConnFactory.createConnection();
-			sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-			MessageProducer producer = sess.createProducer(queue);
-
-			TextMessage message = sess.createTextMessage();
-
-			String command = "neworder";
-			message.setStringProperty("command", command);
-			message.setIntProperty("orderID", orderID.intValue());
-			message.setBooleanProperty("twoPhase", twoPhase);
-			message.setBooleanProperty("direct", true);
-			message.setLongProperty("publishTime", System.currentTimeMillis());
-			message.setText("neworder: orderID=" + orderID
-					+ " runtimeMode=Direct twoPhase=" + twoPhase);
-
-			if (Log.doTrace())
-				Log.trace("TradeDirectBean:queueOrder Sending message: "
-						+ message.getText());
-			producer.send(message);
-			sess.close();
-		}
-
-		catch (Exception e) {
-			throw e; // pass the exception back
-		}
-
-		finally {
-			if (sess != null)
-				sess.close();
-			if (conn != null)
-				conn.close();
-		}
-	}
+    public void queueOrder(Integer orderID, boolean twoPhase) throws Exception {
+        if (Log.doTrace())
+            Log.trace("TradeDirect:queueOrder - inSession(" + this.inSession + ")", orderID);
+
+        javax.jms.Connection conn = null;
+        Session sess = null;
+
+        try {
+            conn = qConnFactory.createConnection();
+            sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageProducer producer = sess.createProducer(queue);
+
+            TextMessage message = sess.createTextMessage();
+
+            String command = "neworder";
+            message.setStringProperty("command", command);
+            message.setIntProperty("orderID", orderID.intValue());
+            message.setBooleanProperty("twoPhase", twoPhase);
+            message.setBooleanProperty("direct", true);
+            message.setLongProperty("publishTime", System.currentTimeMillis());
+            message.setText("neworder: orderID=" + orderID + " runtimeMode=Direct twoPhase=" + twoPhase);
+
+            if (Log.doTrace())
+                Log.trace("TradeDirectBean:queueOrder Sending message: " + message.getText());
+            producer.send(message);
+            sess.close();
+        }
+
+        catch (Exception e) {
+            throw e; // pass the exception back
+        }
+
+        finally {
+            if (sess != null)
+                sess.close();
+            if (conn != null)
+                conn.close();
+        }
+    }
 
-	/**
+    /**
      * @see TradeServices#completeOrder(Integer)
      */
-	public OrderDataBean completeOrder(Integer orderID, boolean twoPhase)
-			throws Exception {
-		OrderDataBean orderData = null;
-		Connection conn = null;
-
-		try // twoPhase
-		{
-
-			if (Log.doTrace())
-				Log.trace("TradeDirect:completeOrder - inSession("
-						+ this.inSession + ")", orderID);
-			setInGlobalTxn(!inSession && twoPhase);
-			conn = getConn();
-			orderData = completeOrder(conn, orderID);
-			commit(conn);
-
-		} catch (Exception e) {
-			Log.error("TradeDirect:completeOrder -- error completing order", e);
-			rollBack(conn, e);
-			cancelOrder(orderID, twoPhase);
-		} finally {
-			releaseConn(conn);
-		}
-
-		return orderData;
-
-	}
-
-	private OrderDataBean completeOrder(Connection conn, Integer orderID)
-			throws Exception {
-
-		OrderDataBean orderData = null;
-		if (Log.doTrace())
-			Log.trace("TradeDirect:completeOrderInternal - inSession("
-					+ this.inSession + ")", orderID);
-
-		PreparedStatement stmt = getStatement(conn, getOrderSQL);
-		stmt.setInt(1, orderID.intValue());
-
-		ResultSet rs = stmt.executeQuery();
-
-		if (!rs.next()) {
-			Log.error("TradeDirect:completeOrder -- unable to find order: "
-					+ orderID);
-			stmt.close();
-			return orderData;
-		}
-		orderData = getOrderDataFromResultSet(rs);
-
-		String orderType = orderData.getOrderType();
-		String orderStatus = orderData.getOrderStatus();
-
-		// if (order.isCompleted())
-		if ((orderStatus.compareToIgnoreCase("completed") == 0)
-				|| (orderStatus.compareToIgnoreCase("alertcompleted") == 0)
-				|| (orderStatus.compareToIgnoreCase("cancelled") == 0))
-			throw new Exception(
-					"TradeDirect:completeOrder -- attempt to complete Order that is already completed");
-
-		int accountID = rs.getInt("account_accountID");
-		String quoteID = rs.getString("quote_symbol");
-		int holdingID = rs.getInt("holding_holdingID");
-
-		BigDecimal price = orderData.getPrice();
-		double quantity = orderData.getQuantity();
-		BigDecimal orderFee = orderData.getOrderFee();
-
-		// get the data for the account and quote
-		// the holding will be created for a buy or extracted for a sell
-
-		/*
-         * Use the AccountID and Quote Symbol from the Order AccountDataBean
-         * accountData = getAccountData(accountID, conn); QuoteDataBean
-         * quoteData = getQuoteData(conn, quoteID);
+    public OrderDataBean completeOrder(Integer orderID, boolean twoPhase) throws Exception {
+        OrderDataBean orderData = null;
+        Connection conn = null;
+
+        try // twoPhase
+        {
+
+            if (Log.doTrace())
+                Log.trace("TradeDirect:completeOrder - inSession(" + this.inSession + ")", orderID);
+            setInGlobalTxn(!inSession && twoPhase);
+            conn = getConn();
+            orderData = completeOrder(conn, orderID);
+            commit(conn);
+
+        } catch (Exception e) {
+            Log.error("TradeDirect:completeOrder -- error completing order", e);
+            rollBack(conn, e);
+            cancelOrder(orderID, twoPhase);
+        } finally {
+            releaseConn(conn);
+        }
+
+        return orderData;
+
+    }
+
+    private OrderDataBean completeOrder(Connection conn, Integer orderID) throws Exception {
+
+        OrderDataBean orderData = null;
+        if (Log.doTrace())
+            Log.trace("TradeDirect:completeOrderInternal - inSession(" + this.inSession + ")", orderID);
+
+        PreparedStatement stmt = getStatement(conn, getOrderSQL);
+        stmt.setInt(1, orderID.intValue());
+
+        ResultSet rs = stmt.executeQuery();
+
+        if (!rs.next()) {
+            Log.error("TradeDirect:completeOrder -- unable to find order: " + orderID);
+            stmt.close();
+            return orderData;
+        }
+        orderData = getOrderDataFromResultSet(rs);
+
+        String orderType = orderData.getOrderType();
+        String orderStatus = orderData.getOrderStatus();
+
+        // if (order.isCompleted())
+        if ((orderStatus.compareToIgnoreCase("completed") == 0)
+            || (orderStatus.compareToIgnoreCase("alertcompleted") == 0)
+            || (orderStatus.compareToIgnoreCase("cancelled") == 0))
+            throw new Exception("TradeDirect:completeOrder -- attempt to complete Order that is already completed");
+
+        int accountID = rs.getInt("account_accountID");
+        String quoteID = rs.getString("quote_symbol");
+        int holdingID = rs.getInt("holding_holdingID");
+
+        BigDecimal price = orderData.getPrice();
+        double quantity = orderData.getQuantity();
+        BigDecimal orderFee = orderData.getOrderFee();
+
+        // get the data for the account and quote
+        // the holding will be created for a buy or extracted for a sell
+
+        /*
+         * Use the AccountID and Quote Symbol from the Order AccountDataBean accountData = getAccountData(accountID,
+         * conn); QuoteDataBean quoteData = getQuoteData(conn, quoteID);
          */
-		String userID = getAccountProfileData(conn, new Integer(accountID))
-				.getUserID();
+        String userID = getAccountProfileData(conn, new Integer(accountID)).getUserID();
 
-		HoldingDataBean holdingData = null;
+        HoldingDataBean holdingData = null;
 
-		if (Log.doTrace())
-			Log.trace("TradeDirect:completeOrder--> Completing Order "
-					+ orderData.getOrderID() + "\n\t Order info: " + orderData
-					+ "\n\t Account info: " + accountID + "\n\t Quote info: "
-					+ quoteID);
-
-		// if (order.isBuy())
-		if (orderType.compareToIgnoreCase("buy") == 0) {
-			/*
-             * Complete a Buy operation - create a new Holding for the Account -
-             * deduct the Order cost from the Account balance
+        if (Log.doTrace())
+            Log.trace("TradeDirect:completeOrder--> Completing Order " + orderData.getOrderID() + "\n\t Order info: "
+                + orderData + "\n\t Account info: " + accountID + "\n\t Quote info: " + quoteID);
+
+        // if (order.isBuy())
+        if (orderType.compareToIgnoreCase("buy") == 0) {
+            /*
+             * Complete a Buy operation - create a new Holding for the Account - deduct the Order cost from the Account
+             * balance
              */
 
-			holdingData = createHolding(conn, accountID, quoteID, quantity,
-					price);
-			updateOrderHolding(conn, orderID.intValue(), holdingData
-					.getHoldingID().intValue());
-		}
-
-		// if (order.isSell()) {
-		if (orderType.compareToIgnoreCase("sell") == 0) {
-			/*
-             * Complete a Sell operation - remove the Holding from the Account -
-             * deposit the Order proceeds to the Account balance
+            holdingData = createHolding(conn, accountID, quoteID, quantity, price);
+            updateOrderHolding(conn, orderID.intValue(), holdingData.getHoldingID().intValue());
+        }
+
+        // if (order.isSell()) {
+        if (orderType.compareToIgnoreCase("sell") == 0) {
+            /*
+             * Complete a Sell operation - remove the Holding from the Account - deposit the Order proceeds to the
+             * Account balance
              */
-			holdingData = getHoldingData(conn, holdingID);
-			if (holdingData == null)
-				Log.debug("TradeDirect:completeOrder:sell -- user: " + userID
-						+ " already sold holding: " + holdingID);
-			else
-				removeHolding(conn, holdingID, orderID.intValue());
+            holdingData = getHoldingData(conn, holdingID);
+            if (holdingData == null)
+                Log.debug("TradeDirect:completeOrder:sell -- user: " + userID + " already sold holding: " + holdingID);
+            else
+                removeHolding(conn, holdingID, orderID.intValue());
 
-		}
+        }
 
-		updateOrderStatus(conn, orderData.getOrderID(), "closed");
+        updateOrderStatus(conn, orderData.getOrderID(), "closed");
 
-		if (Log.doTrace())
-			Log.trace("TradeDirect:completeOrder--> Completed Order "
-					+ orderData.getOrderID() + "\n\t Order info: " + orderData
-					+ "\n\t Account info: " + accountID + "\n\t Quote info: "
-					+ quoteID + "\n\t Holding info: " + holdingData);
+        if (Log.doTrace())
+            Log.trace("TradeDirect:completeOrder--> Completed Order " + orderData.getOrderID() + "\n\t Order info: "
+                + orderData + "\n\t Account info: " + accountID + "\n\t Quote info: " + quoteID + "\n\t Holding info: "
+                + holdingData);
 
-		stmt.close();
+        stmt.close();
 
-		commit(conn);
+        commit(conn);
 
-		// signify this order for user userID is complete
-		TradeAction tradeAction = new TradeAction(this);
-		tradeAction.orderCompleted(userID, orderID);
+        // signify this order for user userID is complete
+        TradeAction tradeAction = new TradeAction(this);
+        tradeAction.orderCompleted(userID, orderID);
 
-		return orderData;
-	}
+        return orderData;
+    }
 
-	/**
+    /**
      * @see TradeServices#cancelOrder(Integer, boolean)
      */
-	public void cancelOrder(Integer orderID, boolean twoPhase) throws Exception {
-		OrderDataBean orderData = null;
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:cancelOrder - inSession("
-						+ this.inSession + ")", orderID);
-			setInGlobalTxn(!inSession && twoPhase);
-			conn = getConn();
-			cancelOrder(conn, orderID);
-			commit(conn);
-
-		} catch (Exception e) {
-			Log.error("TradeDirect:cancelOrder -- error cancelling order: "
-					+ orderID, e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-	}
-
-	private void cancelOrder(Connection conn, Integer orderID) throws Exception {
-		updateOrderStatus(conn, orderID, "cancelled");
-	}
-
-	public void orderCompleted(String userID, Integer orderID) throws Exception {
-		throw new UnsupportedOperationException(
-				"TradeDirect:orderCompleted method not supported");
-	}
-
-	private HoldingDataBean createHolding(Connection conn, int accountID,
-			String symbol, double quantity, BigDecimal purchasePrice)
-			throws Exception {
-		HoldingDataBean holdingData = null;
-
-		Timestamp purchaseDate = new Timestamp(System.currentTimeMillis());
-		PreparedStatement stmt = getStatement(conn, createHoldingSQL);
-
-		Integer holdingID = KeySequenceDirect.getNextID(conn, "holding",
-				inSession, getInGlobalTxn());
-		stmt.setInt(1, holdingID.intValue());
-		stmt.setTimestamp(2, purchaseDate);
-		stmt.setBigDecimal(3, purchasePrice);
-		stmt.setDouble(4, quantity);
-		stmt.setString(5, symbol);
-		stmt.setInt(6, accountID);
-		int rowCount = stmt.executeUpdate();
-
-		stmt.close();
-
-		return getHoldingData(conn, holdingID.intValue());
-	}
-
-	private void removeHolding(Connection conn, int holdingID, int orderID)
-			throws Exception {
-		PreparedStatement stmt = getStatement(conn, removeHoldingSQL);
-
-		stmt.setInt(1, holdingID);
-		int rowCount = stmt.executeUpdate();
-		stmt.close();
-
-		// set the HoldingID to NULL for the purchase and sell order now that
-		// the holding as been removed
-		stmt = getStatement(conn, removeHoldingFromOrderSQL);
-
-		stmt.setInt(1, holdingID);
-		rowCount = stmt.executeUpdate();
-		stmt.close();
-
-	}
-
-	private OrderDataBean createOrder(Connection conn,
-			AccountDataBean accountData, QuoteDataBean quoteData,
-			HoldingDataBean holdingData, String orderType, double quantity)
-			throws Exception {
-		OrderDataBean orderData = null;
-
-		Timestamp currentDate = new Timestamp(System.currentTimeMillis());
-
-		PreparedStatement stmt = getStatement(conn, createOrderSQL);
-
-		Integer orderID = KeySequenceDirect.getNextID(conn, "order", inSession,
-				getInGlobalTxn());
-		stmt.setInt(1, orderID.intValue());
-		stmt.setString(2, orderType);
-		stmt.setString(3, "open");
-		stmt.setTimestamp(4, currentDate);
-		stmt.setDouble(5, quantity);
-		stmt.setBigDecimal(6, quoteData.getPrice().setScale(
-				FinancialUtils.SCALE, FinancialUtils.ROUND));
-		stmt.setBigDecimal(7, TradeConfig.getOrderFee(orderType));
-		stmt.setInt(8, accountData.getAccountID().intValue());
-		if (holdingData == null)
-			stmt.setNull(9, java.sql.Types.INTEGER);
-		else
-			stmt.setInt(9, holdingData.getHoldingID().intValue());
-		stmt.setString(10, quoteData.getSymbol());
-		int rowCount = stmt.executeUpdate();
+    public void cancelOrder(Integer orderID, boolean twoPhase) throws Exception {
+        OrderDataBean orderData = null;
+        Connection conn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:cancelOrder - inSession(" + this.inSession + ")", orderID);
+            setInGlobalTxn(!inSession && twoPhase);
+            conn = getConn();
+            cancelOrder(conn, orderID);
+            commit(conn);
+
+        } catch (Exception e) {
+            Log.error("TradeDirect:cancelOrder -- error cancelling order: " + orderID, e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+    }
+
+    private void cancelOrder(Connection conn, Integer orderID) throws Exception {
+        updateOrderStatus(conn, orderID, "cancelled");
+    }
+
+    public void orderCompleted(String userID, Integer orderID) throws Exception {
+        throw new UnsupportedOperationException("TradeDirect:orderCompleted method not supported");
+    }
+
+    private HoldingDataBean createHolding(Connection conn, int accountID, String symbol, double quantity,
+        BigDecimal purchasePrice) throws Exception {
+        HoldingDataBean holdingData = null;
+
+        Timestamp purchaseDate = new Timestamp(System.currentTimeMillis());
+        PreparedStatement stmt = getStatement(conn, createHoldingSQL);
+
+        Integer holdingID = KeySequenceDirect.getNextID(conn, "holding", inSession, getInGlobalTxn());
+        stmt.setInt(1, holdingID.intValue());
+        stmt.setTimestamp(2, purchaseDate);
+        stmt.setBigDecimal(3, purchasePrice);
+        stmt.setDouble(4, quantity);
+        stmt.setString(5, symbol);
+        stmt.setInt(6, accountID);
+        int rowCount = stmt.executeUpdate();
+
+        stmt.close();
+
+        return getHoldingData(conn, holdingID.intValue());
+    }
+
+    private void removeHolding(Connection conn, int holdingID, int orderID) throws Exception {
+        PreparedStatement stmt = getStatement(conn, removeHoldingSQL);
+
+        stmt.setInt(1, holdingID);
+        int rowCount = stmt.executeUpdate();
+        stmt.close();
+
+        // set the HoldingID to NULL for the purchase and sell order now that
+        // the holding as been removed
+        stmt = getStatement(conn, removeHoldingFromOrderSQL);
+
+        stmt.setInt(1, holdingID);
+        rowCount = stmt.executeUpdate();
+        stmt.close();
+
+    }
+
+    private OrderDataBean createOrder(Connection conn, AccountDataBean accountData, QuoteDataBean quoteData,
+        HoldingDataBean holdingData, String orderType, double quantity) throws Exception {
+        OrderDataBean orderData = null;
+
+        Timestamp currentDate = new Timestamp(System.currentTimeMillis());
+
+        PreparedStatement stmt = getStatement(conn, createOrderSQL);
+
+        Integer orderID = KeySequenceDirect.getNextID(conn, "order", inSession, getInGlobalTxn());
+        stmt.setInt(1, orderID.intValue());
+        stmt.setString(2, orderType);
+        stmt.setString(3, "open");
+        stmt.setTimestamp(4, currentDate);
+        stmt.setDouble(5, quantity);
+        stmt.setBigDecimal(6, quoteData.getPrice().setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));
+        stmt.setBigDecimal(7, TradeConfig.getOrderFee(orderType));
+        stmt.setInt(8, accountData.getAccountID().intValue());
+        if (holdingData == null)
+            stmt.setNull(9, java.sql.Types.INTEGER);
+        else
+            stmt.setInt(9, holdingData.getHoldingID().intValue());
+        stmt.setString(10, quoteData.getSymbol());
+        int rowCount = stmt.executeUpdate();
 
-		stmt.close();
+        stmt.close();
 
-		return getOrderData(conn, orderID.intValue());
-	}
+        return getOrderData(conn, orderID.intValue());
+    }
 
-	/**
+    /**
      * @see TradeServices#getOrders(String)
      */
-	public Collection getOrders(String userID) throws Exception {
-		Collection orderDataBeans = new ArrayList();
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getOrders - inSession(" + this.inSession
-						+ ")", userID);
-
-			conn = getConn();
-			PreparedStatement stmt = getStatement(conn, getOrdersByUserSQL);
-			stmt.setString(1, userID);
+    public Collection getOrders(String userID) throws Exception {
+        Collection orderDataBeans = new ArrayList();
+        Connection conn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getOrders - inSession(" + this.inSession + ")", userID);
+
+            conn = getConn();
+            PreparedStatement stmt = getStatement(conn, getOrdersByUserSQL);
+            stmt.setString(1, userID);
 
-			ResultSet rs = stmt.executeQuery();
+            ResultSet rs = stmt.executeQuery();
 
-			// TODO: return top 5 orders for now -- next version will add a
+            // TODO: return top 5 orders for now -- next version will add a
             // getAllOrders method
-			// also need to get orders sorted by order id descending
-			int i = 0;
-			while ((rs.next()) && (i++ < 5)) {
-				OrderDataBean orderData = getOrderDataFromResultSet(rs);
-				orderDataBeans.add(orderData);
-			}
-
-			stmt.close();
-			commit(conn);
-
-		} catch (Exception e) {
-			Log.error("TradeDirect:getOrders -- error getting user orders", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return orderDataBeans;
-	}
+            // also need to get orders sorted by order id descending
+            int i = 0;
+            while ((rs.next()) && (i++ < 5)) {
+                OrderDataBean orderData = getOrderDataFromResultSet(rs);
+                orderDataBeans.add(orderData);
+            }
+
+            stmt.close();
+            commit(conn);
+
+        } catch (Exception e) {
+            Log.error("TradeDirect:getOrders -- error getting user orders", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return orderDataBeans;
+    }
 
-	/**
+    /**
      * @see TradeServices#getClosedOrders(String)
      */
-	public Collection getClosedOrders(String userID) throws Exception {
-		Collection orderDataBeans = new ArrayList();
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getClosedOrders - inSession("
-						+ this.inSession + ")", userID);
-
-			conn = getConn();
-			PreparedStatement stmt = getStatement(conn, getClosedOrdersSQL);
-			stmt.setString(1, userID);
-
-			ResultSet rs = stmt.executeQuery();
-
-			while (rs.next()) {
-				OrderDataBean orderData = getOrderDataFromResultSet(rs);
-				orderData.setOrderStatus("completed");
-				updateOrderStatus(conn, orderData.getOrderID(), orderData
-						.getOrderStatus());
-				orderDataBeans.add(orderData);
-
-			}
-
-			stmt.close();
-			commit(conn);
-		} catch (Exception e) {
-			Log.error("TradeDirect:getOrders -- error getting user orders", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return orderDataBeans;
-	}
+    public Collection getClosedOrders(String userID) throws Exception {
+        Collection orderDataBeans = new ArrayList();
+        Connection conn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getClosedOrders - inSession(" + this.inSession + ")", userID);
+
+            conn = getConn();
+            PreparedStatement stmt = getStatement(conn, getClosedOrdersSQL);
+            stmt.setString(1, userID);
+
+            ResultSet rs = stmt.executeQuery();
+
+            while (rs.next()) {
+                OrderDataBean orderData = getOrderDataFromResultSet(rs);
+                orderData.setOrderStatus("completed");
+                updateOrderStatus(conn, orderData.getOrderID(), orderData.getOrderStatus());
+                orderDataBeans.add(orderData);
+
+            }
+
+            stmt.close();
+            commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:getOrders -- error getting user orders", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return orderDataBeans;
+    }
 
-	/**
+    /**
      * @see TradeServices#createQuote(String, String, BigDecimal)
      */
-	public QuoteDataBean createQuote(String symbol, String companyName,
-			BigDecimal price) throws Exception {
+    public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price) throws Exception {
 
-		QuoteDataBean quoteData = null;
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.traceEnter("TradeDirect:createQuote - inSession("
-						+ this.inSession + ")");
-
-			price = price.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND);
-			double volume = 0.0, change = 0.0;
-
-			conn = getConn();
-			PreparedStatement stmt = getStatement(conn, createQuoteSQL);
-			stmt.setString(1, symbol); // symbol
-			stmt.setString(2, companyName); // companyName
-			stmt.setDouble(3, volume); // volume
-			stmt.setBigDecimal(4, price); // price
-			stmt.setBigDecimal(5, price); // open
-			stmt.setBigDecimal(6, price); // low
-			stmt.setBigDecimal(7, price); // high
-			stmt.setDouble(8, change); // change
-
-			stmt.executeUpdate();
-			stmt.close();
-			commit(conn);
-
-			quoteData = new QuoteDataBean(symbol, companyName, volume, price,
-					price, price, price, change);
-			if (Log.doTrace())
-				Log.traceExit("TradeDirect:createQuote");
-		} catch (Exception e) {
-			Log.error("TradeDirect:createQuote -- error creating quote", e);
-		} finally {
-			releaseConn(conn);
-		}
-		return quoteData;
-	}
+        QuoteDataBean quoteData = null;
+        Connection conn = null;
+        try {
+            if (Log.doTrace())
+                Log.traceEnter("TradeDirect:createQuote - inSession(" + this.inSession + ")");
+
+            price = price.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND);
+            double volume = 0.0, change = 0.0;
+
+            conn = getConn();
+            PreparedStatement stmt = getStatement(conn, createQuoteSQL);
+            stmt.setString(1, symbol); // symbol
+            stmt.setString(2, companyName); // companyName
+            stmt.setDouble(3, volume); // volume
+            stmt.setBigDecimal(4, price); // price
+            stmt.setBigDecimal(5, price); // open
+            stmt.setBigDecimal(6, price); // low
+            stmt.setBigDecimal(7, price); // high
+            stmt.setDouble(8, change); // change
+
+            stmt.executeUpdate();
+            stmt.close();
+            commit(conn);
+
+            quoteData = new QuoteDataBean(symbol, companyName, volume, price, price, price, price, change);
+            if (Log.doTrace())
+                Log.traceExit("TradeDirect:createQuote");
+        } catch (Exception e) {
+            Log.error("TradeDirect:createQuote -- error creating quote", e);
+        } finally {
+            releaseConn(conn);
+        }
+        return quoteData;
+    }
 
-	/**
+    /**
      * @see TradeServices#getQuote(String)
      */
 
-	public QuoteDataBean getQuote(String symbol) throws Exception {
-		QuoteDataBean quoteData = null;
-		Connection conn = null;
-		UserTransaction txn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getQuote - inSession(" + this.inSession
-						+ ")", symbol);
-
-			conn = getConn();
-			quoteData = getQuote(conn, symbol);
-			commit(conn);
-		} catch (Exception e) {
-			Log.error("TradeDirect:getQuote -- error getting quote", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return quoteData;
-	}
-
-	private QuoteDataBean getQuote(Connection conn, String symbol)
-			throws Exception {
-		QuoteDataBean quoteData = null;
-		PreparedStatement stmt = getStatement(conn, getQuoteSQL);
-		stmt.setString(1, symbol); // symbol
-
-		ResultSet rs = stmt.executeQuery();
-
-		if (!rs.next())
-			Log
-					.error("TradeDirect:getQuote -- failure no result.next() for symbol: "
-							+ symbol);
-
-		else
-			quoteData = getQuoteDataFromResultSet(rs);
-
-		stmt.close();
-
-		return quoteData;
-	}
-
-	private QuoteDataBean getQuoteForUpdate(Connection conn, String symbol)
-			throws Exception {
-		QuoteDataBean quoteData = null;
-		PreparedStatement stmt = getStatement(conn, getQuoteForUpdateSQL);
-		stmt.setString(1, symbol); // symbol
-
-		ResultSet rs = stmt.executeQuery();
-
-		if (!rs.next())
-			Log.error("TradeDirect:getQuote -- failure no result.next()");
-
-		else
-			quoteData = getQuoteDataFromResultSet(rs);
+    public QuoteDataBean getQuote(String symbol) throws Exception {
+        QuoteDataBean quoteData = null;
+        Connection conn = null;
+        UserTransaction txn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getQuote - inSession(" + this.inSession + ")", symbol);
+
+            conn = getConn();
+            quoteData = getQuote(conn, symbol);
+            commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:getQuote -- error getting quote", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return quoteData;
+    }
+
+    private QuoteDataBean getQuote(Connection conn, String symbol) throws Exception {
+        QuoteDataBean quoteData = null;
+        PreparedStatement stmt = getStatement(conn, getQuoteSQL);
+        stmt.setString(1, symbol); // symbol
+
+        ResultSet rs = stmt.executeQuery();
+
+        if (!rs.next())
+            Log.error("TradeDirect:getQuote -- failure no result.next() for symbol: " + symbol);
+
+        else
+            quoteData = getQuoteDataFromResultSet(rs);
+
+        stmt.close();
+
+        return quoteData;
+    }
+
+    private QuoteDataBean getQuoteForUpdate(Connection conn, String symbol) throws Exception {
+        QuoteDataBean quoteData = null;
+        PreparedStatement stmt = getStatement(conn, getQuoteForUpdateSQL);
+        stmt.setString(1, symbol); // symbol
+
+        ResultSet rs = stmt.executeQuery();
+
+        if (!rs.next())
+            Log.error("TradeDirect:getQuote -- failure no result.next()");
+
+        else
+            quoteData = getQuoteDataFromResultSet(rs);
 
-		stmt.close();
+        stmt.close();
 
-		return quoteData;
-	}
+        return quoteData;
+    }
 
-	/**
+    /**
      * @see TradeServices#getAllQuotes(String)
      */
-	public Collection getAllQuotes() throws Exception {
-		Collection quotes = new ArrayList();
-		QuoteDataBean quoteData = null;
-
-		Connection conn = null;
-		try {
-			conn = getConn();
-
-			PreparedStatement stmt = getStatement(conn, getAllQuotesSQL);
-
-			ResultSet rs = stmt.executeQuery();
-
-			while (!rs.next()) {
-				quoteData = getQuoteDataFromResultSet(rs);
-				quotes.add(quoteData);
-			}
-
-			stmt.close();
-		} catch (Exception e) {
-			Log.error("TradeDirect:getAllQuotes", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
+    public Collection getAllQuotes() throws Exception {
+        Collection quotes = new ArrayList();
+        QuoteDataBean quoteData = null;
+
+        Connection conn = null;
+        try {
+            conn = getConn();
+
+            PreparedStatement stmt = getStatement(conn, getAllQuotesSQL);
+
+            ResultSet rs = stmt.executeQuery();
+
+            while (!rs.next()) {
+                quoteData = getQuoteDataFromResultSet(rs);
+                quotes.add(quoteData);
+            }
+
+            stmt.close();
+        } catch (Exception e) {
+            Log.error("TradeDirect:getAllQuotes", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
 
-		return quotes;
-	}
+        return quotes;
+    }
 
-	/**
+    /**
      * @see TradeServices#getHoldings(String)
      */
-	public Collection getHoldings(String userID) throws Exception {
-		Collection holdingDataBeans = new ArrayList();
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getHoldings - inSession("
-						+ this.inSession + ")", userID);
-
-			conn = getConn();
-			PreparedStatement stmt = getStatement(conn, getHoldingsForUserSQL);
-			stmt.setString(1, userID);
-
-			ResultSet rs = stmt.executeQuery();
-
-			while (rs.next()) {
-				HoldingDataBean holdingData = getHoldingDataFromResultSet(rs);
-				holdingDataBeans.add(holdingData);
-			}
-
-			stmt.close();
-			commit(conn);
-
-		} catch (Exception e) {
-			Log.error("TradeDirect:getHoldings -- error getting user holings",
-					e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return holdingDataBeans;
-	}
+    public Collection getHoldings(String userID) throws Exception {
+        Collection holdingDataBeans = new ArrayList();
+        Connection conn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getHoldings - inSession(" + this.inSession + ")", userID);
+
+            conn = getConn();
+            PreparedStatement stmt = getStatement(conn, getHoldingsForUserSQL);
+            stmt.setString(1, userID);
+
+            ResultSet rs = stmt.executeQuery();
+
+            while (rs.next()) {
+                HoldingDataBean holdingData = getHoldingDataFromResultSet(rs);
+                holdingDataBeans.add(holdingData);
+            }
+
+            stmt.close();
+            commit(conn);
+
+        } catch (Exception e) {
+            Log.error("TradeDirect:getHoldings -- error getting user holings", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return holdingDataBeans;
+    }
 
-	/**
+    /**
      * @see TradeServices#getHolding(Integer)
      */
-	public HoldingDataBean getHolding(Integer holdingID) throws Exception {
-		HoldingDataBean holdingData = null;
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getHolding - inSession("
-						+ this.inSession + ")", holdingID);
-
-			conn = getConn();
-			holdingData = getHoldingData(holdingID.intValue());
-
-			commit(conn);
-
-		} catch (Exception e) {
-			Log.error("TradeDirect:getHolding -- error getting holding "
-					+ holdingID + "", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return holdingData;
-	}
+    public HoldingDataBean getHolding(Integer holdingID) throws Exception {
+        HoldingDataBean holdingData = null;
+        Connection conn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getHolding - inSession(" + this.inSession + ")", holdingID);
+
+            conn = getConn();
+            holdingData = getHoldingData(holdingID.intValue());
+
+            commit(conn);
+
+        } catch (Exception e) {
+            Log.error("TradeDirect:getHolding -- error getting holding " + holdingID + "", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return holdingData;
+    }
 
-	/**
+    /**
      * @see TradeServices#getAccountData(String)
      */
-	public AccountDataBean getAccountData(String userID) throws Exception {
-		try {
-			AccountDataBean accountData = null;
-			Connection conn = null;
-			try {
-				if (Log.doTrace())
-					Log.trace("TradeDirect:getAccountData - inSession("
-							+ this.inSession + ")", userID);
-
-				conn = getConn();
-				accountData = getAccountData(conn, userID);
-				commit(conn);
-
-			} catch (Exception e) {
-				Log
-						.error(
-								"TradeDirect:getAccountData -- error getting account data",
-								e);
-				rollBack(conn, e);
-			} finally {
-				releaseConn(conn);
-			}
-			return accountData;
-		} catch (Exception e) {
-			throw new Exception(e.getMessage(), e);
-		}
-	}
-
-	private AccountDataBean getAccountData(Connection conn, String userID)
-			throws Exception {
-		PreparedStatement stmt = getStatement(conn, getAccountForUserSQL);
-		stmt.setString(1, userID);
-		ResultSet rs = stmt.executeQuery();
-		AccountDataBean accountData = getAccountDataFromResultSet(rs);
-		stmt.close();
-		return accountData;
-	}
-
-	private AccountDataBean getAccountDataForUpdate(Connection conn,
-			String userID) throws Exception {
-		PreparedStatement stmt = getStatement(conn,
-				getAccountForUserForUpdateSQL);
-		stmt.setString(1, userID);
-		ResultSet rs = stmt.executeQuery();
-		AccountDataBean accountData = getAccountDataFromResultSet(rs);
-		stmt.close();
-		return accountData;
-	}
+    public AccountDataBean getAccountData(String userID) throws Exception {
+        try {
+            AccountDataBean accountData = null;
+            Connection conn = null;
+            try {
+                if (Log.doTrace())
+                    Log.trace("TradeDirect:getAccountData - inSession(" + this.inSession + ")", userID);
+
+                conn = getConn();
+                accountData = getAccountData(conn, userID);
+                commit(conn);
+
+            } catch (Exception e) {
+                Log.error("TradeDirect:getAccountData -- error getting account data", e);
+                rollBack(conn, e);
+            } finally {
+                releaseConn(conn);
+            }
+            return accountData;
+        } catch (Exception e) {
+            throw new Exception(e.getMessage(), e);
+        }
+    }
+
+    private AccountDataBean getAccountData(Connection conn, String userID) throws Exception {
+        PreparedStatement stmt = getStatement(conn, getAccountForUserSQL);
+        stmt.setString(1, userID);
+        ResultSet rs = stmt.executeQuery();
+        AccountDataBean accountData = getAccountDataFromResultSet(rs);
+        stmt.close();
+        return accountData;
+    }
+
+    private AccountDataBean getAccountDataForUpdate(Connection conn, String userID) throws Exception {
+        PreparedStatement stmt = getStatement(conn, getAccountForUserForUpdateSQL);
+        stmt.setString(1, userID);
+        ResultSet rs = stmt.executeQuery();
+        AccountDataBean accountData = getAccountDataFromResultSet(rs);
+        stmt.close();
+        return accountData;
+    }
 
-	/**
+    /**
      * @see TradeServices#getAccountData(String)
      */
-	public AccountDataBean getAccountData(int accountID) throws Exception {
-		AccountDataBean accountData = null;
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getAccountData - inSession("
-						+ this.inSession + ")", new Integer(accountID));
-
-			conn = getConn();
-			accountData = getAccountData(accountID, conn);
-			commit(conn);
-
-		} catch (Exception e) {
-			Log.error(
-					"TradeDirect:getAccountData -- error getting account data",
-					e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return accountData;
-	}
-
-	private AccountDataBean getAccountData(int accountID, Connection conn)
-			throws Exception {
-		PreparedStatement stmt = getStatement(conn, getAccountSQL);
-		stmt.setInt(1, accountID);
-		ResultSet rs = stmt.executeQuery();
-		AccountDataBean accountData = getAccountDataFromResultSet(rs);
-		stmt.close();
-		return accountData;
-	}
-
-	private AccountDataBean getAccountDataForUpdate(int accountID,
-			Connection conn) throws Exception {
-		PreparedStatement stmt = getStatement(conn, getAccountForUpdateSQL);
-		stmt.setInt(1, accountID);
-		ResultSet rs = stmt.executeQuery();
-		AccountDataBean accountData = getAccountDataFromResultSet(rs);
-		stmt.close();
-		return accountData;
-	}
-
-	private QuoteDataBean getQuoteData(String symbol) throws Exception {
-		QuoteDataBean quoteData = null;
-		Connection conn = null;
-		try {
-			conn = getConn();
-			quoteData = getQuoteData(conn, symbol);
-			commit(conn);
-		} catch (Exception e) {
-			Log.error("TradeDirect:getQuoteData -- error getting data", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return quoteData;
-	}
-
-	private QuoteDataBean getQuoteData(Connection conn, String symbol)
-			throws Exception {
-		QuoteDataBean quoteData = null;
-		PreparedStatement stmt = getStatement(conn, getQuoteSQL);
-		stmt.setString(1, symbol);
-		ResultSet rs = stmt.executeQuery();
-		if (!rs.next())
-			Log
-					.error("TradeDirect:getQuoteData -- could not find quote for symbol="
-							+ symbol);
-		else
-			quoteData = getQuoteDataFromResultSet(rs);
-		stmt.close();
-		return quoteData;
-	}
-
-	private HoldingDataBean getHoldingData(int holdingID) throws Exception {
-		HoldingDataBean holdingData = null;
-		Connection conn = null;
-		try {
-			conn = getConn();
-			holdingData = getHoldingData(conn, holdingID);
-			commit(conn);
-		} catch (Exception e) {
-			Log.error("TradeDirect:getHoldingData -- error getting data", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return holdingData;
-	}
-
-	private HoldingDataBean getHoldingData(Connection conn, int holdingID)
-			throws Exception {
-		HoldingDataBean holdingData = null;
-		PreparedStatement stmt = getStatement(conn, getHoldingSQL);
-		stmt.setInt(1, holdingID);
-		ResultSet rs = stmt.executeQuery();
-		if (!rs.next())
-			Log.error("TradeDirect:getHoldingData -- no results -- holdingID="
-					+ holdingID);
-		else
-			holdingData = getHoldingDataFromResultSet(rs);
-
-		stmt.close();
-		return holdingData;
-	}
-
-	private OrderDataBean getOrderData(int orderID) throws Exception {
-		OrderDataBean orderData = null;
-		Connection conn = null;
-		try {
-			conn = getConn();
-			orderData = getOrderData(conn, orderID);
-			commit(conn);
-		} catch (Exception e) {
-			Log.error("TradeDirect:getOrderData -- error getting data", e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return orderData;
-	}
-
-	private OrderDataBean getOrderData(Connection conn, int orderID)
-			throws Exception {
-		OrderDataBean orderData = null;
-		if (Log.doTrace())
-			Log.trace("TradeDirect:getOrderData(conn, " + orderID + ")");
-		PreparedStatement stmt = getStatement(conn, getOrderSQL);
-		stmt.setInt(1, orderID);
-		ResultSet rs = stmt.executeQuery();
-		if (!rs.next())
-			Log.error("TradeDirect:getOrderData -- no results for orderID:"
-					+ orderID);
-		else
-			orderData = getOrderDataFromResultSet(rs);
-		stmt.close();
-		return orderData;
-	}
+    public AccountDataBean getAccountData(int accountID) throws Exception {
+        AccountDataBean accountData = null;
+        Connection conn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getAccountData - inSession(" + this.inSession + ")", new Integer(accountID));
+
+            conn = getConn();
+            accountData = getAccountData(accountID, conn);
+            commit(conn);
+
+        } catch (Exception e) {
+            Log.error("TradeDirect:getAccountData -- error getting account data", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return accountData;
+    }
+
+    private AccountDataBean getAccountData(int accountID, Connection conn) throws Exception {
+        PreparedStatement stmt = getStatement(conn, getAccountSQL);
+        stmt.setInt(1, accountID);
+        ResultSet rs = stmt.executeQuery();
+        AccountDataBean accountData = getAccountDataFromResultSet(rs);
+        stmt.close();
+        return accountData;
+    }
+
+    private AccountDataBean getAccountDataForUpdate(int accountID, Connection conn) throws Exception {
+        PreparedStatement stmt = getStatement(conn, getAccountForUpdateSQL);
+        stmt.setInt(1, accountID);
+        ResultSet rs = stmt.executeQuery();
+        AccountDataBean accountData = getAccountDataFromResultSet(rs);
+        stmt.close();
+        return accountData;
+    }
+
+    private QuoteDataBean getQuoteData(String symbol) throws Exception {
+        QuoteDataBean quoteData = null;
+        Connection conn = null;
+        try {
+            conn = getConn();
+            quoteData = getQuoteData(conn, symbol);
+            commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:getQuoteData -- error getting data", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return quoteData;
+    }
+
+    private QuoteDataBean getQuoteData(Connection conn, String symbol) throws Exception {
+        QuoteDataBean quoteData = null;
+        PreparedStatement stmt = getStatement(conn, getQuoteSQL);
+        stmt.setString(1, symbol);
+        ResultSet rs = stmt.executeQuery();
+        if (!rs.next())
+            Log.error("TradeDirect:getQuoteData -- could not find quote for symbol=" + symbol);
+        else
+            quoteData = getQuoteDataFromResultSet(rs);
+        stmt.close();
+        return quoteData;
+    }
+
+    private HoldingDataBean getHoldingData(int holdingID) throws Exception {
+        HoldingDataBean holdingData = null;
+        Connection conn = null;
+        try {
+            conn = getConn();
+            holdingData = getHoldingData(conn, holdingID);
+            commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:getHoldingData -- error getting data", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return holdingData;
+    }
+
+    private HoldingDataBean getHoldingData(Connection conn, int holdingID) throws Exception {
+        HoldingDataBean holdingData = null;
+        PreparedStatement stmt = getStatement(conn, getHoldingSQL);
+        stmt.setInt(1, holdingID);
+        ResultSet rs = stmt.executeQuery();
+        if (!rs.next())
+            Log.error("TradeDirect:getHoldingData -- no results -- holdingID=" + holdingID);
+        else
+            holdingData = getHoldingDataFromResultSet(rs);
+
+        stmt.close();
+        return holdingData;
+    }
+
+    private OrderDataBean getOrderData(int orderID) throws Exception {
+        OrderDataBean orderData = null;
+        Connection conn = null;
+        try {
+            conn = getConn();
+            orderData = getOrderData(conn, orderID);
+            commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:getOrderData -- error getting data", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return orderData;
+    }
+
+    private OrderDataBean getOrderData(Connection conn, int orderID) throws Exception {
+        OrderDataBean orderData = null;
+        if (Log.doTrace())
+            Log.trace("TradeDirect:getOrderData(conn, " + orderID + ")");
+        PreparedStatement stmt = getStatement(conn, getOrderSQL);
+        stmt.setInt(1, orderID);
+        ResultSet rs = stmt.executeQuery();
+        if (!rs.next())
+            Log.error("TradeDirect:getOrderData -- no results for orderID:" + orderID);
+        else
+            orderData = getOrderDataFromResultSet(rs);
+        stmt.close();
+        return orderData;
+    }
 
-	/**
+    /**
      * @see TradeServices#getAccountProfileData(String)
      */
-	public AccountProfileDataBean getAccountProfileData(String userID)
-			throws Exception {
-		AccountProfileDataBean accountProfileData = null;
-		Connection conn = null;
-
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getAccountProfileData - inSession("
-						+ this.inSession + ")", userID);
-
-			conn = getConn();
-			accountProfileData = getAccountProfileData(conn, userID);
-			commit(conn);
-		} catch (Exception e) {
-			Log
-					.error(
-							"TradeDirect:getAccountProfileData -- error getting profile data",
-							e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return accountProfileData;
-	}
-
-	private AccountProfileDataBean getAccountProfileData(Connection conn,
-			String userID) throws Exception {
-		PreparedStatement stmt = getStatement(conn, getAccountProfileSQL);
-		stmt.setString(1, userID);
-
-		ResultSet rs = stmt.executeQuery();
-
-		AccountProfileDataBean accountProfileData = getAccountProfileDataFromResultSet(rs);
-		stmt.close();
-		return accountProfileData;
-	}
-
-	private AccountProfileDataBean getAccountProfileData(Integer accountID)
-			throws Exception {
-		AccountProfileDataBean accountProfileData = null;
-		Connection conn = null;
-
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:getAccountProfileData", accountID);
-
-			conn = getConn();
-			accountProfileData = getAccountProfileData(conn, accountID);
-			commit(conn);
-		} catch (Exception e) {
-			Log
-					.error(
-							"TradeDirect:getAccountProfileData -- error getting profile data",
-							e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return accountProfileData;
-	}
-
-	private AccountProfileDataBean getAccountProfileData(Connection conn,
-			Integer accountID) throws Exception {
-		PreparedStatement stmt = getStatement(conn,
-				getAccountProfileForAccountSQL);
-		stmt.setInt(1, accountID.intValue());
-
-		ResultSet rs = stmt.executeQuery();
-
-		AccountProfileDataBean accountProfileData = getAccountProfileDataFromResultSet(rs);
-		stmt.close();
-		return accountProfileData;
-	}
+    public AccountProfileDataBean getAccountProfileData(String userID) throws Exception {
+        AccountProfileDataBean accountProfileData = null;
+        Connection conn = null;
+
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getAccountProfileData - inSession(" + this.inSession + ")", userID);
+
+            conn = getConn();
+            accountProfileData = getAccountProfileData(conn, userID);
+            commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:getAccountProfileData -- error getting profile data", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return accountProfileData;
+    }
+
+    private AccountProfileDataBean getAccountProfileData(Connection conn, String userID) throws Exception {
+        PreparedStatement stmt = getStatement(conn, getAccountProfileSQL);
+        stmt.setString(1, userID);
+
+        ResultSet rs = stmt.executeQuery();
+
+        AccountProfileDataBean accountProfileData = getAccountProfileDataFromResultSet(rs);
+        stmt.close();
+        return accountProfileData;
+    }
+
+    private AccountProfileDataBean getAccountProfileData(Integer accountID) throws Exception {
+        AccountProfileDataBean accountProfileData = null;
+        Connection conn = null;
+
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:getAccountProfileData", accountID);
+
+            conn = getConn();
+            accountProfileData = getAccountProfileData(conn, accountID);
+            commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:getAccountProfileData -- error getting profile data", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return accountProfileData;
+    }
+
+    private AccountProfileDataBean getAccountProfileData(Connection conn, Integer accountID) throws Exception {
+        PreparedStatement stmt = getStatement(conn, getAccountProfileForAccountSQL);
+        stmt.setInt(1, accountID.intValue());
+
+        ResultSet rs = stmt.executeQuery();
+
+        AccountProfileDataBean accountProfileData = getAccountProfileDataFromResultSet(rs);
+        stmt.close();
+        return accountProfileData;
+    }
 
-	/**
+    /**
      * @see TradeServices#updateAccountProfile(AccountProfileDataBean)
      */
-	public AccountProfileDataBean updateAccountProfile(
-			AccountProfileDataBean profileData) throws Exception {
-		AccountProfileDataBean accountProfileData = null;
-		Connection conn = null;
-
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:updateAccountProfileData - inSession("
-						+ this.inSession + ")", profileData.getUserID());
-
-			conn = getConn();
-			updateAccountProfile(conn, profileData);
-
-			accountProfileData = getAccountProfileData(conn, profileData
-					.getUserID());
-			commit(conn);
-		} catch (Exception e) {
-			Log
-					.error(
-							"TradeDirect:getAccountProfileData -- error getting profile data",
-							e);
-			rollBack(conn, e);
-		} finally {
-			releaseConn(conn);
-		}
-		return accountProfileData;
-	}
-
-	private void creditAccountBalance(Connection conn,
-			AccountDataBean accountData, BigDecimal credit) throws Exception {
-		PreparedStatement stmt = getStatement(conn, creditAccountBalanceSQL);
-
-		stmt.setBigDecimal(1, credit);
-		stmt.setInt(2, accountData.getAccountID().intValue());
-
-		int count = stmt.executeUpdate();
-		stmt.close();
-
-	}
-
-	// Set Timestamp to zero to denote sell is inflight
-	// UPDATE -- could add a "status" attribute to holding
-	private void updateHoldingStatus(Connection conn, Integer holdingID,
-			String symbol) throws Exception {
-		Timestamp ts = new Timestamp(0);
-		PreparedStatement stmt = getStatement(conn,
-				"update holdingejb set purchasedate= ? where holdingid = ?");
-
-		stmt.setTimestamp(1, ts);
-		stmt.setInt(2, holdingID.intValue());
-		int count = stmt.executeUpdate();
-		stmt.close();
-	}
-
-	private void updateOrderStatus(Connection conn, Integer orderID,
-			String status) throws Exception {
-		PreparedStatement stmt = getStatement(conn, updateOrderStatusSQL);
-
-		stmt.setString(1, status);
-		stmt.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
-		stmt.setInt(3, orderID.intValue());
-		int count = stmt.executeUpdate();
-		stmt.close();
-	}
-
-	private void updateOrderHolding(Connection conn, int orderID, int holdingID)
-			throws Exception {
-		PreparedStatement stmt = getStatement(conn, updateOrderHoldingSQL);
-
-		stmt.setInt(1, holdingID);
-		stmt.setInt(2, orderID);
-		int count = stmt.executeUpdate();
-		stmt.close();
-	}
-
-	private void updateAccountProfile(Connection conn,
-			AccountProfileDataBean profileData) throws Exception {
-		PreparedStatement stmt = getStatement(conn, updateAccountProfileSQL);
-
-		stmt.setString(1, profileData.getPassword());
-		stmt.setString(2, profileData.getFullName());
-		stmt.setString(3, profileData.getAddress());
-		stmt.setString(4, profileData.getEmail());
-		stmt.setString(5, profileData.getCreditCard());
-		stmt.setString(6, profileData.getUserID());
-
-		int count = stmt.executeUpdate();
-		stmt.close();
-	}
-
-	private void updateQuoteVolume(Connection conn, QuoteDataBean quoteData,
-			double quantity) throws Exception {
-		PreparedStatement stmt = getStatement(conn, updateQuoteVolumeSQL);
-
-		stmt.setDouble(1, quantity);
-		stmt.setString(2, quoteData.getSymbol());
-
-		int count = stmt.executeUpdate();
-		stmt.close();
-	}
-
-	public QuoteDataBean updateQuotePriceVolume(String symbol,
-			BigDecimal changeFactor, double sharesTraded) throws Exception {
-		return updateQuotePriceVolumeInt(symbol, changeFactor, sharesTraded,
-				TradeConfig.getPublishQuotePriceChange());
-	}
+    public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData) throws Exception {
+        AccountProfileDataBean accountProfileData = null;
+        Connection conn = null;
+
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:updateAccountProfileData - inSession(" + this.inSession + ")", profileData
+                    .getUserID());
+
+            conn = getConn();
+            updateAccountProfile(conn, profileData);
+
+            accountProfileData = getAccountProfileData(conn, profileData.getUserID());
+            commit(conn);
+        } catch (Exception e) {
+            Log.error("TradeDirect:getAccountProfileData -- error getting profile data", e);
+            rollBack(conn, e);
+        } finally {
+            releaseConn(conn);
+        }
+        return accountProfileData;
+    }
+
+    private void creditAccountBalance(Connection conn, AccountDataBean accountData, BigDecimal credit) throws Exception {
+        PreparedStatement stmt = getStatement(conn, creditAccountBalanceSQL);
+
+        stmt.setBigDecimal(1, credit);
+        stmt.setInt(2, accountData.getAccountID().intValue());
+
+        int count = stmt.executeUpdate();
+        stmt.close();
+
+    }
+
+    // Set Timestamp to zero to denote sell is inflight
+    // UPDATE -- could add a "status" attribute to holding
+    private void updateHoldingStatus(Connection conn, Integer holdingID, String symbol) throws Exception {
+        Timestamp ts = new Timestamp(0);
+        PreparedStatement stmt = getStatement(conn, "update holdingejb set purchasedate= ? where holdingid = ?");
+
+        stmt.setTimestamp(1, ts);
+        stmt.setInt(2, holdingID.intValue());
+        int count = stmt.executeUpdate();
+        stmt.close();
+    }
+
+    private void updateOrderStatus(Connection conn, Integer orderID, String status) throws Exception {
+        PreparedStatement stmt = getStatement(conn, updateOrderStatusSQL);
+
+        stmt.setString(1, status);
+        stmt.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
+        stmt.setInt(3, orderID.intValue());
+        int count = stmt.executeUpdate();
+        stmt.close();
+    }
+
+    private void updateOrderHolding(Connection conn, int orderID, int holdingID) throws Exception {
+        PreparedStatement stmt = getStatement(conn, updateOrderHoldingSQL);
+
+        stmt.setInt(1, holdingID);
+        stmt.setInt(2, orderID);
+        int count = stmt.executeUpdate();
+        stmt.close();
+    }
+
+    private void updateAccountProfile(Connection conn, AccountProfileDataBean profileData) throws Exception {
+        PreparedStatement stmt = getStatement(conn, updateAccountProfileSQL);
+
+        stmt.setString(1, profileData.getPassword());
+        stmt.setString(2, profileData.getFullName());
+        stmt.setString(3, profileData.getAddress());
+        stmt.setString(4, profileData.getEmail());
+        stmt.setString(5, profileData.getCreditCard());
+        stmt.setString(6, profileData.getUserID());
+
+        int count = stmt.executeUpdate();
+        stmt.close();
+    }
+
+    private void updateQuoteVolume(Connection conn, QuoteDataBean quoteData, double quantity) throws Exception {
+        PreparedStatement stmt = getStatement(conn, updateQuoteVolumeSQL);
+
+        stmt.setDouble(1, quantity);
+        stmt.setString(2, quoteData.getSymbol());
+
+        int count = stmt.executeUpdate();
+        stmt.close();
+    }
+
+    public QuoteDataBean updateQuotePriceVolume(String symbol, BigDecimal changeFactor, double sharesTraded)
+        throws Exception {
+        return updateQuotePriceVolumeInt(symbol, changeFactor, sharesTraded, TradeConfig.getPublishQuotePriceChange());
+    }
 
-	/**
+    /**
      * Update a quote's price and volume
      * 
      * @param symbol
@@ -1341,938 +1223,875 @@
      * @param sharedTraded
      *            the ammount to add to the current volume
      * @param publishQuotePriceChange
-     *            used by the PingJDBCWrite Primitive to ensure no JMS is used,
-     *            should be true for all normal calls to this API
+     *            used by the PingJDBCWrite Primitive to ensure no JMS is used, should be true for all normal calls to
+     *            this API
      */
-	public QuoteDataBean updateQuotePriceVolumeInt(String symbol,
-			BigDecimal changeFactor, double sharesTraded,
-			boolean publishQuotePriceChange) throws Exception {
-
-		if (TradeConfig.getUpdateQuotePrices() == false)
-			return new QuoteDataBean();
-
-		QuoteDataBean quoteData = null;
-		Connection conn = null;
-		UserTransaction txn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:updateQuotePriceVolume - inSession("
-						+ this.inSession + ")", symbol, changeFactor,
-						new Double(sharesTraded));
-
-			conn = getConn();
-
-			quoteData = getQuoteForUpdate(conn, symbol);
-			BigDecimal oldPrice = quoteData.getPrice();
-			double newVolume = quoteData.getVolume() + sharesTraded;
-
-			if (oldPrice.equals(TradeConfig.PENNY_STOCK_PRICE)) {
-				changeFactor = TradeConfig.PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER;
-			} else if (oldPrice.compareTo(TradeConfig.MAXIMUM_STOCK_PRICE) > 0) {
-				changeFactor = TradeConfig.MAXIMUM_STOCK_SPLIT_MULTIPLIER;
-			}
-
-			BigDecimal newPrice = changeFactor.multiply(oldPrice).setScale(2,
-					BigDecimal.ROUND_HALF_UP);
-
-			updateQuotePriceVolume(conn, quoteData.getSymbol(), newPrice,
-					newVolume);
-			quoteData = getQuote(conn, symbol);
-
-			commit(conn);
-
-			if (publishQuotePriceChange) {
-				publishQuotePriceChange(quoteData, oldPrice, changeFactor,
-						sharesTraded);
-			}
-
-		} catch (Exception e) {
-			Log
-					.error("TradeDirect:updateQuotePriceVolume -- error updating quote price/volume for symbol:"
-							+ symbol);
-			rollBack(conn, e);
-			throw e;
-		} finally {
-			releaseConn(conn);
-		}
-		return quoteData;
-	}
-
-	private void updateQuotePriceVolume(Connection conn, String symbol,
-			BigDecimal newPrice, double newVolume) throws Exception {
-
-		PreparedStatement stmt = getStatement(conn, updateQuotePriceVolumeSQL);
-
-		stmt.setBigDecimal(1, newPrice);
-		stmt.setBigDecimal(2, newPrice);
-		stmt.setDouble(3, newVolume);
-		stmt.setString(4, symbol);
-
-		int count = stmt.executeUpdate();
-		stmt.close();
-	}
-
-	private void publishQuotePriceChange(QuoteDataBean quoteData,
-			BigDecimal oldPrice, BigDecimal changeFactor, double sharesTraded)
-			throws Exception {
-		if (Log.doTrace())
-			Log
-					.trace("TradeDirect:publishQuotePrice PUBLISHING to MDB quoteData = "
-							+ quoteData);
-
-		javax.jms.Connection conn = null;
-		Session sess = null;
-
-		try {
-			conn = tConnFactory.createConnection();
-			sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-			MessageProducer producer = sess.createProducer(streamerTopic);
-			TextMessage message = sess.createTextMessage();
-
-			String command = "updateQuote";
-			message.setStringProperty("command", command);
-			message.setStringProperty("symbol", quoteData.getSymbol());
-			message.setStringProperty("company", quoteData.getCompanyName());
-			message.setStringProperty("price", quoteData.getPrice().toString());
-			message.setStringProperty("oldPrice", oldPrice.toString());
-			message.setStringProperty("open", quoteData.getOpen().toString());
-			message.setStringProperty("low", quoteData.getLow().toString());
-			message.setStringProperty("high", quoteData.getHigh().toString());
-			message.setDoubleProperty("volume", quoteData.getVolume());
-
-			message.setStringProperty("changeFactor", changeFactor.toString());
-			message.setDoubleProperty("sharesTraded", sharesTraded);
-			message.setLongProperty("publishTime", System.currentTimeMillis());
-			message.setText("Update Stock price for " + quoteData.getSymbol()
-					+ " old price = " + oldPrice + " new price = "
-					+ quoteData.getPrice());
-
-			producer.send(message);
-		} catch (Exception e) {
-			throw e; // pass exception back
-
-		}
-
-		finally {
-			if (sess != null)
-				sess.close();
-			if (conn != null)
-				conn.close();
-		}
-	}
+    public QuoteDataBean updateQuotePriceVolumeInt(String symbol, BigDecimal changeFactor, double sharesTraded,
+        boolean publishQuotePriceChange) throws Exception {
+
+        if (TradeConfig.getUpdateQuotePrices() == false)
+            return new QuoteDataBean();
 
-	/**
+        QuoteDataBean quoteData = null;
+        Connection conn = null;
+        UserTransaction txn = null;
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeDirect:updateQuotePriceVolume - inSession(" + this.inSession + ")", symbol,
+                    changeFactor, new Double(sharesTraded));
+
+            conn = getConn();
+
+            quoteData = getQuoteForUpdate(conn, symbol);
+            BigDecimal oldPrice = quoteData.getPrice();
+            double newVolume = quoteData.getVolume() + sharesTraded;
+
+            if (oldPrice.equals(TradeConfig.PENNY_STOCK_PRICE)) {
+                changeFactor = TradeConfig.PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER;
+            } else if (oldPrice.compareTo(TradeConfig.MAXIMUM_STOCK_PRICE) > 0) {
+                changeFactor = TradeConfig.MAXIMUM_STOCK_SPLIT_MULTIPLIER;
+            }
+
+            BigDecimal newPrice = changeFactor.multiply(oldPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
+
+            updateQuotePriceVolume(conn, quoteData.getSymbol(), newPrice, newVolume);
+            quoteData = getQuote(conn, symbol);
+
+            commit(conn);
+
+            if (publishQuotePriceChange) {
+                publishQuotePriceChange(quoteData, oldPrice, changeFactor, sharesTraded);
+            }
+
+        } catch (Exception e) {
+            Log.error("TradeDirect:updateQuotePriceVolume -- error updating quote price/volume for symbol:" + symbol);
+            rollBack(conn, e);
+            throw e;
+        } finally {
+            releaseConn(conn);
+        }
+        return quoteData;
+    }
+
+    private void updateQuotePriceVolume(Connection conn, String symbol, BigDecimal newPrice, double newVolume)
+        throws Exception {
+
+        PreparedStatement stmt = getStatement(conn, updateQuotePriceVolumeSQL);
+
+        stmt.setBigDecimal(1, newPrice);
+        stmt.setBigDecimal(2, newPrice);
+        stmt.setDouble(3, newVolume);
+        stmt.setString(4, symbol);
+
+        int count = stmt.executeUpdate();
+        stmt.close();
+    }
+
+    private void publishQuotePriceChange(QuoteDataBean quoteData, BigDecimal oldPrice, BigDecimal changeFactor,
+        double sharesTraded) throws Exception {
+        if (Log.doTrace())
+            Log.trace("TradeDirect:publishQuotePrice PUBLISHING to MDB quoteData = " + quoteData);
+
+        javax.jms.Connection conn = null;
+        Session sess = null;
+
+        try {
+            conn = tConnFactory.createConnection();
+            sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageProducer producer = sess.createProducer(streamerTopic);
+            TextMessage message = sess.createTextMessage();
+
+            String command = "updateQuote";
+            message.setStringProperty("command", command);
+            message.setStringProperty("symbol", quoteData.getSymbol());
+            message.setStringProperty("company", quoteData.getCompanyName());
+            message.setStringProperty("price", quoteData.getPrice().toString());
+            message.setStringProperty("oldPrice", oldPrice.toString());
+            message.setStringProperty("open", quoteData.getOpen().toString());
+            message.setStringProperty("low", quoteData.getLow().toString());
+            message.setStringProperty("high", quoteData.getHigh().toString());
+            message.setDoubleProperty("volume", quoteData.getVolume());
+
+            message.setStringProperty("changeFactor", changeFactor.toString());
+            message.setDoubleProperty("sharesTraded", sharesTraded);
+            message.setLongProperty("publishTime", System.currentTimeMillis());
+            message.setText("Update Stock price for " + quoteData.getSymbol() + " old price = " + oldPrice
+                + " new price = " + quoteData.getPrice());
+
+            producer.send(message);
+        } catch (Exception e) {
+            throw e; // pass exception back
+
+        }
+
+        finally {
+            if (sess != null)
+                sess.close();
+            if (conn != null)
+                conn.close();
+        }
+    }
+
+    /**
      * @see TradeServices#login(String, String)
      */
 
-	public AccountDataBean login(String userID, String password)
-			throws Exception {
+    public AccountDataBean login(String userID, String password) throws Exception {
 
-		AccountDataBean accountData = null;
-		Connection conn = null;
-		try {
-			if (Log.doTrace())
-				Log.trace("TradeDirect:login - inSession(" + this.inSession
-						+ ")", userID, password);
-
-			conn = getConn();
-			PreparedStatement stmt = getStatement(conn, getAccountProfileSQL);
-			stmt.setString(1, userID);
-
-			ResultSet rs = stmt.executeQuery();
-			if (!rs.next()) {
-				Log.error("TradeDirect:login -- failure to find account for"
-						+ userID);
-				throw new javax.ejb.FinderException("Cannot find account for"
-						+ userID);
-			}
-
-			String pw = rs.getString("passwd");
-			stmt.close();
-			if ((pw == null) || (pw.equals(password) == false)) {
-				String error = "TradeDirect:Login failure for user: " + userID
-						+ "\n\tIncorrect password-->" + userID + ":" + password;
-				Log.error(error);
-				throw new Exception(error);
-			}
-
-			stmt = getStatement(conn, loginSQL);
-			stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
-			stmt.setString(2, userID);
-
-			int rows = stmt.executeUpdate();
-			// ?assert rows==1?
-			stmt.close();
-
-			stmt = getStatement(conn, getAccountForUserSQL);
-			stmt.setString(1, userID);
-			rs = stmt.executeQuery();
-
-			accountData = getAccountDataFromResultSet(rs);
-
-			stmt.close();
-
-			commit(conn);
-		} catch (Exception e) {

[... 1436 lines stripped ...]


Mime
View raw message