incubator-stonehenge-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bende...@apache.org
Subject svn commit: r811675 [3/9] - in /incubator/stonehenge/trunk: ./ stocktrader/metro/ stocktrader/metro/business_service/ stocktrader/metro/business_service/etc/ stocktrader/metro/business_service/src/ stocktrader/metro/business_service/src/org/ stocktrade...
Date Sat, 05 Sep 2009 16:41:19 GMT
Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLDAOFactory.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLDAOFactory.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLDAOFactory.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLDAOFactory.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,122 @@
+/*
+ * 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.stonehenge.stocktrader.mysql;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stonehenge.stocktrader.dal.CustomerDAO;
+import org.apache.stonehenge.stocktrader.dal.DAOException;
+import org.apache.stonehenge.stocktrader.dal.DAOFactory;
+import org.apache.stonehenge.stocktrader.dal.MarketSummaryDAO;
+import org.apache.stonehenge.stocktrader.dal.OrderDAO;
+
+public class MySQLDAOFactory extends DAOFactory {
+
+	private static Log logger = LogFactory.getLog(MySQLDAOFactory.class);
+	private static MySQLDAOFactory self = null;
+
+	private Connection sqlConnection = null;
+
+	private String connection = null;
+
+    static {
+		try {
+			Class.forName("com.mysql.jdbc.Driver");
+		} catch (ClassNotFoundException e) {
+			logger.warn("Unable to load DBDrive class", e);
+		}
+	}
+
+	public static DAOFactory getInstance() {
+		if (self == null) {
+			self = new MySQLDAOFactory();
+		}
+		return self;
+	}
+
+	private MySQLDAOFactory() {
+	}
+
+	public OrderDAO getOrderDAO() throws DAOException {
+		logger.debug("MySQLDAOFactory.getOrderDAO");
+		try {
+			OrderDAO orderDAO = new MySQLOrderDAO(getConnection());
+			return orderDAO;
+		} catch (SQLException e) {
+			logger.debug("", e);
+			throw new DAOException("Exception was thrown when instantiating MySQLOrderDAO object",e);
+		}
+	}
+
+	public CustomerDAO getCustomerDAO() throws DAOException {
+		logger.debug("MySQLDAOFactory.getCustomerDAO");
+		try {
+			CustomerDAO customerDAO = new MySQLCustomerDAO(getConnection());
+			return customerDAO;
+		} catch (SQLException e) {
+			logger.debug("", e);
+			throw new DAOException("Exception was thrown when instantiating a MySQLCustomerDAO",e);
+		}
+	}
+
+	public MarketSummaryDAO getMarketSummaryDAO() throws DAOException {
+		logger.debug("MySQLDAOFactory.getMarketSummaryDAO");
+		try {
+			MarketSummaryDAO marketSummaryDAO = new MySQLMarketSummaryDAO(getConnection());
+			return marketSummaryDAO;
+		} catch (SQLException e) {
+			logger.debug("", e);
+			throw new DAOException("Exception was thrown when instantiating a MarketSummaryDAO",e);
+		}
+	}
+
+	private String getConnectionString() {
+		if (connection == null) {
+            loadProperties();
+            if (prop.size() <= 0) {
+//			if (prop == null) {
+				connection = "jdbc:mysql://localhost:3306/stocktraderdb?user=trade&password=yyy";
+			} else {
+				StringBuffer buf = new StringBuffer();
+				buf.append("jdbc:mysql://");
+				buf.append(prop.getProperty(PROP_DB_HOST));
+				buf.append(":" + prop.getProperty(PROP_DB_PORT));
+				buf.append("/" + prop.getProperty(PROP_DB_NAME));
+				buf.append("?user=" + prop.getProperty(PROP_DB_USER));
+				buf.append("&password=" + prop.getProperty(PROP_DB_PASSWORD));
+				connection = buf.toString();
+			}
+		}
+
+		if (logger.isDebugEnabled()) {
+			logger.debug("MySQLDAOFactory.getConnectionString()\nConnection :"+ connection);
+		}
+		return connection;
+	}
+
+	private Connection getConnection() throws SQLException {
+		if (sqlConnection == null || sqlConnection.isClosed()) {
+			sqlConnection = DriverManager.getConnection(getConnectionString());
+		}
+		return sqlConnection;
+	}
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLMarketSummaryDAO.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLMarketSummaryDAO.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLMarketSummaryDAO.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLMarketSummaryDAO.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,261 @@
+/*
+ * 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.stonehenge.stocktrader.mysql;
+
+import org.apache.stonehenge.stocktrader.mssql.AbstractMSSQLDAO;
+import org.apache.stonehenge.stocktrader.dal.MarketSummaryDAO;
+import org.apache.stonehenge.stocktrader.dal.DAOException;
+import org.apache.stonehenge.stocktrader.CustomQuoteBean;
+import org.apache.stonehenge.stocktrader.CustomMarketSummaryBean;
+import org.apache.stonehenge.stocktrader.util.StockTraderUtility;
+import org.apache.stonehenge.stocktrader.util.StockTraderSQLUtil;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.ArrayList;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class MySQLMarketSummaryDAO extends AbstractMSSQLDAO implements MarketSummaryDAO {
+	private static final Log logger = LogFactory.getLog(MySQLMarketSummaryDAO.class);
+
+	private static final String SQL_SELECT_QUOTE = "SELECT symbol, companyname, volume, price, open1, low, high, change1 FROM quote WHERE symbol = ?";
+	private static final String SQL_SELECT_QUOTE_NOLOCK = "SELECT symbol, companyname, volume, price, open1, low, high, change1 FROM quote WHERE symbol = ?";
+	private static final String SQL_UPDATE_STOCKPRICEVOLUME = "UPDATE quote SET price = ?, low = ?, high = ?, change1 = ? - open1, volume = volume + ? WHERE symbol = ?";
+
+	private static final String SQL_SELECT_MARKETSUMMARY_GAINERS = "SELECT symbol, companyname, volume, price, open1, low, high, change1 FROM quote WHERE symbol LIKE 's:%' ORDER BY change1 DESC";
+	private static final String SQL_SELECT_MARKETSUMMARY_LOSERS = "SELECT symbol, companyname, volume, price, open1, low, high, change1 FROM quote WHERE symbol LIKE 's:%' ORDER BY change1";
+	private static final String SQL_SELECT_MARKETSUMMARY_TSIA = "SELECT SUM(price) / COUNT(*) as tsia FROM quote WHERE symbol LIKE 's:%'";
+	private static final String SQL_SELECT_MARKETSUMMARY_OPENTSIA = "SELECT SUM(open1) / COUNT(*) as opentsia FROM quote WHERE symbol LIKE 's:%'";
+	private static final String SQL_SELECT_MARKETSUMMARY_VOLUME = "SELECT SUM(volume) FROM quote WHERE symbol LIKE 's:%'";
+
+	public MySQLMarketSummaryDAO(Connection sqlConnection) throws DAOException {
+		super(sqlConnection);
+	}
+
+	public CustomQuoteBean getQuote(String symbol) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("MarketSummaryDAO.getQouteForUpdate(String)\nSymbol :"+ symbol);
+		}
+		PreparedStatement selectQuote = null;
+		try {
+			selectQuote = sqlConnection.prepareStatement(SQL_SELECT_QUOTE_NOLOCK);
+			selectQuote.setString(1, symbol);
+			ResultSet rs = selectQuote.executeQuery();
+
+			try {
+				CustomQuoteBean quote = null;
+				if (rs.next()) {
+					quote = new CustomQuoteBean(
+                            rs.getString(1),
+                            rs.getString(2),
+                            rs.getDouble(3),
+							rs.getBigDecimal(4),
+                            rs.getBigDecimal(5),
+                            rs.getBigDecimal(6),
+                            rs.getBigDecimal(7),
+                            rs.getDouble(8));
+				}
+				return quote;
+			} finally {
+				try {
+					rs.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		} catch (SQLException e) {
+			throw new DAOException("", e);
+		} finally {
+			try {
+				if (selectQuote != null) {
+					selectQuote.close();
+				}
+			} catch (SQLException e) {
+				logger.debug("", e);
+			}
+		}
+	}
+
+	public CustomQuoteBean getQuoteForUpdate(String symbol) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("MarketSummaryDAO.getQouteForUpdate(String)\nSymbol :"+ symbol);
+		}
+		PreparedStatement qouteForUpdateStat = null;
+		try {
+			qouteForUpdateStat = sqlConnection.prepareStatement(SQL_SELECT_QUOTE);
+			CustomQuoteBean quote = null;
+
+			qouteForUpdateStat.setString(1, symbol);
+			ResultSet rs = qouteForUpdateStat.executeQuery();
+
+			if (rs.next()) {
+				quote = new CustomQuoteBean(
+                        rs.getString(1),
+                        rs.getString(2),
+						rs.getDouble(3),
+                        rs.getBigDecimal(4),
+                        rs.getBigDecimal(5),
+                        rs.getBigDecimal(6),
+                        rs.getBigDecimal(7),
+                        rs.getDouble(8));
+
+				try {
+					rs.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+				return quote;
+			} else {
+				throw new DAOException("No quote entry found");
+			}
+		} catch (SQLException e) {
+			throw new DAOException("", e);
+		} finally {
+			try {
+				if (qouteForUpdateStat != null) {
+					qouteForUpdateStat.close();
+				}
+			} catch (SQLException e) {
+				logger.debug("", e);
+			}
+		}
+	}
+
+	public void updateStockPriceVolume(double quantity, CustomQuoteBean quote) throws DAOException {
+		BigDecimal priceChangeFactor = StockTraderUtility.getRandomPriceChangeFactor(quote.getPrice());
+		BigDecimal newPrice = quote.getPrice().multiply(priceChangeFactor);
+
+		if (newPrice.compareTo(quote.getLow()) == -1) {
+			quote.setLow(newPrice);
+		}
+		if (newPrice.compareTo(quote.getHigh()) == 1) {
+			quote.setHigh(newPrice);
+		}
+
+		PreparedStatement updateStockPriceVolumeStat = null;
+		try {
+			updateStockPriceVolumeStat = sqlConnection.prepareStatement(SQL_UPDATE_STOCKPRICEVOLUME);
+			updateStockPriceVolumeStat.setBigDecimal(1, newPrice);
+			updateStockPriceVolumeStat.setBigDecimal(2, quote.getLow());
+			updateStockPriceVolumeStat.setBigDecimal(3, quote.getHigh());
+			updateStockPriceVolumeStat.setBigDecimal(4, newPrice);
+			updateStockPriceVolumeStat.setFloat(5, (float) quantity);
+			updateStockPriceVolumeStat.setString(6, quote.getSymbol());
+			updateStockPriceVolumeStat.executeUpdate();
+
+		} catch (SQLException e) {
+			throw new DAOException("", e);
+		} finally {
+			try {
+				if (updateStockPriceVolumeStat != null) {
+					updateStockPriceVolumeStat.close();
+				}
+			} catch (SQLException e) {
+				logger.debug("", e);
+			}
+		}
+	}
+
+	public CustomMarketSummaryBean getCustomMarketSummary() throws DAOException {
+		BigDecimal tSIA = (BigDecimal) StockTraderSQLUtil.executeScalarNoParm(SQL_SELECT_MARKETSUMMARY_TSIA, sqlConnection);
+		BigDecimal openTSIA = (BigDecimal) StockTraderSQLUtil.executeScalarNoParm(SQL_SELECT_MARKETSUMMARY_OPENTSIA, sqlConnection);
+		double totalVolume = ((Double) StockTraderSQLUtil.executeScalarNoParm(SQL_SELECT_MARKETSUMMARY_VOLUME, sqlConnection)).doubleValue();
+
+		List<CustomQuoteBean> topGainers = new ArrayList<CustomQuoteBean>();
+		PreparedStatement gainers = null;
+		try {
+			gainers = sqlConnection.prepareStatement(SQL_SELECT_MARKETSUMMARY_GAINERS);
+			ResultSet rs = gainers.executeQuery();
+
+			try {
+				for (int i = 0; rs.next() && i < 5; i++) {
+					CustomQuoteBean quote = new CustomQuoteBean(
+							rs.getString(1),
+                            rs.getString(2),
+                            rs.getDouble(3),
+							rs.getBigDecimal(4),
+                            rs.getBigDecimal(5),
+                            rs.getBigDecimal(6),
+                            rs.getBigDecimal(7),
+                            rs.getDouble(8));
+					topGainers.add(quote);
+				}
+			} finally {
+				try {
+					rs.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		} catch (SQLException e) {
+			throw new DAOException("", e);
+		} finally {
+			if (gainers != null) {
+				try {
+					gainers.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		}
+		List<CustomQuoteBean> topLosers = new ArrayList<CustomQuoteBean>();
+		PreparedStatement losers = null;
+		try {
+			losers = sqlConnection.prepareStatement(SQL_SELECT_MARKETSUMMARY_LOSERS);
+			ResultSet rs = losers.executeQuery();
+
+			try {
+				for (int i = 0; rs.next() && i < 5; i++) {
+					CustomQuoteBean quote = new CustomQuoteBean(
+							rs.getString(1),
+                            rs.getString(2),
+                            rs.getDouble(3),
+							rs.getBigDecimal(4),
+                            rs.getBigDecimal(5),
+                            rs.getBigDecimal(6),
+                            rs.getBigDecimal(7),
+                            rs.getDouble(8));
+					topLosers.add(quote);
+				}
+			} finally {
+				try {
+					rs.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		} catch (SQLException e) {
+			throw new DAOException("", e);
+		} finally {
+			if (losers != null) {
+				try {
+					losers.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		}
+		CustomMarketSummaryBean marketSummary = new CustomMarketSummaryBean(
+				tSIA, openTSIA, totalVolume, topGainers, topLosers);
+		return marketSummary;
+	}
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLOrderDAO.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLOrderDAO.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLOrderDAO.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/mysql/MySQLOrderDAO.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,420 @@
+/*
+ * 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.stonehenge.stocktrader.mysql;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stonehenge.stocktrader.CustomHoldingBean;
+import org.apache.stonehenge.stocktrader.CustomOrderBean;
+import org.apache.stonehenge.stocktrader.CustomQuoteBean;
+import org.apache.stonehenge.stocktrader.dal.*;
+import org.apache.stonehenge.stocktrader.util.StockTraderUtility;
+
+import java.math.BigDecimal;
+import java.sql.*;
+import java.util.Calendar;
+
+public class MySQLOrderDAO extends AbstractMySQLDAO implements OrderDAO {
+	private static Log logger = LogFactory.getLog(MySQLOrderDAO.class);
+
+	private static final String SQL_GET_ACCOUNTID_ORDER = "SELECT account_accountid FROM orders WHERE orderid = ?";
+	private static final String SQL_INSERT_HOLDING = "INSERT INTO holding (purchaseprice, quantity, purchasedate, account_accountid, quote_symbol, holdingid) VALUES (?, ?, ?, ?, ?, null)";
+	private static final String SQL_UPDATE_HOLDING = "UPDATE holding SET quantity =quantity - ? WHERE holdingid = ?";
+	private static final String SQL_DELETE_HOLDING = "DELETE FROM holding WHERE holdingid = ?";
+	private static final String SQL_SELECT_HOLDING = "SELECT holdingid, quantity, purchaseprice, purchasedate, quote_symbol, account_accountid FROM holding WHERE holdingid = ?";
+	private static final String SQL_UPDATE_ORDER = "UPDATE orders SET quantity = ? WHERE orderid = ?";
+	private static final String SQL_CLOSE_ORDER = "UPDATE orders SET orderstatus = ?, completiondate = now(), holding_holdingid = ?, price = ? WHERE orderid = ?";
+	private static final String SQL_GET_ACCOUNTID = "SELECT accountid FROM account  WHERE profile_userid = ?";
+    private static final String SQL_GET_LAST_INSERT_ID = "SELECT LAST_INSERT_ID()";
+
+	// CHECKME
+	private static final String SQL_INSERT_ORDER = "INSERT INTO orders (opendate, orderfee, price, quote_symbol, quantity, ordertype, orderstatus, account_accountid, holding_holdingid, orderid) VALUES (now(), ?, ?, ?, ?, ?, 'open', ?, ?, null)";
+	private static final String SQL_SELECT_ORDER_ID = "SELECT LAST_INSERT_ID() FROM orders WHERE orderfee = ? AND price = ? AND quote_symbol = ? AND quantity = ? AND ordertype = ? AND orderstatus = ? AND account_accountid = ? AND holding_holdingid = ?";
+
+	public MySQLOrderDAO(Connection sqlConnection) throws DAOException {
+		super(sqlConnection);
+	}
+
+	public CustomQuoteBean getQuoteForUpdate(String symbol) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("OrderDAO.getQuoteForUpdate()\nSymbol :" + symbol);
+		}
+
+		DAOFactory fac = MySQLDAOFactory.getInstance();
+		MarketSummaryDAO marketSummaryDAO = fac.getMarketSummaryDAO();
+		return marketSummaryDAO.getQuoteForUpdate(symbol);
+	}
+
+	public int createHolding(CustomOrderBean order) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("OrderDAO.createHolding(OrderDataModel)\nOrderID :"
+					+ order.getOrderID() + "\nOrderType :"
+					+ order.getOrderType() + "\nSymbol :" + order.getSymbol()
+					+ "\nQuantity :" + order.getQuantity() + "\nOrder Status :"
+					+ order.getOrderStatus() + "\nOrder Open Date :"
+					+ order.getOpenDate() + "\nCompletionDate :"
+					+ order.getCompletionDate());
+		}
+
+		PreparedStatement getAccountIdStat = null;
+		int accountId = -1;
+
+		try {
+			getAccountIdStat = sqlConnection.prepareStatement(SQL_GET_ACCOUNTID_ORDER);
+			getAccountIdStat.setInt(1, order.getOrderID());
+
+			ResultSet rs = getAccountIdStat.executeQuery();
+			if (rs.next()) {
+				accountId = Integer.parseInt(rs.getString(1));
+				order.setAccountId(accountId);
+			}
+
+			try {
+				rs.close();
+			} catch (Exception e) {
+				logger.debug("", e);
+			}
+		} catch (SQLException e) {
+			throw new DAOException("Exception is thrown when selecting the accountID from order entries where order ID :" + order.getOrderID(), e);
+
+		} finally {
+			if (getAccountIdStat != null) {
+				try {
+					getAccountIdStat.close();
+				} catch (Exception e) {
+					logger.debug("", e);
+				}
+			}
+		}
+
+		if (accountId != -1) {
+			int holdingId = -1;
+			PreparedStatement insertHoldingStat = null;
+
+			try {
+				insertHoldingStat = sqlConnection.prepareStatement(SQL_INSERT_HOLDING);
+				insertHoldingStat.setBigDecimal(1, order.getPrice());
+				insertHoldingStat.setDouble(2, order.getQuantity());
+				Calendar openDate = (order.getOpenDate() != null) ? order.getOpenDate() : Calendar.getInstance();
+				insertHoldingStat.setDate(3, StockTraderUtility.convertToSqlDate(openDate));
+				insertHoldingStat.setInt(4, order.getAccountId());
+				insertHoldingStat.setString(5, order.getSymbol());
+                insertHoldingStat.executeUpdate();
+
+				ResultSet rs = sqlConnection.prepareCall(SQL_GET_LAST_INSERT_ID).executeQuery();
+				if (rs.next()) {
+					holdingId = rs.getInt(1);
+				}
+
+				try {
+					rs.close();
+				} catch (Exception e) {
+					logger.debug("", e);
+				}
+				return holdingId;
+
+			} catch (SQLException e) {
+				throw new DAOException("An exception is thrown during an insertion of a holding entry",e);
+
+			} finally {
+				if (insertHoldingStat != null) {
+					try {
+						insertHoldingStat.close();
+					} catch (Exception e) {
+						logger.debug("", e);
+					}
+				}
+			}
+		}
+		return -1;
+	}
+
+	public void updateHolding(int holdingId, double quantity) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("OrderDAO.updateHolding()\nHolding ID :" + holdingId + "\nQuantity :" + quantity);
+		}
+
+		PreparedStatement updateHoldingStat = null;
+		try {
+			updateHoldingStat = sqlConnection.prepareStatement(SQL_UPDATE_HOLDING);
+			updateHoldingStat.setDouble(1, quantity);
+			updateHoldingStat.setInt(2, holdingId);
+			updateHoldingStat.executeUpdate();
+
+		} catch (SQLException e) {
+			throw new DAOException("An exception is thrown during an updation of holding entry", e);
+		} finally {
+			if (updateHoldingStat != null) {
+				try {
+					updateHoldingStat.close();
+				} catch (Exception e) {
+					logger.debug("", e);
+				}
+			}
+		}
+	}
+
+	public void deleteHolding(int holdingId) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("OrderDAO.deleteHolding()\nHolding ID :" + holdingId);
+		}
+
+		PreparedStatement deleteHoldingStat = null;
+		try {
+			deleteHoldingStat = sqlConnection.prepareStatement(SQL_DELETE_HOLDING);
+			deleteHoldingStat.setInt(1, holdingId);
+			deleteHoldingStat.execute();
+
+		} catch (SQLException e) {
+			throw new DAOException("An exception is thrown during deletion of a holding entry",e);
+		} finally {
+			if (deleteHoldingStat != null) {
+				try {
+					deleteHoldingStat.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		}
+	}
+
+	public CustomHoldingBean getHoldingForUpdate(int orderId)
+			throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("HoldingDataModel.getHoldingForUpdate()\nOrder ID :"+ orderId);
+		}
+		DAOFactory fac = MySQLDAOFactory.getInstance();
+		CustomerDAO customerDAO = fac.getCustomerDAO();
+		return customerDAO.getHoldingForUpdate(orderId);
+	}
+
+	public CustomHoldingBean getHolding(int holdingId) throws DAOException {
+		CustomHoldingBean holding = null;
+		PreparedStatement selectHoldingStat = null;
+		try {
+			selectHoldingStat = sqlConnection.prepareStatement(SQL_SELECT_HOLDING);
+			selectHoldingStat.setInt(1, holdingId);
+			ResultSet rs = selectHoldingStat.executeQuery();
+			if (rs.next()) {
+				try {
+					holding = new CustomHoldingBean(
+							rs.getInt(1),
+							rs.getDouble(2),
+							rs.getBigDecimal(3),
+							StockTraderUtility.convertToCalendar(rs.getDate(4)),
+							rs.getString(5),
+							rs.getInt(6));
+					return holding;
+
+				} finally {
+					try {
+						rs.close();
+					} catch (Exception e) {
+						logger.debug("", e);
+					}
+				}
+			}
+		} catch (SQLException e) {
+			throw new DAOException("An Exception is thrown during selecting a holding entry",e);
+		} finally {
+			if (selectHoldingStat != null) {
+				try {
+					selectHoldingStat.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		}
+		return holding;
+	}
+
+	public void updateAccountBalance(int accountId, BigDecimal total) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("OrderDAO.updateAccountBalance(int,BigDecimal)\nAccount ID :" + accountId + "\nTotal :" + total);
+		}
+		DAOFactory fac = MySQLDAOFactory.getInstance();
+		CustomerDAO customerDAO = fac.getCustomerDAO();
+		customerDAO.updateAccountBalance(accountId, total);
+	}
+
+	public void updateStockPriceVolume(double quantity, CustomQuoteBean quote) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("OrderDAO.updateStockPriceVolume(double,QuatedataModle)\nQuantity :" + quantity + "\nQuote\nSymbol" + quote.getSymbol());
+		}
+		DAOFactory fac = MySQLDAOFactory.getInstance();
+		MarketSummaryDAO marketSummaryDAO = fac.getMarketSummaryDAO();
+		marketSummaryDAO.updateStockPriceVolume(quantity, quote);
+	}
+
+	public void updateOrder(CustomOrderBean order) throws DAOException {
+		PreparedStatement updateHoldingStat = null;
+		try {
+			updateHoldingStat = sqlConnection.prepareStatement(SQL_UPDATE_ORDER);
+			updateHoldingStat.setDouble(1, order.getQuantity());
+			updateHoldingStat.setInt(2, order.getOrderID());
+			updateHoldingStat.executeUpdate();
+
+		} catch (SQLException e) {
+			throw new DAOException("An Exception is thrown during updating a holding entry", e);
+		} finally {
+			if (updateHoldingStat != null) {
+				try {
+					updateHoldingStat.close();
+				} catch (Exception e) {
+					logger.debug("", e);
+				}
+			}
+		}
+	}
+
+	public void closeOrder(CustomOrderBean order) throws DAOException {
+		if (logger.isDebugEnabled()) {
+			logger.debug("OrderDAO.closeOrder(OrderDataModel)\nOrderID :"
+					+ order.getOrderID() + "\nOrderType :"
+					+ order.getOrderType() + "\nSymbol :" + order.getSymbol()
+					+ "\nQuantity :" + order.getQuantity() + "\nOrder Status :"
+					+ order.getOrderStatus() + "\nOrder Open Date :"
+					+ order.getOpenDate() + "\nCompletionDate :"
+					+ order.getCompletionDate());
+		}
+
+		PreparedStatement closeOrderStat = null;
+		try {
+			closeOrderStat = sqlConnection.prepareStatement(SQL_CLOSE_ORDER);
+			closeOrderStat.setString(1, StockTraderUtility.ORDER_STATUS_CLOSED);
+			if (StockTraderUtility.ORDER_TYPE_SELL.equals(order.getOrderType())) {
+				closeOrderStat.setNull(2, Types.INTEGER);
+			} else {
+				closeOrderStat.setInt(2, order.getHoldingId());
+			}
+			closeOrderStat.setBigDecimal(3, order.getPrice());
+			closeOrderStat.setInt(4, order.getOrderID());
+			closeOrderStat.executeUpdate();
+
+		} catch (SQLException e) {
+			throw new DAOException("", e);
+
+		} finally {
+			if (closeOrderStat != null) {
+				try {
+					closeOrderStat.close();
+				} catch (Exception e) {
+					logger.debug("", e);
+				}
+			}
+		}
+	}
+
+	public CustomOrderBean createOrder(String userID, String symbol, String orderType, double quantity, int holdingID) throws DAOException {
+		int orderID = 0;
+		Calendar minCalender = Calendar.getInstance();
+		minCalender.setTimeInMillis(0);
+		CustomOrderBean order = new CustomOrderBean(
+                orderID,
+                orderType,
+				StockTraderUtility.ORDER_STATUS_OPEN,
+                Calendar.getInstance(),
+				minCalender,
+                quantity,
+                BigDecimal.valueOf(1),
+				StockTraderUtility.getOrderFee(orderType),
+                symbol);
+		order.setHoldingId(holdingID);
+
+		PreparedStatement getAccountId = null;
+		try {
+			getAccountId = sqlConnection.prepareStatement(SQL_GET_ACCOUNTID);
+			getAccountId.setString(1, userID);
+			ResultSet rs = getAccountId.executeQuery();
+			if (rs.next()) {
+				order.setAccountId(rs.getInt(1));
+			}
+		} catch (SQLException e) {
+
+		} finally {
+			if (getAccountId != null) {
+				try {
+					getAccountId.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		}
+
+		PreparedStatement insertOrder = null;
+		PreparedStatement selectOrderID = null;
+		try {
+			insertOrder = sqlConnection.prepareStatement(SQL_INSERT_ORDER);
+			insertOrder.setBigDecimal(1, order.getOrderFee());
+			insertOrder.setBigDecimal(2, order.getPrice());
+			insertOrder.setString(3, order.getSymbol());
+            // FIXED: metro used Double rather than double
+//			insertOrder.setFloat(4, (float) order.getQuantity());
+			insertOrder.setFloat(4, order.getQuantity().floatValue());
+			insertOrder.setString(5, order.getOrderType());
+			insertOrder.setInt(6, order.getAccountId());
+			insertOrder.setInt(7, order.getHoldingId());
+			insertOrder.executeUpdate();
+
+
+			selectOrderID = sqlConnection.prepareStatement(SQL_SELECT_ORDER_ID);
+			// ORDERFEE = ? AND PRICE = ? AND QUOTE_SYMBOL = ? AND QUANTITY = ?
+			// ORDERTYPE = ? ORDERSTATUS = ? AND ACCOUNT_ACCOUNTID = ?
+			// HOLDING_HOLDINGID = ?"
+			selectOrderID.setBigDecimal(1, order.getOrderFee());
+			selectOrderID.setBigDecimal(2, order.getPrice());
+			selectOrderID.setString(3, order.getSymbol());
+			selectOrderID.setDouble(4, order.getQuantity());
+			selectOrderID.setString(5, order.getOrderType());
+			selectOrderID.setString(6, "open");
+			selectOrderID.setInt(7, order.getAccountId());
+			selectOrderID.setInt(8, order.getHoldingId());
+			ResultSet rs = selectOrderID.executeQuery();
+			if (rs.next()) {
+				try {
+					order.setOrderID(rs.getInt(1));
+				} finally {
+					try {
+						rs.close();
+					} catch (SQLException e) {
+						logger.debug("", e);
+					}
+				}
+			}
+		} catch (SQLException e) {
+			throw new DAOException("", e);
+		} finally {
+			if (insertOrder != null) {
+				try {
+					insertOrder.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+			if (selectOrderID != null) {
+				try {
+					selectOrderID.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		}
+		return order;
+	}
+}
+

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeConfigServiceClient.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeConfigServiceClient.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeConfigServiceClient.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeConfigServiceClient.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,68 @@
+package org.apache.stonehenge.stocktrader.services;
+
+import org.apache.stonehenge.stocktrader.util.StockTraderUtility;
+import org.datacontract.schemas._2004._07.trade.BSConfigRequest;
+import org.datacontract.schemas._2004._07.trade.BSConfigResponse;
+import org.tempuri.ConfigService;
+import org.tempuri.ConfigServiceService;
+import traderconfighost.trade.GetBSConfig;
+import traderconfighost.trade.GetBSConfigResponse;
+
+import javax.xml.ws.BindingProvider;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class TradeConfigServiceClient {
+    private static final String SERVICE_URL = "org.apache.stonehenge.stocktrader.TradeConfigService.url";
+
+    private static TradeConfigServiceClient self = null;
+    private Properties prop = new Properties();
+    private static ConfigServiceService service = null;
+
+    public static TradeConfigServiceClient getInstance() {
+        if (self == null) {
+            self = new TradeConfigServiceClient();
+        }
+        return self;
+    }
+
+    private TradeConfigServiceClient() {
+        ClassLoader cl = getClass().getClassLoader();
+        InputStream is = cl
+                .getResourceAsStream(StockTraderUtility.TRADE_ORDER_SERVICE_PROPERTY_FILE);
+        try {
+            prop.load(is);
+        } catch (IOException e) {
+        }
+
+        ConfigService configService = new ConfigService();
+        service = configService.getBasicHttpBindingConfigServiceService();
+        ((BindingProvider) service).getRequestContext()
+                .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, prop.getProperty(SERVICE_URL));
+    }
+
+    public TradeOrderConfig getTradeOrderConfig() {
+        GetBSConfig getBSConfig = new GetBSConfig();
+        BSConfigRequest configRequest = new BSConfigRequest();
+        configRequest.setBSName("METRO_BS");
+        getBSConfig.setBs(configRequest);
+        GetBSConfigResponse getBSConfigResponse = service.getBSConfig(getBSConfig);
+        BSConfigResponse response = getBSConfigResponse.getGetBSConfigResult();
+
+        TradeOrderConfig config = new TradeOrderConfig();
+        config.setEndpointURL(response.getOPS());
+        config.setSecure(response.isSec());
+        return config;
+    }
+
+    public static void main(String arg[]) {
+        TradeConfigServiceClient client = TradeConfigServiceClient.getInstance();
+        TradeOrderConfig config = client.getTradeOrderConfig();
+        String url = config.getEndpointURL();
+
+        assert url.equals("http://localhost:8090/order_processor/OrderProcessorSec");
+        
+        System.out.println("connect successfully!!");
+    }
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeOrderConfig.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeOrderConfig.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeOrderConfig.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeOrderConfig.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,19 @@
+package org.apache.stonehenge.stocktrader.services;
+
+public class TradeOrderConfig {
+    private String endpointURL;
+	private boolean secure;
+
+	public String getEndpointURL() {
+		return endpointURL;
+	}
+	public void setEndpointURL(String endpointURL) {
+		this.endpointURL = endpointURL;
+	}
+	public boolean isSecure() {
+		return secure;
+	}
+	public void setSecure(boolean secure) {
+		this.secure = secure;
+	}
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeOrderServiceClient.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeOrderServiceClient.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeOrderServiceClient.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeOrderServiceClient.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,54 @@
+package org.apache.stonehenge.stocktrader.services;
+
+import org.tempuri.OrderProcessor;
+import org.tempuri.OrderProcessorService;
+import org.apache.stonehenge.stocktrader.CustomOrderBean;
+import traderorderhost.trade.SubmitOrder;
+
+import javax.xml.ws.BindingProvider;
+import java.io.IOException;
+
+public class TradeOrderServiceClient {
+    private static TradeOrderServiceClient self = null;
+
+    private TradeOrderServiceClient() throws IOException {
+    }
+
+    public static final TradeOrderServiceClient getInstance()
+            throws IOException {
+        if (self == null) {
+            self = new TradeOrderServiceClient();
+        }
+        return self;
+    }
+
+    public void SubmitOrder(CustomOrderBean order) throws IOException {
+        OrderProcessor processor = new OrderProcessor();
+        OrderProcessorService service = getOrderProcessorService(processor);
+
+        SubmitOrder param = new SubmitOrder();
+        param.setOrder(order);
+        service.submitOrder(param);
+    }
+
+    private OrderProcessorService getOrderProcessorService(OrderProcessor processor) throws IOException {
+        TradeOrderConfig config = TradeConfigServiceClient.getInstance().getTradeOrderConfig();
+        OrderProcessorService service;
+        if (config.isSecure()) {
+            service = processor.getCustomBindingOrderProcessorService();
+        } else {
+            service = processor.getBasicHttpBindingOrderProcessorService();
+        }
+
+        ((BindingProvider) service).getRequestContext()
+                .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, config.getEndpointURL());
+        return service;
+    }
+
+    public static void main(String[] args) throws Exception {
+        TradeOrderServiceClient asynClient = TradeOrderServiceClient.getInstance();
+        CustomOrderBean order = new CustomOrderBean(2, 2);
+        order.setQuantity(235D);
+        asynClient.SubmitOrder(order);
+    }
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeServiceImpl.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeServiceImpl.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TradeServiceImpl.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,299 @@
+package org.apache.stonehenge.stocktrader.services;
+
+import org.tempuri.ITradeServices;
+import org.apache.stonehenge.stocktrader.*;
+import org.apache.stonehenge.stocktrader.dal.DAOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import com.ibm.websphere.samples.trade.*;
+
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import java.util.List;
+
+@WebService(endpointInterface = "org.tempuri.ITradeServices")
+public class TradeServiceImpl implements ITradeServices {
+    private static final Log logger = LogFactory.getLog(TradeServiceImpl.class);
+
+	private final TraderServiceManager mgr = new TraderServiceManager();
+    
+    public EmptyMethodActionResponse emptyMethodAction(
+            @WebParam(name = "emptyMethodAction", targetNamespace = "http://trade.samples.websphere.ibm.com",
+                    partName = "parameters") EmptyMethodAction emptyMethodAction) {
+        throw new UnsupportedOperationException("emptyMethodAction unimplemented");
+    }
+
+    public void isOnline(
+            @WebParam(name = "isOnline", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") IsOnline isOnline) {
+        if (logger.isDebugEnabled()) {
+			logger.debug("TradeServiceImpl.isOnline()");
+		}
+    }
+
+    public LoginResponse login(
+            @WebParam(name = "login", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") Login login) {
+        CustomAccountBean param;
+		try {
+			param = mgr.login(login.getUserID(), login.getPassword());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		LoginResponse response = new LoginResponse();
+		response.setLoginReturn(param);
+		return response;
+    }
+
+    public GetOrdersResponse getOrders(
+            @WebParam(name = "getOrders", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") GetOrders getOrders) {
+        List<CustomOrderBean> orders;
+		try {
+			orders = mgr.getOrders(getOrders.getUserID());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetOrdersResponse response = new GetOrdersResponse();
+		ArrayOfOrderDataBean param = new ArrayOfOrderDataBean();
+        // FIXED: used array for metro generated code
+        param.getOrderDataBean().addAll(orders);
+//		param.setOrderDataBean(toArray(orders));
+		response.setGetOrdersReturn(param);
+		return response;
+    }
+
+    public GetAccountDataResponse getAccountData(
+            @WebParam(name = "getAccountData", targetNamespace = "http://trade.samples.websphere.ibm.com",
+                    partName = "parameters") GetAccountData getAccountData) {
+        CustomAccountBean accountData;
+		try {
+			accountData = mgr.getAccountData(getAccountData.getUserID());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetAccountDataResponse getAccountDataResponse = new GetAccountDataResponse();
+		getAccountDataResponse.setGetAccountDataReturn(accountData);
+		return getAccountDataResponse;
+    }
+
+    public GetAccountProfileDataResponse getAccountProfileData(
+            @WebParam(name = "getAccountProfileData", targetNamespace = "http://trade.samples.websphere.ibm.com",
+                    partName = "parameters") GetAccountProfileData getAccountProfileData) {
+        CustomAccountProfileBean accountProfileData;
+		try {
+			accountProfileData = mgr
+					.getAccountProfileData(getAccountProfileData.getUserID());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetAccountProfileDataResponse response = new GetAccountProfileDataResponse();
+		response.setGetAccountProfileDataReturn(accountProfileData);
+		return response;
+    }
+
+    public UpdateAccountProfileResponse updateAccountProfile(
+            @WebParam(name = "updateAccountProfile", targetNamespace = "http://trade.samples.websphere.ibm.com",
+                    partName = "parameters") UpdateAccountProfile updateAccountProfile) {
+        CustomAccountProfileBean accountProfile = new CustomAccountProfileBean(
+				updateAccountProfile.getProfileData());
+		CustomAccountProfileBean param;
+		try {
+			param = mgr.updateAccountProfile(accountProfile);
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+
+		UpdateAccountProfileResponse response = new UpdateAccountProfileResponse();
+		response.setUpdateAccountProfileReturn(param);
+		return response;
+    }
+
+    public LogoutResponse logout(
+            @WebParam(name = "logout", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") Logout logout) {
+        try {
+			mgr.logout(logout.getUserID());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		LogoutResponse response = new LogoutResponse();
+		return response;
+    }
+
+    public BuyResponse buy(
+            @WebParam(name = "buy", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") Buy buy) {
+        CustomOrderBean order;
+		try {
+			order = mgr
+					.buy(buy.getUserID(), buy.getSymbol(), buy.getQuantity());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		BuyResponse buyResponse = new BuyResponse();
+		buyResponse.setBuyReturn(order);
+		return buyResponse;
+    }
+
+    public SellResponse sell(
+            @WebParam(name = "sell", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") Sell sell) {
+        CustomOrderBean param;
+		try {
+			param = mgr.sell(sell.getUserID(), sell.getHoldingID(), sell
+					.getOrderProcessingMode());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		SellResponse response = new SellResponse();
+		response.setSellReturn(param);
+		return response;
+    }
+
+    public GetHoldingsResponse getHoldings(
+            @WebParam(name = "getHoldings", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") GetHoldings getHoldings) {
+        List<CustomHoldingBean> holdingBeans;
+		try {
+			holdingBeans = mgr.getHoldings(getHoldings.getUserID());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetHoldingsResponse response = new GetHoldingsResponse();
+		ArrayOfHoldingDataBean param = new ArrayOfHoldingDataBean();
+        
+        // FIXED: used array for metro generated code
+        param.getHoldingDataBean().addAll(holdingBeans);
+//		param.setHoldingDataBean(toArray(holdingBeans));
+		response.setGetHoldingsReturn(param);
+		return response;
+    }
+
+    public RegisterResponse register(
+            @WebParam(name = "register", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") Register register) {
+        CustomAccountBean param;
+		try {
+			param = mgr.register(register.getUserID(), register.getPassword(),
+					register.getFullname(), register.getAddress(), register
+							.getEmail(), register.getCreditcard(), register
+							.getOpenBalance());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		RegisterResponse response = new RegisterResponse();
+		response.setRegisterReturn(param);
+		return response;
+    }
+
+    public GetClosedOrdersResponse getClosedOrders(
+            @WebParam(name = "getClosedOrders", targetNamespace = "http://trade.samples.websphere.ibm.com",
+                    partName = "parameters") GetClosedOrders getClosedOrders) {
+        List<CustomOrderBean> closedOrders;
+		try {
+			closedOrders = mgr.getClosedOrders(getClosedOrders.getUserID());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetClosedOrdersResponse response = new GetClosedOrdersResponse();
+		ArrayOfOrderDataBean arrayOfOrderBean = new ArrayOfOrderDataBean();
+        // FIXED: used array for metro generated code
+        arrayOfOrderBean.getOrderDataBean().addAll(closedOrders);
+//		arrayOfOrderBean.setOrderDataBean(toArray(closedOrders));
+		response.setGetClosedOrdersReturn(arrayOfOrderBean);
+		return response;
+    }
+
+    public GetMarketSummaryResponse getMarketSummary(
+            @WebParam(name = "getMarketSummary", targetNamespace = "http://trade.samples.websphere.ibm.com",
+                    partName = "parameters") GetMarketSummary getMarketSummary) {
+        CustomMarketSummaryBean param;
+		try {
+			param = mgr.getMarketSummary();
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetMarketSummaryResponse response = new GetMarketSummaryResponse();
+		response.setGetMarketSummaryReturn(param);
+		return response;
+    }
+
+    public GetQuoteResponse getQuote(
+            @WebParam(name = "getQuote", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") GetQuote getQuote) {
+        CustomQuoteBean param;
+		try {
+			param = mgr.getQuote(getQuote.getSymbol());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetQuoteResponse response = new GetQuoteResponse();
+		response.setGetQuoteReturn(param);
+		return response;
+    }
+
+    public GetHoldingResponse getHolding(
+            @WebParam(name = "getHolding", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") GetHolding getHolding) {
+        CustomHoldingBean holding;
+		try {
+			holding = mgr.getHolding(getHolding.getUserID(), getHolding
+					.getHoldingID());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetHoldingResponse response = new GetHoldingResponse();
+		response.setGetHoldingReturn(holding);
+		return response;
+    }
+
+    public GetTopOrdersResponse getTopOrders(
+            @WebParam(name = "getTopOrders", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") GetTopOrders getTopOrders) {
+        List<CustomOrderBean> topOrders;
+		try {
+			topOrders = mgr.getTopOrders(getTopOrders.getUserID());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		GetTopOrdersResponse response = new GetTopOrdersResponse();
+		ArrayOfOrderDataBean param = new ArrayOfOrderDataBean();
+        // FIXED: used array for metro generated code
+        param.getOrderDataBean().addAll(topOrders);
+//		param.setOrderDataBean(toArray(topOrders));
+		response.setGetTopOrdersReturn(param);
+		return response;
+    }
+
+    public SellEnhancedResponse sellEnhanced(
+            @WebParam(name = "sellEnhanced", targetNamespace = "http://trade.samples.websphere.ibm.com", partName =
+                    "parameters") SellEnhanced sellEnhanced) {
+        CustomOrderBean param;
+		try {
+			param = mgr.sellEnhanced(sellEnhanced.getUserID(), sellEnhanced
+					.getHoldingID(), sellEnhanced.getQuantity());
+		} catch (DAOException e) {
+			logger.debug("", e);
+			throw new RuntimeException(e);
+		}
+		SellEnhancedResponse response = new SellEnhancedResponse();
+		response.setSellEnhancedReturn(param);
+		return response;
+    }
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TraderServiceManager.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TraderServiceManager.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TraderServiceManager.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/services/TraderServiceManager.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,228 @@
+/*
+ * 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.stonehenge.stocktrader.services;
+
+import java.math.BigDecimal;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stonehenge.stocktrader.CustomAccountBean;
+import org.apache.stonehenge.stocktrader.CustomAccountProfileBean;
+import org.apache.stonehenge.stocktrader.CustomHoldingBean;
+import org.apache.stonehenge.stocktrader.CustomMarketSummaryBean;
+import org.apache.stonehenge.stocktrader.CustomOrderBean;
+import org.apache.stonehenge.stocktrader.CustomQuoteBean;
+import org.apache.stonehenge.stocktrader.dal.CustomerDAO;
+import org.apache.stonehenge.stocktrader.dal.DAOException;
+import org.apache.stonehenge.stocktrader.dal.DAOFactory;
+import org.apache.stonehenge.stocktrader.dal.MarketSummaryDAO;
+import org.apache.stonehenge.stocktrader.dal.OrderDAO;
+import org.apache.stonehenge.stocktrader.util.StockTraderUtility;
+
+public class TraderServiceManager {
+
+	private static final Log logger = LogFactory
+			.getLog(TraderServiceManager.class);
+
+	private DAOFactory factory = null;
+
+	public TraderServiceManager() {
+		factory = DAOFactory.getFacotry();
+	}
+
+	public CustomAccountBean login(String userId, String password)
+			throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.login(userId, password);
+	}
+
+	public void logout(String userId) throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		customerDAO.logoutUser(userId);
+	}
+
+	public CustomAccountBean getAccountData(String userId) throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.getCustomerByUserId(userId);
+	}
+
+	public CustomAccountProfileBean getAccountProfileData(String userId)
+			throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.getAccountProfileData(userId);
+	}
+
+	public List<CustomOrderBean> getOrders(String userId) throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.getOrders(userId, false,
+				StockTraderUtility.MAX_QUERY_TOP_ORDERS,
+				StockTraderUtility.MAX_QUERY_ORDERS);
+	}
+
+	public List<CustomOrderBean> getTopOrders(String userId)
+			throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.getOrders(userId, true,
+				StockTraderUtility.MAX_QUERY_TOP_ORDERS,
+				StockTraderUtility.MAX_QUERY_ORDERS);
+	}
+
+	public List<CustomOrderBean> getClosedOrders(String userId)
+			throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.getClosedOrders(userId);
+	}
+
+	public CustomAccountBean register(String userId, String password,
+			String fullName, String address, String email, String creditcard,
+			BigDecimal openBalance) throws DAOException {
+		throw new UnsupportedOperationException();
+	}
+
+//	public CustomAccountBean addNewRegisteredUser(String userId,
+//			String password, String fullName, String address, String email,
+//			String creditcard, BigDecimal openBalance) throws DAOException {
+//		CustomerDAO customerDAO = factory.getCustomerDAO();
+//		CustomAccountProfileBean customerProfile = new CustomAccountProfileBean(
+//				userId, password, fullName, address, email, creditcard);
+//		customerDAO.insertAccountProfile(customerProfile);
+//		CustomAccountBean customer = new CustomAccountBean(0, userId, Calendar
+//				.getInstance(), openBalance, 0, openBalance, Calendar
+//				.getInstance(), 0);
+//		return customer;
+//	}
+
+	public CustomAccountProfileBean updateAccountProfile(
+			CustomAccountProfileBean customAccountProfile) throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.update(customAccountProfile);
+	}
+
+	public CustomMarketSummaryBean getMarketSummary() throws DAOException {
+		MarketSummaryDAO marketSummaryDAO = factory.getMarketSummaryDAO();
+		return marketSummaryDAO.getCustomMarketSummary();
+	}
+
+	public CustomQuoteBean getQuote(String symbol) throws DAOException {
+		MarketSummaryDAO marketSummaryDAO = factory.getMarketSummaryDAO();
+		return marketSummaryDAO.getQuote(symbol);
+	}
+
+	public CustomOrderBean buy(String userID, String symbol, double quantity)
+			throws DAOException {
+		return placeOrder(StockTraderUtility.ORDER_TYPE_BUY, userID, 0, symbol,
+				quantity);
+	}
+
+	public CustomOrderBean sell(String userID, int holdingID,
+			int orderProcessingMode) throws DAOException {
+		return placeOrder(StockTraderUtility.ORDER_TYPE_SELL, userID,
+				holdingID, null, 0);
+	}
+
+	public CustomOrderBean sellEnhanced(String userID, int holdingID,
+			double quantity) throws DAOException {
+		return placeOrder(StockTraderUtility.ORDER_TYPE_SELL_ENHANCED, userID,
+				holdingID, null, quantity);
+	}
+
+	public CustomOrderBean placeOrder(String orderType, String userID,
+			int holdingID, String symbol, double quantity) throws DAOException {
+		OrderDAO orderDAO = factory.getOrderDAO();
+		CustomOrderBean order = null;
+		CustomHoldingBean holding = new CustomHoldingBean();
+		try {
+
+			orderDAO.beginTransaction();
+			order = createOrder(orderType, userID, holdingID, symbol, quantity,
+					holding);
+
+            TradeOrderServiceClient asynClient = TradeOrderServiceClient.getInstance();
+			asynClient.SubmitOrder(order);
+			orderDAO.commitTransaction();
+			return order;
+		} catch (Exception e) {
+			try {
+				orderDAO.rollbackTransaction();
+			} catch (DAOException e2) {
+				throw e2;
+			}
+            logger.error(e);
+			throw new RuntimeException(e);
+		}
+	}
+
+	private CustomOrderBean createOrder(String orderType, String userID,
+			int holdingID, String symbol, double quantity,
+			CustomHoldingBean holding) throws DAOException {
+		CustomOrderBean order = null;
+		OrderDAO orderDAO = factory.getOrderDAO();
+
+		if (StockTraderUtility.ORDER_TYPE_SELL.equals(orderType)) {
+			// CHECKME holding is the argument
+			holding = orderDAO.getHolding(holdingID);
+			if (holding == null) {
+				throw new DAOException("No holding entry found for HoldingID<"
+						+ holdingID + ">");
+			}
+			order = orderDAO.createOrder(userID, holding.getQuoteID(),
+					StockTraderUtility.ORDER_TYPE_SELL, holding.getQuantity(),
+					holdingID);
+
+		} else if (StockTraderUtility.ORDER_TYPE_SELL_ENHANCED
+				.equals(orderType)) {
+			holding = orderDAO.getHolding(holdingID);
+			if (holding == null) {
+				throw new DAOException("No holding entry found for HoldingID<"
+						+ holdingID + ">");
+			}
+			if (quantity > holding.getQuantity()) {
+				order = orderDAO.createOrder(userID, holding.getQuoteID(),
+						StockTraderUtility.ORDER_TYPE_SELL, holding
+								.getQuantity(), holdingID);
+			} else {
+				order = orderDAO
+						.createOrder(userID, holding.getQuoteID(),
+								StockTraderUtility.ORDER_TYPE_SELL, quantity,
+								holdingID);
+			}
+		} else if (StockTraderUtility.ORDER_TYPE_BUY.equals(orderType)) {
+			order = orderDAO.createOrder(userID, symbol,
+					StockTraderUtility.ORDER_TYPE_BUY, quantity, -1);
+		} else {
+			throw new IllegalArgumentException("Invalid orderType<" + orderType
+					+ ">");
+		}
+		return order;
+	}
+
+	public CustomHoldingBean getHolding(String userID, int holdingID)
+			throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.getHolding(userID, holdingID);
+	}
+
+	public List<CustomHoldingBean> getHoldings(String userID)
+			throws DAOException {
+		CustomerDAO customerDAO = factory.getCustomerDAO();
+		return customerDAO.getHoldings(userID);
+	}
+
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/util/StockTraderSQLUtil.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/util/StockTraderSQLUtil.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/util/StockTraderSQLUtil.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/util/StockTraderSQLUtil.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,56 @@
+/*
+ * 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.stonehenge.stocktrader.util;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stonehenge.stocktrader.dal.DAOException;
+
+public class StockTraderSQLUtil {
+	private static final Log logger = LogFactory
+			.getLog(StockTraderSQLUtil.class);
+
+	public static Object executeScalarNoParm(String query, Connection sqlConnection)
+			throws DAOException {
+		PreparedStatement preparedStatement = null;
+		try {
+			preparedStatement = sqlConnection.prepareStatement(query);
+			ResultSet rs = preparedStatement.executeQuery();
+			if (rs.next()) {
+				return rs.getObject(1);
+			}
+			return null;
+		} catch (SQLException e) {
+			throw new DAOException("", e);
+		} finally {
+			if (preparedStatement != null) {
+				try {
+					preparedStatement.close();
+				} catch (SQLException e) {
+					logger.debug("", e);
+				}
+			}
+		}
+	}
+
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/util/StockTraderUtility.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/util/StockTraderUtility.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/util/StockTraderUtility.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/org/apache/stonehenge/stocktrader/util/StockTraderUtility.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,101 @@
+/*
+ * 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.stonehenge.stocktrader.util;
+
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.util.Calendar;
+import java.util.Random;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class StockTraderUtility {
+	
+	public static final String TRADE_ORDER_SERVICE_PROPERTY_FILE = "TradeServiceConfig.properties";
+	public static final String TRADE_ORDER_SERVICE_SECURITY_FILE = "security-policy.xml";
+	public static final String MSSQL_DB_PROPERRTIES_FILE = "mssql-db.properties";
+    public static final String DB_PROPERRTIES_FILE = "db.properties";
+	public static final String ORDER_TYPE_BUY = "buy";
+	public static final String ORDER_TYPE_SELL = "sell";
+	public static final String ORDER_TYPE_SELL_ENHANCED = "sellEnhanced";
+	public static final String ORDER_STATUS_CLOSED = "closed";
+	public static final String ORDER_STATUS_OPEN = "open";
+
+	public static final int MAX_QUERY_TOP_ORDERS = 5;
+	public static final int MAX_QUERY_ORDERS = 5;
+
+	public static final BigDecimal PENNY_STOCK_P = BigDecimal.valueOf(0.1);
+	public static final BigDecimal JUNK_STOCK_MIRACLE_MULTIPLIER = BigDecimal
+			.valueOf(500);
+	public static final BigDecimal STOCK_P_HIGH_BAR = BigDecimal.valueOf(1000);
+	public static final BigDecimal STOCK_P_HIGH_BAR_CRASH = BigDecimal
+			.valueOf(0.05);
+	public static final BigDecimal STOCK_CHANGE_MAX_PERCENT = BigDecimal
+			.valueOf(5);
+	public static final BigDecimal BUY_FEE = BigDecimal.valueOf(15.95);
+	public static final BigDecimal SELL_FEE = BigDecimal.valueOf(25.95);
+
+	private static final Log logger = LogFactory
+			.getLog(StockTraderUtility.class);
+
+	public static BigDecimal getRandomPriceChangeFactor(BigDecimal currentPrice) {
+		if (currentPrice.compareTo(PENNY_STOCK_P) == -1
+				|| currentPrice.compareTo(PENNY_STOCK_P) == 0) {
+			return JUNK_STOCK_MIRACLE_MULTIPLIER;
+		} else if (currentPrice.compareTo(STOCK_P_HIGH_BAR) == 1
+				|| currentPrice.compareTo(STOCK_P_HIGH_BAR) == 0) {
+			return STOCK_P_HIGH_BAR_CRASH;
+		}
+
+		BigDecimal factor = BigDecimal.valueOf(0);
+		Random rand = new Random();
+		int y = rand.nextInt(STOCK_CHANGE_MAX_PERCENT.subtract(BigDecimal.ONE)
+				.intValue());
+		y = y + 1;
+		int x = rand.nextInt();
+
+		if (x % 2 == 0) {
+			factor = BigDecimal.ONE.subtract((BigDecimal.valueOf(y))
+					.divide(BigDecimal.valueOf(100)));// / 100m;
+		} else
+			factor = BigDecimal.ONE.add(BigDecimal.ONE.add(BigDecimal
+					.valueOf(y).divide(BigDecimal.valueOf(100))));
+		return factor;
+	}
+
+	public static Date convertToSqlDate(Calendar calendar) {
+		return new Date(calendar.getTimeInMillis());
+	}
+
+	public static Calendar convertToCalendar(Date date) {
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTimeInMillis(date.getTime());
+		return calendar;
+	}
+
+	public static BigDecimal getOrderFee(String orderType) {
+		if (StockTraderUtility.ORDER_TYPE_BUY.equals(orderType)
+				|| StockTraderUtility.ORDER_TYPE_SELL.equals(orderType)) {
+			return BUY_FEE;
+		} else {
+			return SELL_FEE;
+		}
+	}
+
+}

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/wsdl0.wsdl
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/wsdl0.wsdl?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/wsdl0.wsdl (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/wsdl0.wsdl Sat Sep  5 16:41:14 2009
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wsdl:definitions targetNamespace="http://Trade.TraderOrderHost" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+                  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+                  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+                  xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://Trade.TraderOrderHost"
+                  xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
+                  xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+                  xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+                  xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
+                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+                  xmlns:wsa10="http://www.w3.org/2005/08/addressing"
+                  xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
+    <wsdl:types>
+        <xsd:schema targetNamespace="http://Trade.TraderOrderHost/Imports">
+            <xsd:import schemaLocation="xsd0.xsd"
+                        namespace="http://Trade.TraderOrderHost"/>
+            <xsd:import schemaLocation="xsd1.xsd"
+                        namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
+            <xsd:import schemaLocation="xsd2.xsd"
+                        namespace="http://trade.samples.websphere.ibm.com"/>
+        </xsd:schema>
+    </wsdl:types>
+    <wsdl:message name="OrderProcessorService_SubmitOrder_InputMessage">
+        <wsdl:part name="parameters" element="tns:SubmitOrder"/>
+    </wsdl:message>
+    <wsdl:message name="OrderProcessorService_isOnline_InputMessage">
+        <wsdl:part name="parameters" element="tns:isOnline"/>
+    </wsdl:message>
+    <wsdl:portType name="OrderProcessorService">
+        <wsdl:operation name="SubmitOrder">
+            <wsdl:input wsaw:Action="SubmitOrder" message="tns:OrderProcessorService_SubmitOrder_InputMessage"/>
+        </wsdl:operation>
+        <wsdl:operation name="isOnline">
+            <wsdl:input wsaw:Action="isOnline" message="tns:OrderProcessorService_isOnline_InputMessage"/>
+        </wsdl:operation>
+    </wsdl:portType>
+</wsdl:definitions>
\ No newline at end of file

Added: incubator/stonehenge/trunk/stocktrader/metro/business_service/src/wsit-client.xml
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/business_service/src/wsit-client.xml?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/business_service/src/wsit-client.xml (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/business_service/src/wsit-client.xml Sat Sep  5 16:41:14 2009
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wsdl:definitions name="OrderProcessor" targetNamespace="http://tempuri.org/"
+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/"
+                  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+                  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+                  xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/"
+                  xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
+                  xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://Trade.TraderOrderHost"
+                  xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+                  xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
+                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+                  xmlns:wsa10="http://www.w3.org/2005/08/addressing"
+                  xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
+
+    <wsp:Policy wsu:Id="ClientKeystorePolicy"
+                xmlns:sc="http://schemas.sun.com/2006/03/wss/client"
+                xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy"
+                xmlns:scc="http://schemas.sun.com/ws/2006/05/sc/client">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <sunsp:DisableInclusivePrefixList xmlns:sunsp="http://schemas.sun.com/2006/03/wss/client"></sunsp:DisableInclusivePrefixList>
+                <sc:KeyStore wspp:visibility="private" location="client-keystore.jks"
+                             type="JKS" alias="mykey" storepass="changeit"></sc:KeyStore>
+                <sc:TrustStore wspp:visibility="private" location="client-truststore.jks"
+                               type="JKS" storepass="changeit" peeralias="mykey"></sc:TrustStore>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+
+    <wsdl:import namespace="http://Trade.TraderOrderHost" location="wsdl0.wsdl"/>
+
+    <wsdl:binding name="CustomBinding_OrderProcessorService" type="i0:OrderProcessorService">
+        <wsp:PolicyReference URI="#ClientKeystorePolicy"/>
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="SubmitOrder">
+            <soap:operation soapAction="SubmitOrder" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="OrderProcessor">
+        <wsdl:port name="CustomBinding_OrderProcessorService" binding="tns:CustomBinding_OrderProcessorService">
+            <soap:address location="http://stocktrader:8000/tradeorderprocessor/sec"/>
+            <wsa10:EndpointReference>
+                <wsa10:Address>http://stocktrader:8000/tradeorderprocessor/sec</wsa10:Address>
+                <Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
+                    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
+                        <X509Data>
+                            <X509Certificate>
+                                MIIB8DCCAVmgAwIBAgIQ1ELWkagtIaZA+rGlQ0DB/DANBgkqhkiG9w0BAQQFADASMRAwDgYDVQQDEwdPUFMuQ29tMB4XDTA4MDUyMTA0NDUwMVoXDTM5MTIzMTIzNTk1OVowEjEQMA4GA1UEAxMHT1BTLkNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAxwk9moHNb3pwAFdolsVrNRCypa9MAH9NOblGJRW6av93sC5oubfjbzfIgURycVgOYoI/6G3AZijENC//tR8CiNuwfc338j4gGJCYQMKF80f0v+wsOChbWA/jSMmW0XeZ2mtn28kUzZwBN+auK+iUurYmUfZlNCIzLrM49KKqLRMCAwEAAaNHMEUwQwYDVR0BBDwwOoAQGGhusN6c4j/7WSnvieRMbKEUMBIxEDAOBgNVBAMTB09QUy5Db22CENRC1pGoLSGmQPqxpUNAwfwwDQYJKoZIhvcNAQEEBQADgYEAZ8xVxioCvG8t8iCx5Xy7JgUyGVnTgxVhP3+uMGSca0u1wqnfoPethXkykPkCP5ZEYSS5SoBLdCKhn1HqICdTBkR2m0ebo50CoXT1lAy+5MELdzlR8SH9KV6nokwCPAW3RURk1huaDi3FO1oFDVm6146rAByZrG/PjDe3w+MUaHg=
+                            </X509Certificate>
+                        </X509Data>
+                    </KeyInfo>
+                </Identity>
+            </wsa10:EndpointReference>
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file

Added: incubator/stonehenge/trunk/stocktrader/metro/config_service/build.xml
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/config_service/build.xml?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/config_service/build.xml (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/config_service/build.xml Sat Sep  5 16:41:14 2009
@@ -0,0 +1,88 @@
+<project basedir="." default="war" name="config_service">
+    <import file="../etc/as.xml"/>
+
+    <property name="src.dir" value="${basedir}/src"/>
+    <property name="build.home" value="${basedir}/build"/>
+    <property name="build.classes.home" value="${build.home}/classes"/>
+    <property name="build.war.home" value="${build.home}/war"/>
+
+    <property name="war.name" value="${ant.project.name}.war"/>
+    <property name="war.file" value="${build.war.home}/${war.name}"/>
+    <property name="lib.home" value="${basedir}/../lib"/>
+    <property name="lib.metro.home" value="${lib.home}/metro"/>
+
+    <path id="metro.classpath">
+        <pathelement location="${java.home}/../lib/tools.jar"/>
+        <fileset dir="${lib.metro.home}">
+            <include name="*.jar"/>
+        </fileset>
+    </path>
+
+    <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
+        <classpath refid="metro.classpath"/>
+    </taskdef>
+
+    <path id="all.classpath">
+        <fileset dir="${lib.home}">
+            <include name="**/*.jar"/>
+        </fileset>
+    </path>
+
+    <target name="clean">
+        <delete dir="${build.home}" includeEmptyDirs="true"/>
+    </target>
+
+    <target name="setup-build-dir" depends="clean">
+        <mkdir dir="${build.home}"/>
+        <mkdir dir="${build.classes.home}"/>
+        <mkdir dir="${build.war.home}"/>
+    </target>
+
+    <target name="setup" depends="setup-build-dir"/>
+
+    <target name="build" depends="setup">
+        <wsimport
+                debug="${debug}"
+                verbose="${verbose}"
+                keep="${keep}"
+                destdir="${build.classes.home}"
+                wsdl="${config.service.wsdl}">
+            <binding dir="${config.service.binding.dir}" includes="${config.service.binding}"/>
+            <xjcarg value="-extension"/>
+        </wsimport>
+        <copy todir="${build.classes.home}">
+            <fileset dir="../resources/conf" includes="*.properties"/>
+        </copy>
+        <javac
+                fork="true"
+                srcdir="${src.dir}"
+                destdir="${build.classes.home}">
+            <classpath refid="all.classpath"/>
+        </javac>
+    </target>
+
+    <target name="war" depends="build">
+        <war warfile="${war.file}" webxml="etc/web.xml">
+            <webinf dir="${basedir}/etc" includes="sun-jaxws.xml"/>
+            <zipfileset
+                    dir="${config.service.binding.dir}"
+                    includes="*.wsdl, *.xsd"
+                    prefix="WEB-INF/wsdl"/>
+            <classes dir="${build.classes.home}"/>
+            <lib dir="${lib.home}/commons"/>
+            <lib dir="${lib.home}/log4j"/>
+            <lib dir="${lib.home}/mssql"/>
+            <lib dir="${lib.home}/mysql"/>
+        </war>
+    </target>
+
+    <target name="deploy" depends="war">
+        <copy file="${war.file}" todir="${deploy.dir}"/>
+    </target>
+
+    <target name="undeploy">
+        <delete file="${deploy.dir}/${war.name}"/>
+    </target>
+
+    <target name="redeploy" depends="undeploy, deploy"/>
+</project>

