You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ri...@apache.org on 2006/05/17 17:09:23 UTC
svn commit: r407278 - in /incubator/tuscany/java/sampleapps/bigbank:
account/src/main/java/bigbank/account/services/account/
account/src/main/java/bigbank/account/services/accountdata/
account/src/main/java/bigbank/account/services/accountdb/ account/s...
Author: rineholt
Date: Wed May 17 08:09:22 2006
New Revision: 407278
URL: http://svn.apache.org/viewvc?rev=407278&view=rev
Log:
TUSCANY-393
http://issues.apache.org/jira/browse/TUSCANY-393
Cleanup bigbank sample code
Removed:
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/CheckingAccount.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/SavingsAccount.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/StockAccount.java
Modified:
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java
incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java Wed May 17 08:09:22 2006
@@ -26,7 +26,6 @@
import java.util.Map;
import java.util.TimeZone;
-import org.apache.tuscany.sdo.util.SDOUtil;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
@@ -35,18 +34,20 @@
import bigbank.account.services.stockquote.StockQuote;
import bigbank.account.services.stockquote.StockQuoteService;
-import com.bigbank.account.AccountFactory;
import com.bigbank.account.AccountReport;
import com.bigbank.account.AccountService;
import com.bigbank.account.CustomerProfileData;
import com.bigbank.account.StockSummary;
-@Service(interfaces=AccountService.class)
+@Service(interfaces = AccountService.class)
public class AccountServiceImpl implements AccountService {
-
- public static final String CHECKING_ACCOUNT_PREFIX= "134-43-394";
- public static final String SAVINGS_ACCOUNT_PREFIX= "134-42-623";
+
+ public static final String CHECKING_ACCOUNT_PREFIX = "134-43-394";
+
+ public static final String SAVINGS_ACCOUNT_PREFIX = "134-42-623";
+
public static final String ACCOUNT_TYPE_SAVINGS = "savings";
+
public static final String ACCOUNT_TYPE_CHECKINGS = "checkings";
public static final DateFormat tsformatXSDDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz");
@@ -54,7 +55,6 @@
AccountServiceImpl.tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
}
-
private String currency = "USD";
@Property
@@ -62,205 +62,176 @@
this.currency = currency;
}
-
-
private AccountDataService accountDataService;
+
@Reference
public void setAccountDataService(AccountDataService accountDataService) {
this.accountDataService = accountDataService;
}
private StockQuoteService stockQuoteService;
+
@Reference
public void setStockQuoteService(StockQuoteService stockQuoteService) {
this.stockQuoteService = stockQuoteService;
}
-
public AccountServiceImpl() {
}
-// public AccountReport getAccountReport2(int customerID) {
-//
-// AccountFactory accountFactory=new AccountFactory();
-//
-// AccountReport accountReport = accountFactory.createAccountReport();
-// List accountSummaries = accountReport.getAccountSummaries();
-//
-// CheckingAccount checkingAccount = accountDataService.getCheckingAccount(customerID);
-// AccountSummary checkingAccountSummary = accountFactory.createAccountSummary();
-// checkingAccountSummary.setAccountNumber(checkingAccount.getAccountNumber());
-// checkingAccountSummary.setAccountType("checking");
-// checkingAccountSummary.setBalance(fromUSDollarToCurrency(checkingAccount.getBalance()));
-// accountSummaries.add(checkingAccountSummary);
-//
-// SavingsAccount savingsAccount = accountDataService.getSavingsAccount(customerID);
-// AccountSummary savingsAccountSummary = accountFactory.createAccountSummary();
-// savingsAccountSummary.setAccountNumber(savingsAccount.getAccountNumber());
-// savingsAccountSummary.setAccountType("savings");
-// savingsAccountSummary.setBalance(fromUSDollarToCurrency(savingsAccount.getBalance()));
-// accountSummaries.add(savingsAccountSummary);
-//
-// StockAccount stockAccount = accountDataService.getStockAccount(customerID);
-// AccountSummary stockAccountSummary = accountFactory.createAccountSummary();
-// stockAccountSummary.setAccountNumber(stockAccount.getAccountNumber());
-// stockAccountSummary.setAccountType("stock");
-// float balance = (stockQuoteService.getQuote(stockAccount.getSymbol())) * stockAccount.getQuantity();
-// stockAccountSummary.setBalance(fromUSDollarToCurrency(balance));
-// accountSummaries.add(stockAccountSummary);
-//
-// return accountReport;
-// }
-
@SuppressWarnings("unchecked")
- public AccountReport getAccountReport(int customerID) throws RemoteException{
-
+ public AccountReport getAccountReport(int customerID) throws RemoteException {
+
try {
AccountReport accountReport = accountDataService.getAccountReport(customerID);
return updateStockInformation(accountReport);
} catch (Exception e) {
e.printStackTrace();
- if (e instanceof RemoteException) throw (RemoteException)e;
- else throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
- }
+ if (e instanceof RemoteException)
+ throw (RemoteException) e;
+ else
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
}
-
+
private AccountReport updateStockInformation(AccountReport accountReport) throws RemoteException {
List<StockSummary> stocks = accountReport.getStockSummaries();
- if(stocks.size() <1) return accountReport; //nothing todo
+ if (stocks.size() < 1)
+ return accountReport; // nothing todo
HashSet<String> owned = new HashSet<String>(stocks.size());
- for(StockSummary stock : stocks){
+ for (StockSummary stock : stocks) {
owned.add(stock.getSymbol());
}
- ArrayList<String> ownedStr= new ArrayList<String>(owned.size()*5);
- for(String s : owned){
-
+ ArrayList<String> ownedStr = new ArrayList<String>(owned.size() * 5);
+ for (String s : owned) {
+
ownedStr.add(s);
}
-
- Map<String, StockQuote> stockInfo = stockQuoteService.getQuotes((String[])ownedStr.toArray(new String[owned.size()]));
-
- for(StockSummary stock : stocks){
+
+ Map<String, StockQuote> stockInfo = stockQuoteService.getQuotes((String[]) ownedStr.toArray(new String[owned.size()]));
+
+ for (StockSummary stock : stocks) {
String symbol = stock.getSymbol();
- StockQuote stockquote= stockInfo.get(symbol);
- if(stockquote == null){
+ StockQuote stockquote = stockInfo.get(symbol);
+ if (stockquote == null) {
stock.setCurrentPrice(Float.NaN);
stock.setCompany("*not found*");
stock.setHighPrice(Float.NaN);
stock.setLowPrice(Float.NaN);
-
- }else{
- stock.setCurrentPrice(convertToFloat(stockquote.getStockQuote()));
- stock.setCompany(stockquote.getCompanyName());
- stock.setHighPrice(convertToFloat(stockquote.getDayHighPrice()));
- stock.setLowPrice(convertToFloat(stockquote.getDayLowPrice()));
+
+ } else {
+ stock.setCurrentPrice(convertToFloat(stockquote.getStockQuote()));
+ stock.setCompany(stockquote.getCompanyName());
+ stock.setHighPrice(convertToFloat(stockquote.getDayHighPrice()));
+ stock.setLowPrice(convertToFloat(stockquote.getDayLowPrice()));
}
- }
-
+ }
+
return accountReport;
}
-
- float convertToFloat( final String s){
-
-
- try {
- return Float.parseFloat(s);
- } catch (Exception e) {
- return Float.NaN;
- }
-
- }
+ float convertToFloat(final String s) {
+ try {
+ return Float.parseFloat(s);
+ } catch (Exception e) {
+ return Float.NaN;
+ }
+
+ }
private float fromUSDollarToCurrency(float value) {
- if (currency.equals("USD")) return value;
- else if (currency.equals("EURO")) return value * 0.8f;
+ if (currency.equals("USD"))
+ return value;
+ else if (currency.equals("EURO"))
+ return value * 0.8f;
else
return 0.0f;
}
- public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException {
-
- try{
- return accountDataService.getCustomerProfile(logonID);
- } catch (Exception e) {
- e.printStackTrace();
- if (e instanceof RemoteException) throw (RemoteException)e;
- else throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
- }
-
+ public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException {
+
+ try {
+ return accountDataService.getCustomerProfile(logonID);
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (e instanceof RemoteException)
+ throw (RemoteException) e;
+ else
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
+
}
public float deposit(String account, float ammount) throws RemoteException {
- try{
+ try {
return accountDataService.deposit(account, ammount);
- } catch (RemoteException e){
+ } catch (RemoteException e) {
e.printStackTrace();
throw e;
} catch (Exception e) {
e.printStackTrace();
- throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
- }
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
}
public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException {
- try{
- String symbol= stock.getSymbol();
- Map<String, StockQuote> stockInfo = stockQuoteService.getQuotes(new String[]{symbol});
-
+ try {
+ String symbol = stock.getSymbol();
+ Map<String, StockQuote> stockInfo = stockQuoteService.getQuotes(new String[] { symbol });
+
StockQuote stockQuote = stockInfo.get(symbol);
stock.setPurchasePrice(Float.parseFloat(stockQuote.getStockQuote()));
- String purchaseDate= tsformatXSDDateTime.format(new Date());
+ String purchaseDate = tsformatXSDDateTime.format(new Date());
if (purchaseDate.endsWith("UTC"))
purchaseDate = purchaseDate.substring(0, purchaseDate.length() - 3) + "Z";
stock.setPurchaseDate(purchaseDate);
-
return accountDataService.purchaseStock(id, stock);
- } catch (RemoteException e){
+ } catch (RemoteException e) {
e.printStackTrace();
throw e;
} catch (Exception e) {
e.printStackTrace();
- throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
- }
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
}
public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException {
- try{
+ try {
return accountDataService.sellStock(purchaseLotNumber, quantity);
- } catch (RemoteException e){
+ } catch (RemoteException e) {
e.printStackTrace();
throw e;
} catch (Exception e) {
e.printStackTrace();
- throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
- }
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
}
public float withdraw(String account, float ammount) throws RemoteException {
- try{
+ try {
return accountDataService.withdraw(account, ammount);
- } catch (RemoteException e){
+ } catch (RemoteException e) {
e.printStackTrace();
throw e;
} catch (Exception e) {
e.printStackTrace();
- throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
- }
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
}
- public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) throws RemoteException {
- try{
+ public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
+ throws RemoteException {
+ try {
return accountDataService.createAccount(customerProfile, createSavings, createCheckings);
- } catch (RemoteException e){
+ } catch (RemoteException e) {
e.printStackTrace();
throw e;
} catch (Exception e) {
e.printStackTrace();
- throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
- }
+ throw new RemoteException(e.getClass() + " " + e.getMessage(), e);
+ }
}
}
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java Wed May 17 08:09:22 2006
@@ -1,6 +1,5 @@
/**
*
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +15,6 @@
*/
package bigbank.account.services.accountdata;
-import com.bigbank.account.AccountService;
public interface AccountDataService {
@@ -75,8 +73,5 @@
public com.bigbank.account.AccountReport getAccountReport(
int param19) throws java.rmi.RemoteException;
-
-
- //
}
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java Wed May 17 08:09:22 2006
@@ -16,14 +16,11 @@
*/
package bigbank.account.services.accountdata;
-import java.awt.geom.QuadCurve2D;
import java.io.InputStream;
import java.rmi.RemoteException;
import java.sql.Connection;
-import java.sql.Date;
import java.sql.DriverManager;
import java.sql.SQLException;
-import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -36,33 +33,33 @@
import org.apache.tuscany.das.rdb.Command;
import org.apache.tuscany.das.rdb.CommandGroup;
import org.apache.tuscany.das.rdb.Converter;
-import org.apache.tuscany.sdo.util.SDOUtil;
import org.osoa.sca.annotations.Service;
import bigbank.account.services.account.AccountServiceImpl;
import com.bigbank.account.AccountFactory;
import com.bigbank.account.AccountReport;
-import com.bigbank.account.AccountService;
import com.bigbank.account.AccountSummary;
import com.bigbank.account.CustomerProfileData;
import com.bigbank.account.DataGraphRoot;
import com.bigbank.account.StockSummary;
-
import commonj.sdo.DataObject;
import commonj.sdo.helper.TypeHelper;
@Service(AccountDataService.class)
public class AccountDataServiceDASImpl implements AccountDataService {
- // TODO get rid of this!!
+
static public String dbDirectory = null;
+
public static final DateFormat tsformatXSDDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz");
+
public static final DateFormat sqlformatDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSz");
-
+
static {
- tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
- //sqlformatDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
- }
+ tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ }
+
public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException {
try {
@@ -81,8 +78,8 @@
Collection customers = root.getCustomerProfileData();
CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next();
- System.out.println(customerProfileData);
- System.out.flush();
+
+
return customerProfileData;
} catch (Exception e) {
@@ -115,8 +112,6 @@
Collection customers = root.getCustomerProfileData();
CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next();
-//System.out.println(customerProfileData);
-//System.out.flush();
return customerProfileData;
}
@@ -230,7 +225,7 @@
}
public float withdraw(String account, float ammount) throws RemoteException {
-
+
return deposit(account, -ammount);
}
@@ -259,8 +254,8 @@
conn.close();
return newbalance;
} catch (Exception e) {
- throw new RemoteException(e.getClass().getName() ,e);
- }
+ throw new RemoteException(e.getClass().getName(), e);
+ }
}
@@ -272,53 +267,52 @@
Command read = commandGroup.getCommand("stockbylotSelect");
TypeHelper helper = TypeHelper.INSTANCE;
read.setDataObjectModel(helper.getType(DataGraphRoot.class));
- read.setParameterValue("PURCHASELOTNUMBER", purchaseLotNumber);//autoboxing :-)
- DataGraphRoot root = (DataGraphRoot) read.executeQuery();
- List stocks= root.getStockSummaries();
- if(null != stocks && !stocks.isEmpty()){
- StockSummary stock= (StockSummary) stocks.get(0);
+ read.setParameterValue("PURCHASELOTNUMBER", purchaseLotNumber);// autoboxing :-)
+ DataGraphRoot root = (DataGraphRoot) read.executeQuery();
+ List stocks = root.getStockSummaries();
+ if (null != stocks && !stocks.isEmpty()) {
+ StockSummary stock = (StockSummary) stocks.get(0);
int newQuatity = Math.max(stock.getQuantity() - quantity, 0);
- if( newQuatity <1 ){
-
+ if (newQuatity < 1) {
+
Command delete = Command.FACTORY.createCommand("DELETE FROM STOCKS WHERE PURCHASELOTNUMBER = ?");
delete.setParameterValue(1, purchaseLotNumber);
delete.setConnection(getConnection());
delete.execute();
-
- }else{
-
+
+ } else {
+
Command update = commandGroup.getCommand("stockbylot");
-
+
update.setParameterValue("QUANTITY", newQuatity);
update.setParameterValue("PURCHASELOTNUMBER", purchaseLotNumber);
update.execute();
stock.setQuantity(newQuatity);
}
-
+
}
-
-
+
return null;
- } catch (Exception e) {
- throw new RemoteException("sellStock",e);
- }
+ } catch (Exception e) {
+ throw new RemoteException("sellStock", e);
+ }
}
public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException {
try {
-
- Command insert = Command.FACTORY.createCommand("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate) values (?,?,?,?,?)");
- insert.setParameterValue(1, new Integer(id));
- insert.setParameterValue(2, stock.getSymbol());
- insert.setParameterValue(3, stock.getQuantity());
- insert.setParameterValue(4, stock.getPurchasePrice());
- insert.setParameterValue(5, DateConverter.INSTANCE.getColumnValue(stock.getPurchaseDate()));
-
+
+ Command insert = Command.FACTORY
+ .createCommand("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate) values (?,?,?,?,?)");
+ insert.setParameterValue(1, new Integer(id));
+ insert.setParameterValue(2, stock.getSymbol());
+ insert.setParameterValue(3, stock.getQuantity());
+ insert.setParameterValue(4, stock.getPurchasePrice());
+ insert.setParameterValue(5, DateConverter.INSTANCE.getColumnValue(stock.getPurchaseDate()));
+
insert.setConnection(getConnection());
insert.execute();
-
return stock;
} catch (Exception e) {
@@ -335,7 +329,7 @@
// props.put("user", "tuscany");
// props.put("password", "tuscany");
conn = DriverManager.getConnection(protocol + dbDirectory + ";create=true", props);
-
+
conn.setAutoCommit(false);
return conn;
}
@@ -347,60 +341,57 @@
public static class DateConverter implements Converter {
public final static DateConverter INSTANCE = new DateConverter();
+
public DateConverter() {
}
-
- private static final DateFormat tsformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
-
- private static final DateFormat tsformatXSDDate = new SimpleDateFormat("yyyy-MM-dd");
-
+
public Object getPropertyValue(Object columnData) {
-
+
try {
-
+
String ret = tsformatXSDDateTime.format(columnData);
if (ret.endsWith("UTC"))
ret = ret.substring(0, ret.length() - 3) + "Z";
return ret;
-
+
} catch (Exception e) {
-
+
e.printStackTrace();
throw new IllegalArgumentException(e);
}
-
+
}
-
+
public Object getColumnValue(Object propertyData) {
if (propertyData instanceof java.util.Date) {
- //Need to convert back to local time for DB and remove timezone notation at the end..
- String ret= sqlformatDateTime.format(propertyData);
- char lc= ret.charAt(ret.length()-1);
- while(!Character.isDigit(lc)){
- ret= ret.substring(0, ret.length()-1);
- lc= ret.charAt(ret.length()-1);
+ // Need to convert back to local time for DB and remove timezone notation at the end..
+ String ret = sqlformatDateTime.format(propertyData);
+ char lc = ret.charAt(ret.length() - 1);
+ while (!Character.isDigit(lc)) {
+ ret = ret.substring(0, ret.length() - 1);
+ lc = ret.charAt(ret.length() - 1);
}
return ret;
} else if (propertyData instanceof String) {
-
+
try {
- String time= (String) propertyData;
- char last= time.charAt(time.length()-1);
- if(last == 'z' || last =='Z'){
- time= time.substring(0,time.length()-1);
- }
- if(!time.endsWith("UTC")){
- time= time + "UTC";
- }
+ String time = (String) propertyData;
+ char last = time.charAt(time.length() - 1);
+ if (last == 'z' || last == 'Z') {
+ time = time.substring(0, time.length() - 1);
+ }
+ if (!time.endsWith("UTC")) {
+ time = time + "UTC";
+ }
return getColumnValue(tsformatXSDDateTime.parse(time));
} catch (ParseException e) {
- throw new IllegalArgumentException("'" +propertyData +"' does not parse to date.");
+ throw new IllegalArgumentException("'" + propertyData + "' does not parse to date.");
}
} else
throw new IllegalArgumentException();
}
-
+
}
-}
+}
\ No newline at end of file
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java Wed May 17 08:09:22 2006
@@ -18,15 +18,11 @@
import java.rmi.RemoteException;
import java.util.List;
-import java.util.TimeZone;
import org.osoa.sca.annotations.Service;
-import bigbank.account.services.account.AccountServiceImpl;
-
import com.bigbank.account.AccountFactory;
import com.bigbank.account.AccountReport;
-import com.bigbank.account.AccountService;
import com.bigbank.account.AccountSummary;
import com.bigbank.account.CustomerProfileData;
import com.bigbank.account.StockSummary;
@@ -34,8 +30,6 @@
@Service(AccountDataService.class)
public class AccountDataServiceImpl implements AccountDataService {
-
-
public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException {
// TODO Auto-generated method stub
return null;
@@ -43,21 +37,21 @@
public AccountReport getAccountReport(int customerID) {
final AccountFactory accountFactory = AccountFactory.eINSTANCE;
- AccountReport accountReport= accountFactory.createAccountReport();
+ AccountReport accountReport = accountFactory.createAccountReport();
List accounts = accountReport.getAccountSummaries();
-
+
AccountSummary account = accountFactory.createAccountSummary();
account.setAccountType("1111");
account.setAccountNumber("22-22-22");
account.setBalance(123.45F);
accounts.add(account);
-
- account= accountFactory.createAccountSummary();
+
+ account = accountFactory.createAccountSummary();
account.setAccountType("04-11-19");
account.setAccountNumber("11-23");
account.setBalance(543.21F);
accounts.add(account);
-
+
List stocks = accountReport.getStockSummaries();
StockSummary stock = accountFactory.createStockSummary();
stock.setSymbol("IBM");
@@ -66,7 +60,7 @@
stock.setPurchasePrice(33.33F);
stock.setQuantity(10);
stocks.add(stock);
-
+
stock = accountFactory.createStockSummary();
stock.setSymbol("TUSK");
stock.setPurchaseDate("2005-01-05");
@@ -77,7 +71,8 @@
return accountReport;
}
- public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) throws RemoteException {
+ public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
+ throws RemoteException {
// TODO Auto-generated method stub
return null;
}
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java Wed May 17 08:09:22 2006
@@ -82,12 +82,7 @@
this.deleteExisting = false;
createDB(dbDirectory);
-// final String msgDBcreated = "BigBank database created '" + dbDirectory + "'.";
-// System.out.println(msgDBcreated);
-// System.err.println(msgDBcreated);
-// log(msgDBcreated);
- // TODO get rid of this!!!
-
+
} catch (Exception e) {
@@ -98,8 +93,6 @@
}
public AccountDBInit() {
- // System.err.println("AccountDBInit()");
- // System.out.println("AccountDBInit()");
}
public AccountDBInit(String dbDirectory, Boolean deleteExisting) {
@@ -123,17 +116,17 @@
createStockPurchase(conn, id, "DELL", 13, 12.74F, "2003-01-03 11:04:03");
createStockPurchase(conn, id, "LU", 7, 2.74F, "2003-01-04 16:04:03");
createStockPurchase(conn, id, "IBM", 22, 81.43F, "2004-02-03 13:04:33");
- // System.out.println("id " +id); System.out.flush();
+
id = createCustomer(conn, "test2", "demo2", "Pleasant Plains Rd, ViewMount, CO","test2@das.org", "test2", "password");
createAccount(conn, id, AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_SAVINGS, 924.40F);
createAccount(conn, id, AccountServiceImpl.CHECKING_ACCOUNT_PREFIX+id, AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS, 33.26F);
createStockPurchase(conn, id, "FOO", 3, 6.20F, "2000-09-11 09:11:01");
- // System.out.println("id " +id); System.out.flush();
+
conn.commit();
- System.out.println("done.");
- System.out.flush();
+
+
} catch (org.apache.derby.impl.jdbc.EmbedSQLException e) {
if (conn != null && !conn.isClosed())
@@ -141,9 +134,6 @@
if (e.getErrorCode() == 20000 && "X0Y32".equalsIgnoreCase(e.getSQLState()) && -1 != e.getMessage().indexOf("already exists")) {
// this is ok the database is there.
-// System.out.println("DB already there.");
-// System.out.flush();
-
} else {
e.printStackTrace();
@@ -176,8 +166,6 @@
Connection conn;
Class.forName(driver).newInstance();
Properties props = new Properties();
- // props.put("user", "tuscany");
- // props.put("password", "tuscany");
conn = DriverManager.getConnection(protocol + location + ";create=true", props);
conn.setAutoCommit(false);
@@ -213,7 +201,7 @@
}
int id = rs.getInt(2);
s.close();
- // System.out.println("cr2wrc id='" + id +"'"); System.out.flush();
+
return id;
}
@@ -225,7 +213,7 @@
+ accountType + "', " + balance + ")");
s.close();
- // System.out.println("cr2wrc id='" + id +"'"); System.out.flush();
+
}
@@ -242,8 +230,7 @@
+ quantity + ", " + purchasePrice + ", '" + purchaseDate + "')");
s.close();
- // System.out.println("cr2wrc id='" + id +"'"); System.out.flush();
-
+
}
protected static void registerTypes() {
@@ -273,7 +260,7 @@
createDB(dbDirectory);
accountDBInit.readDBstdout(System.out);
- // CustomerProfileData customerProfileData = accountDBInit.testgetCustomerByLoginIDThroughDASRead("cr22rc");
+
// Test withdrawl
withdraw wd = AccountFactory.INSTANCE.createwithdraw();
@@ -314,10 +301,10 @@
stockPurchase.set("PURCHASEDATE", new Date());
ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
- // apply.addConverter("STOCKS.PURCHASEDATE", MyDateConverter.class.getName());
+
apply.execute(root);
- // System.out.println(sp);
+
}
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java Wed May 17 08:09:22 2006
@@ -21,18 +21,18 @@
import java.util.Map;
import java.util.Random;
-/* Dummy'd up StockQuoteService, override webservice for now */
+/* Mock StockQuoteService */
public class StockQuoteServiceImpl implements StockQuoteService {
- static Random rn = new Random(); // squence.
+ static Random rn = new Random();
static Hashtable<String, StockQuote> stocks = new Hashtable<String, StockQuote>();
- public synchronized Map<String, StockQuote> getQuotes(String[] symbols) throws RemoteException {
+ public synchronized Map<String, StockQuote> getQuotes(String[] symbols) throws RemoteException {
Map<String, StockQuote> ret = new Hashtable<String, StockQuote>();
for (String sym : symbols) {
- sym= sym.toUpperCase();
+ sym = sym.toUpperCase();
if (!ret.containsKey(sym)) {
StockQuote sq = stocks.get(sym);
if (sq == null) {
@@ -52,7 +52,7 @@
float dh = Math.max(newval, new Float(sq.getDayHighPrice()));
sq.setDayHighPrice(dh + "");
float dl = Math.min(newval, new Float(sq.getDayLowPrice()));
- sq.setDayLowPrice(dl +"");
+ sq.setDayLowPrice(dl + "");
}
ret.put(sym, (StockQuote) sq.clone());
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java Wed May 17 08:09:22 2006
@@ -38,7 +38,6 @@
* This class implements the Stock quote service component.
*/
@Service(StockQuoteService.class)
-// FIXME workaround for JIRA TUSCANY-41
@Scope("MODULE")
public class StockQuoteWebservicexServiceImpl implements StockQuoteService {
@@ -59,13 +58,12 @@
sb.append(sym);
}
String stockdata = stockQuoteService.GetQuote(sb.toString());
- // System.err.println(stockdata);
InputStream in = new ByteArrayInputStream(stockdata.getBytes());
XMLInputFactory factory = XMLInputFactory.newInstance();
XMLStreamReader parser = factory.createXMLStreamReader(in);
ArrayList<StockQuote> listQuotes = new ArrayList<StockQuote>();
- Hashtable<String,StockQuote> listQuoteHT= new Hashtable<String,StockQuote>();
+ Hashtable<String, StockQuote> listQuoteHT = new Hashtable<String, StockQuote>();
MapStock currentStock = null;
StringBuilder currentText = new StringBuilder(100);
for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
@@ -79,19 +77,19 @@
}
break;
case XMLStreamConstants.END_ELEMENT:
- lname= parser.getLocalName();
+ lname = parser.getLocalName();
String mname = "set" + lname;
try {
Method setter = MapStock.class.getMethod(mname, new Class[] { String.class });
if (setter != null) {
setter.invoke(currentStock, currentText.toString());
- if( lname.equals("Symbol")){
+ if (lname.equals("Symbol")) {
listQuoteHT.put(currentText.toString(), currentStock);
-
+
}
}
} catch (NoSuchMethodException e) {
- // TODO: handle exception
+
}
// System.err.println(parser.getLocalName() + ":" + currentText.toString());
currentText.setLength(0);
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java Wed May 17 08:09:22 2006
@@ -16,28 +16,22 @@
*/
package bigbank.webclient.services.account;
-import java.io.InputStream;
import java.rmi.RemoteException;
-import org.apache.tuscany.sdo.util.SDOUtil;
import org.osoa.sca.ServiceUnavailableException;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
-import com.bigbank.account.AccountFactory;
import com.bigbank.account.AccountReport;
import com.bigbank.account.AccountService;
import com.bigbank.account.CustomerProfileData;
import com.bigbank.account.StockSummary;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XSDHelper;
/**
*/
@Service(AccountService.class)
public class AccountServiceComponentImpl implements AccountService {
-
private AccountService accountService;
@Reference
@@ -65,7 +59,7 @@
public StockSummary purchaseStock(int customerID, StockSummary stockSummary) throws RemoteException {
try {
- return accountService.purchaseStock(customerID, stockSummary);
+ return accountService.purchaseStock(customerID, stockSummary);
} catch (Exception e) {
throw new ServiceUnavailableException(e);
}
@@ -87,7 +81,6 @@
}
}
-
public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException {
try {
return accountService.sellStock(purchaseLotNumber, quantity);
@@ -98,16 +91,16 @@
public float withdraw(String account, float amount) throws RemoteException {
try {
- return accountService.withdraw(account, amount);
+ return accountService.withdraw(account, amount);
} catch (Exception e) {
throw new ServiceUnavailableException(e);
}
}
- public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) throws RemoteException {
-
+ public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
+ throws RemoteException {
+
return accountService.createAccount(customerProfile, createSavings, createCheckings);
}
-
}
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java Wed May 17 08:09:22 2006
@@ -26,15 +26,16 @@
@Service(LoginService.class)
public class AccountLoginServiceImpl implements LoginService {
- @Reference
+ @Reference
public AccountService accountService;
+
@Reference
public ProfileService profileService;
public int login(String userName, String password) throws RemoteException {
CustomerProfileData profileData = accountService.getCustomerProfile(userName);
-
+
if (!password.equals(profileData.getPassword())) {
return INVALID_PASSWORD;
}
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java Wed May 17 08:09:22 2006
@@ -21,9 +21,10 @@
public interface LoginService {
public static final int SUCCESS = 1;
+
public static final int INVALID_LOGIN = -1;
+
public static final int INVALID_PASSWORD = -2;
public int login(String userName, String password) throws RemoteException;
}
-
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java Wed May 17 08:09:22 2006
@@ -65,4 +65,3 @@
this.id = id;
}
}
-
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java Wed May 17 08:09:22 2006
@@ -26,14 +26,12 @@
import org.osoa.sca.ModuleContext;
import bigbank.webclient.services.profile.ProfileService;
-import bigbank.webclient.tags.sca.LoginBarrierTag;
import com.bigbank.account.AccountReport;
import com.bigbank.account.AccountService;
/**
- * Retrieves and iterates over account summary information for the current
- * profile by accessing the remotable account service component
+ * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component
*/
public class AccountStatusTag extends TagSupport {
@@ -84,18 +82,14 @@
public int doStartTag() throws JspException {
ModuleContext moduleContext = CurrentModuleContext.getContext();
- ProfileService profile = (ProfileService) moduleContext
- .locateService(mProfileService);
+ ProfileService profile = (ProfileService) moduleContext.locateService(mProfileService);
if (profile == null) {
- throw new JspException("Profile [" + mProfileService
- + "] not found in current module context");
+ throw new JspException("Profile [" + mProfileService + "] not found in current module context");
}
- AccountService service = (AccountService) moduleContext
- .locateService(mAccountService);
+ AccountService service = (AccountService) moduleContext.locateService(mAccountService);
if (service == null) {
- throw new JspException("Service [" + mAccountService
- + "] not found in current module context");
+ throw new JspException("Service [" + mAccountService + "] not found in current module context");
}
List summaries;
try {
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java Wed May 17 08:09:22 2006
@@ -22,34 +22,17 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
-import org.osoa.sca.CurrentModuleContext;
-import org.osoa.sca.ModuleContext;
-
-import bigbank.webclient.services.profile.ProfileService;
-
-import com.bigbank.account.AccountReport;
-import com.bigbank.account.AccountService;
-
/**
- * Retrieves and iterates over account summary information for the current
- * profile by accessing the remotable account service component
+ * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component
*/
public class StockStatusTag extends TagSupport {
- // ----------------------------------
- // Constructors
- // ----------------------------------
public StockStatusTag() {
super();
}
- // ----------------------------------
- // Methods
- // ----------------------------------
-
-
private String mId;
@@ -64,9 +47,10 @@
private Iterator mIterator;
public int doStartTag() throws JspException {
-
- List summaries= (List) pageContext.getAttribute("StockSummaries");
- if(null == summaries) return SKIP_BODY;
+
+ List summaries = (List) pageContext.getAttribute("StockSummaries");
+ if (null == summaries)
+ return SKIP_BODY;
mIterator = summaries.iterator();
if (mIterator.hasNext()) {
pageContext.setAttribute(mId, mIterator.next());
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java Wed May 17 08:09:22 2006
@@ -17,11 +17,9 @@
package bigbank.webclient.tags.sca;
import java.io.IOException;
+
import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
@@ -55,11 +53,9 @@
public void setUrl(String pUrl) {
mUrl = pUrl;
}
-
- int doPage= EVAL_PAGE;
-
-// TODO REMOVE
-// public static ProfileService hackCauseSessionAreLost= null;
+
+ int doPage = EVAL_PAGE;
+
public int doStartTag() throws JspException {
if (mProfile == null || mProfile.length() < 1) {
@@ -67,23 +63,20 @@
}
ModuleContext moduleContext = CurrentModuleContext.getContext();
-
- ProfileService profile = (ProfileService) moduleContext.locateService(mProfile);
-
-
+
+ ProfileService profile = (ProfileService) moduleContext.locateService(mProfile);
+
if (profile == null) {
throw new JspException("Profile [" + mProfile + "] not found in current module context");
}
-
-
-
+
if (profile.isLoggedIn()) {
return EVAL_BODY_INCLUDE;
} else {
try {
- doPage= SKIP_PAGE;
+ doPage = SKIP_PAGE;
pageContext.forward(mUrl);
- ((HttpServletResponse) (pageContext.getResponse())).sendRedirect("login.html");
+ ((HttpServletResponse) (pageContext.getResponse())).sendRedirect("login.html");
return SKIP_BODY;
} catch (ServletException e) {
throw new JspException("Unable to forward to [" + mUrl + "]");
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java Wed May 17 08:09:22 2006
@@ -22,10 +22,8 @@
import org.osoa.sca.CurrentModuleContext;
import org.osoa.sca.ModuleContext;
-
/**
- * Places an SCA service in the JSP page context, making it available to other
- * tags corresponding to its id value.
+ * Places an SCA service in the JSP page context, making it available to other tags corresponding to its id value.
*/
public class ServiceTag extends TagSupport {
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java Wed May 17 08:09:22 2006
@@ -33,18 +33,15 @@
import com.bigbank.account.CustomerProfileData;
import com.bigbank.account.StockSummary;
-
public class FormServlet extends HttpServlet {
-
-// private ServletContext mContext;
-// public void init(ServletConfig pCfg) throws ServletException {
-// mContext = pCfg.getServletContext();
-// }
-
+ // private ServletContext mContext;
+ // public void init(ServletConfig pCfg) throws ServletException {
+ // mContext = pCfg.getServletContext();
+ // }
+
public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException {
-
try {
final String action = pReq.getParameter("action");
ModuleContext moduleContext = CurrentModuleContext.getContext();
@@ -58,33 +55,33 @@
if (profileServices == null) {
throw new ServletException("ProfileServiceComponent not found.");
}
- if(!profileServices.isLoggedIn()){
- throw new ServletException("User id '"+ profileServices.getId() +"' not logged on.");
+ if (!profileServices.isLoggedIn()) {
+ throw new ServletException("User id '" + profileServices.getId() + "' not logged on.");
}
}
-
+
if ("createAccount".equals(action)) {
createAccount(pReq, pResp, accountServices);
} else if ("account".equals(action)) {
accountTransaction(pReq, pResp, accountServices);
- }else if ("stockPurchase".equals(action)) {
+ } else if ("stockPurchase".equals(action)) {
stockPurchase(pReq, pResp, profileServices, accountServices);
- }else if ("stockSale".equals(action)){
+ } else if ("stockSale".equals(action)) {
stockSale(pReq, pResp, profileServices, accountServices);
- }else{
- throw new IllegalArgumentException("Unknown action in Form servlet '" +action+"'.");
+ } else {
+ throw new IllegalArgumentException("Unknown action in Form servlet '" + action + "'.");
}
// mContext.getRequestDispatcher("summary.jsp").forward(pReq, pResp);
- pResp.sendRedirect("summary.jsp");
+ pResp.sendRedirect("summary.jsp");
} catch (ServletException e) {
e.printStackTrace();
throw e;
-
- } catch(Exception e){
-
+
+ } catch (Exception e) {
+
throw new ServletException(e);
}
-
+
}
private void stockSale(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices)
@@ -104,8 +101,8 @@
}
-
- private void stockPurchase(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices) throws ServletException {
+ private void stockPurchase(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices)
+ throws ServletException {
try {
if (!"cancel".equals(req.getParameter("cancel"))) {
@@ -118,10 +115,9 @@
}
} catch (Exception e) {
throw new ServletException("stockPurchase " + e.getMessage(), e);
- }
+ }
}
-
private void accountTransaction(HttpServletRequest req, HttpServletResponse resp, AccountService accountServices) throws ServletException {
try {
if (!"cancel".equals(req.getParameter("cancel"))) {
@@ -134,7 +130,7 @@
}
} catch (Exception e) {
throw new ServletException("accountTransaction " + e.getMessage(), e);
- }
+ }
}
@@ -147,14 +143,14 @@
customerProfileData.setEmail(pReq.getParameter("email"));
customerProfileData.setLoginID(pReq.getParameter("loginID"));
customerProfileData.setPassword(pReq.getParameter("password"));
-
-
- CustomerProfileData resp = accountServices.createAccount(customerProfileData, "savings".equals(pReq.getParameter("savings")) , "checkings".equals(pReq.getParameter("checkings")));
+
+ CustomerProfileData resp = accountServices.createAccount(customerProfileData, "savings".equals(pReq.getParameter("savings")), "checkings"
+ .equals(pReq.getParameter("checkings")));
LoginServlet.login(resp.getLoginID(), resp.getPassword());
-
+
} catch (IOException e) {
throw new ServletException(e);
}
-
+
}
}
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java Wed May 17 08:09:22 2006
@@ -20,7 +20,6 @@
import java.rmi.RemoteException;
import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -32,69 +31,61 @@
import bigbank.webclient.services.profile.LoginService;
-
public class LoginServlet extends HttpServlet {
-
-
-
- private ServletContext mContext;
public void init(ServletConfig pCfg) throws ServletException {
- mContext = pCfg.getServletContext();
+
}
public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException {
-
- if("logout".equals(pReq.getParameter("logout")) ||
- "logoutHIDDEN".equals(pReq.getParameter("logoutHIDDEN"))
- ){
+
+ if ("logout".equals(pReq.getParameter("logout")) || "logoutHIDDEN".equals(pReq.getParameter("logoutHIDDEN"))) {
HttpSession sess = pReq.getSession();
- if(sess != null) sess.invalidate();
+ if (sess != null)
+ sess.invalidate();
try {
pResp.sendRedirect("login.html");
} catch (IOException e) {
-
+
e.printStackTrace();
throw new ServletException(e);
}
-
- }else{
+ } else {
- String login = pReq.getParameter("login");
- String password = pReq.getParameter("password");
- try {
- int resp = login(login, password);
- if (resp == LoginService.SUCCESS) {
- // mContext.getRequestDispatcher("/summary.jsp").forward(pReq, pResp);
- pResp.sendRedirect("summary.jsp");
- } else {
- // mContext.getRequestDispatcher("/login.html").forward(pReq, pResp);
- pResp.sendRedirect("login.html");
+ String login = pReq.getParameter("login");
+ String password = pReq.getParameter("password");
+ try {
+ int resp = login(login, password);
+ if (resp == LoginService.SUCCESS) {
+
+ pResp.sendRedirect("summary.jsp");
+ } else {
+
+ pResp.sendRedirect("login.html");
+ }
+ } catch (IOException e) {
+ throw new ServletException(e);
}
- } catch (IOException e) {
- throw new ServletException(e);
}
}
- }
- static int login(final String login, final String password) throws ServletException{
+ static int login(final String login, final String password) throws ServletException {
ModuleContext moduleContext = CurrentModuleContext.getContext();
- LoginService loginMgr = (LoginService)
- moduleContext.locateService("LoginServiceComponent");
+ LoginService loginMgr = (LoginService) moduleContext.locateService("LoginServiceComponent");
if (loginMgr == null) {
throw new ServletException("LoginManager not found");
}
- try {
- return loginMgr.login(login, password);
- } catch (RemoteException e) {
-
- throw new ServletException(e);
- }
-
- }
-
+ try {
+ return loginMgr.login(login, password);
+ } catch (RemoteException e) {
+
+ throw new ServletException(e);
+ }
+
}
+
+}
Modified: incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp?rev=407278&r1=407277&r2=407278&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp (original)
+++ incubator/tuscany/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp Wed May 17 08:09:22 2006
@@ -31,13 +31,7 @@
<input type="hidden" name="purchaseLotNumber" value='<%=request.getParameter("purchaseLotNumber")%>' />
<TABLE border="0">
<TBODY>
-<%--
- <TR>
- <TD>Symbol </TD>
- <TD width="10%"></TD>
- <TD><INPUT type="text" name="symbol" size="6"></TD>
- </TR>
---%>
+
<TR>
<TD>Quantity</TD>
<TD></TD>