Added: incubator/stonehenge/trunk/stocktrader/metro/config_service/etc/sun-jaxws.xml
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/config_service/etc/sun-jaxws.xml?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/config_service/etc/sun-jaxws.xml (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/config_service/etc/sun-jaxws.xml Sat Sep  5 16:41:14 2009
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+ Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+
+ The contents of this file are subject to the terms of either the GNU
+ General Public License Version 2 only ("GPL") or the Common Development
+ and Distribution License("CDDL") (collectively, the "License").  You
+ may not use this file except in compliance with the License. You can obtain
+ a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
+ language governing permissions and limitations under the License.
+
+ When distributing the software, include this License Header Notice in each
+ file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ Sun designates this particular file as subject to the "Classpath" exception
+ as provided by Sun in the GPL Version 2 section of the License file that
+ accompanied this code.  If applicable, add the following below the License
+ Header, with the fields enclosed by brackets [] replaced by your own
+ identifying information: "Portions Copyrighted [year]
+ [name of copyright owner]"
+
+ Contributor(s):
+
+ If you wish your version of this file to be governed by only the CDDL or
+ only the GPL Version 2, indicate your decision by adding "[Contributor]
+ elects to include this software in this distribution under the [CDDL or GPL
+ Version 2] license."  If you don't indicate a single choice of license, a
+ recipient has the option to distribute your version of this file under
+ either the CDDL, the GPL Version 2 or to extend the choice of license to
+ its licensees as provided above.  However, if you add GPL Version 2 code
+ and therefore, elected the GPL Version 2 license, then the option applies
+ only if the new code is made subject to such option by the copyright
+ holder.
+-->
+
+
+<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
+    <endpoint 
+        name="ConfigService"
+        implementation="org.apache.stonehenge.stocktrader.services.ConfigServiceServiceImpl"
+        wsdl="ConfigService.wsdl"
+        service="{http://tempuri.org/}ConfigService"
+        port="{http://tempuri.org/}BasicHttpBinding_ConfigServiceService"
+        url-pattern="/ConfigService"/>
+
+</endpoints>

Added: incubator/stonehenge/trunk/stocktrader/metro/config_service/etc/web.xml
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/config_service/etc/web.xml?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/config_service/etc/web.xml (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/config_service/etc/web.xml Sat Sep  5 16:41:14 2009
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ 
+ Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ 
+ The contents of this file are subject to the terms of either the GNU
+ General Public License Version 2 only ("GPL") or the Common Development
+ and Distribution License("CDDL") (collectively, the "License").  You
+ may not use this file except in compliance with the License. You can obtain
+ a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
+ language governing permissions and limitations under the License.
+ 
+ When distributing the software, include this License Header Notice in each
+ file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ Sun designates this particular file as subject to the "Classpath" exception
+ as provided by Sun in the GPL Version 2 section of the License file that
+ accompanied this code.  If applicable, add the following below the License
+ Header, with the fields enclosed by brackets [] replaced by your own
+ identifying information: "Portions Copyrighted [year]
+ [name of copyright owner]"
+ 
+ Contributor(s):
+ 
+ If you wish your version of this file to be governed by only the CDDL or
+ only the GPL Version 2, indicate your decision by adding "[Contributor]
+ elects to include this software in this distribution under the [CDDL or GPL
+ Version 2] license."  If you don't indicate a single choice of license, a
+ recipient has the option to distribute your version of this file under
+ either the CDDL, the GPL Version 2 or to extend the choice of license to
+ its licensees as provided above.  However, if you add GPL Version 2 code
+ and therefore, elected the GPL Version 2 license, then the option applies
+ only if the new code is made subject to such option by the copyright
+ holder.
+-->
+
+<web-app version="2.4" mlns="http://java.sun.com/xml/ns/j2ee">
+  <listener>
+    <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
+  </listener>
+  <servlet>
+    <servlet-name>stocktrader</servlet-name>
+    <display-name>stocktrader</display-name>
+    <description>stocktrader endpoint</description>
+    <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>stocktrader</servlet-name>
+    <url-pattern>/ConfigService</url-pattern>
+  </servlet-mapping>
+  <session-config>
+    <session-timeout>60</session-timeout>
+  </session-config>
+</web-app>

Added: incubator/stonehenge/trunk/stocktrader/metro/config_service/src/org/apache/stonehenge/stocktrader/dal/ConfigServiceDAO.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/config_service/src/org/apache/stonehenge/stocktrader/dal/ConfigServiceDAO.java?rev=811675&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/metro/config_service/src/org/apache/stonehenge/stocktrader/dal/ConfigServiceDAO.java (added)
+++ incubator/stonehenge/trunk/stocktrader/metro/config_service/src/org/apache/stonehenge/stocktrader/dal/ConfigServiceDAO.java Sat Sep  5 16:41:14 2009
@@ -0,0 +1,24 @@
+package org.apache.stonehenge.stocktrader.dal;
+
+import org.datacontract.schemas._2004._07.trade.BSConfigResponse;
+import org.datacontract.schemas._2004._07.trade.ClientConfigResponse;
+import org.datacontract.schemas._2004._07.trade.ServiceLocation;
+import org.datacontract.schemas._2004._07.trade.OPSConfigResponse;
+
+import java.util.List;
+
+public interface ConfigServiceDAO {
+    List<ServiceLocation> getBSLocations();
+
+    List<ServiceLocation> getOPSLocations();
+
+    ClientConfigResponse getClientConfig(String clientName);
+
+    BSConfigResponse getBSConfig(String bsName);
+
+    boolean setClientToBS(String clientName, String bsName);
+
+    boolean setBSToOPS(String bs, String ops);
+
+    OPSConfigResponse getOPSConfig(String opsName);
+}



Mime
View raw message