Author: rineholt
Date: Mon May 1 18:48:00 2006
New Revision: 398769
URL: http://svn.apache.org/viewcvs?rev=398769&view=rev
Log:
support deposit,withdrawl create a new account, logout mock stocks service
Modified:
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/account/AccountServiceImpl.java
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataService.java
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceImpl.java
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuote.java
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/services/account/AccountServiceComponentImpl.java
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/account/AccountStatusTag.java
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/sca/LoginBarrierTag.java
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/FormServlet.java
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/LoginServlet.java
incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/CustomerProfile.jsp
incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/summary.jsp
Modified:
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/account/AccountServiceImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/account/AccountServiceImpl.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/account/AccountServiceImpl.java
(original)
+++
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/account/AccountServiceImpl.java
Mon May 1 18:48:00 2006
@@ -174,11 +174,6 @@
return 0.0f;
}
- public StockSummary purchaseStock(int param0) throws RemoteException {
- // TODO Auto-generated method stub
- return null;
- }
-
public CustomerProfileData getCustomerProfile(String logonID) throws
RemoteException {
try{
@@ -191,24 +186,16 @@
}
- public float deposit(String param4) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public StockSummary sellStock(int param6) throws RemoteException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public float withdraw(String param8) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public float deposit(String param6, float param7) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
+ public float deposit(String account, float ammount) throws RemoteException
{
+ try{
+ return accountDataService.deposit(account, ammount);
+ } catch (RemoteException e){
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
+ }
}
public StockSummary purchaseStock(int param0, String param1, int param2)
throws RemoteException {
@@ -221,21 +208,27 @@
return null;
}
- public float withdraw(String param12, float param13) throws
RemoteException {
- // TODO Auto-generated method stub
- return 0;
+ public float withdraw(String account, float ammount) throws
RemoteException {
+ try{
+ return accountDataService.withdraw(account, ammount);
+ } catch (RemoteException e){
+ e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
+ }
}
public CustomerProfileData createAccount(CustomerProfileData
customerProfile, boolean createSavings, boolean createCheckings) throws
RemoteException {
try{
return accountDataService.createAccount(customerProfile,
createSavings, createCheckings);
+ } catch (RemoteException e){
+ e.printStackTrace();
+ throw e;
} catch (Exception e) {
e.printStackTrace();
- if (e instanceof RemoteException) throw (RemoteException)e;
- else throw new RemoteException(e.getClass() + " "
+e.getMessage(),e);
+ throw new RemoteException(e.getClass() + " " +e.getMessage(),e);
}
-
-
-
}
}
Modified:
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataService.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataService.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataService.java
(original)
+++
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataService.java
Mon May 1 18:48:00 2006
@@ -16,23 +16,67 @@
*/
package org.apache.tuscany.samples.bigbank.account.services.accountdata;
-import java.rmi.RemoteException;
+import com.bigbank.account.AccountService;
-import com.bigbank.account.AccountReport;
-import com.bigbank.account.CustomerProfileData;
-
-public interface AccountDataService {
- public CustomerProfileData getCustomerProfile(String logonID) throws
RemoteException ;
-
-// public CheckingAccount getCheckingAccount(int customerID);
-
-// public SavingsAccount getSavingsAccount(int customerID);
-//
-// public StockAccount getStockAccount(int customerID);
+public interface AccountDataService {
+
+ /**
+ * Auto generated method signatures
+ * @param param0* @param param1* @param param2
+ */
+ public com.bigbank.account.StockSummary purchaseStock(
+ int param0,java.lang.String param1,int param2) throws
java.rmi.RemoteException;
+
+
+ /**
+ * Auto generated method signatures
+ * @param param4
+ */
+ public com.bigbank.account.CustomerProfileData getCustomerProfile(
+ java.lang.String param4) throws java.rmi.RemoteException;
+
+
+ /**
+ * Auto generated method signatures
+ * @param param6* @param param7
+ */
+ public float deposit(
+ java.lang.String param6,float param7) throws java.rmi.RemoteException;
+
+ /**
+ * Auto generated method signatures
+ * @param param9* @param param10* @param param11
+ */
+ public com.bigbank.account.CustomerProfileData createAccount(
+ com.bigbank.account.CustomerProfileData param9,boolean param10,boolean
param11) throws java.rmi.RemoteException;
- public AccountReport getAccountReport(int customerID ) throws
RemoteException;
- public CustomerProfileData createAccount(CustomerProfileData
customerProfile, boolean createSavings, boolean createCheckings) throws
RemoteException ;
+ /**
+ * Auto generated method signatures
+ * @param param13* @param param14
+ */
+ public com.bigbank.account.StockSummary sellStock(
+ int param13,int param14) throws java.rmi.RemoteException;
+
+
+ /**
+ * Auto generated method signatures
+ * @param param16* @param param17
+ */
+ public float withdraw(
+ java.lang.String param16,float param17) throws java.rmi.RemoteException;
+
+
+ /**
+ * Auto generated method signatures
+ * @param param19
+ */
+ public com.bigbank.account.AccountReport getAccountReport(
+ int param19) throws java.rmi.RemoteException;
+
+
+
-}
+ //
+ }
Modified:
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
(original)
+++
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
Mon May 1 18:48:00 2006
@@ -38,8 +38,12 @@
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;
@@ -85,23 +89,6 @@
protected static final String protocol = "jdbc:derby:";
- protected InputStream createConfigStream() {
- InputStream mapping =
getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml");
- return mapping;
- }
-
- protected Connection getConnection() throws InstantiationException,
IllegalAccessException, ClassNotFoundException, SQLException {
- Connection conn;
- Class.forName(driver).newInstance();
- Properties props = new Properties();
- // props.put("user", "tuscany");
- // props.put("password", "tuscany");
- conn = DriverManager.getConnection(protocol + dbDirectory +
";create=true", props);
-
- conn.setAutoCommit(false);
- return conn;
- }
-
public CustomerProfileData testgetCustomerByLoginIDThroughDASRead(final
String logonID) throws Exception {
InputStream mapping = createConfigStream();
@@ -120,51 +107,12 @@
Collection customers = root.getCustomerProfileData();
CustomerProfileData customerProfileData = (CustomerProfileData)
customers.iterator().next();
- System.out.println(customerProfileData);
- System.out.flush();
+System.out.println(customerProfileData);
+System.out.flush();
return customerProfileData;
}
- public static class DateConverter implements Converter {
- 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");
-
- private static final DateFormat tsformatXSDDateTime = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz");
-
- public Object getPropertyValue(Object columnData) {
-
- try {
-
- tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
- 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 Date) {
- return tsformat.format(propertyData);
- } else
- throw new IllegalArgumentException();
-
- }
-
- }
-
public CustomerProfileData createAccount(CustomerProfileData
customerProfile, boolean createSavings, boolean createCheckings)
throws RemoteException {
@@ -271,5 +219,106 @@
throw new RemoteException("getAccountReport failed. customerID ('"
+ customerID + "')" + e.getClass().getName() + "'. " + e.getMessage(),
e);
}
+ }
+
+ public float withdraw(String account, float ammount) throws
RemoteException {
+
+ return deposit(account, -ammount);
+ }
+
+ public float deposit(String account, float ammount) throws RemoteException
{
+
+ try {
+ Command select = Command.FACTORY.createCommand("SELECT
accountNumber, balance FROM accounts where accountNumber = :accountNumber",
+ createConfigStream());
+ Connection conn = getConnection();
+ select.setConnection(conn);
+ select.setParameterValue("accountNumber", account);
+ TypeHelper helper = TypeHelper.INSTANCE;
+ select.setDataObjectModel(helper.getType(DataGraphRoot.class));
+ DataGraphRoot root = (DataGraphRoot) select.executeQuery();
+ Collection accounts = root.getAccountSummaries();
+ AccountSummary accountData = (AccountSummary)
accounts.iterator().next();
+ float newbalance = accountData.getBalance() + ammount;
+ accountData.setBalance(newbalance);
+ // update department set companyid = ? where department.name = ?
+ CommandGroup commandGroup =
CommandGroup.FACTORY.createCommandGroup(createConfigStream());
+ commandGroup.setConnection(conn);
+ Command update = commandGroup.getCommand("update balance");
+ update.setParameterValue("BALANCE", new Float(newbalance));
+ update.setParameterValue("ACCOUNTNUMBER", account);
+ update.execute();
+ conn.close();
+ return newbalance;
+ } catch (Exception e) {
+ throw new RemoteException(e.getClass().getName() ,e);
+ }
+
+ }
+
+ public StockSummary sellStock(int param13, int param14) throws
RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public StockSummary purchaseStock(int param0, String param1, int param2)
throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ protected Connection getConnection() throws InstantiationException,
IllegalAccessException, ClassNotFoundException, SQLException {
+ Connection conn;
+ Class.forName(driver).newInstance();
+ Properties props = new Properties();
+ // props.put("user", "tuscany");
+ // props.put("password", "tuscany");
+ conn = DriverManager.getConnection(protocol + dbDirectory +
";create=true", props);
+
+ conn.setAutoCommit(false);
+ return conn;
+ }
+
+ protected InputStream createConfigStream() {
+ InputStream mapping =
getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml");
+ return mapping;
+ }
+
+ public static class DateConverter implements Converter {
+ 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");
+
+ private static final DateFormat tsformatXSDDateTime = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz");
+
+ public Object getPropertyValue(Object columnData) {
+
+ try {
+
+ tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC"));
+ 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 Date) {
+ return tsformat.format(propertyData);
+ } else
+ throw new IllegalArgumentException();
+
+ }
+
}
}
Modified:
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceImpl.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceImpl.java
(original)
+++
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/accountdata/AccountDataServiceImpl.java
Mon May 1 18:48:00 2006
@@ -23,6 +23,7 @@
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;
@@ -75,5 +76,25 @@
public CustomerProfileData createAccount(CustomerProfileData
customerProfile, boolean createSavings, boolean createCheckings) throws
RemoteException {
// TODO Auto-generated method stub
return null;
+ }
+
+ public float deposit(String param6, float param7) throws RemoteException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public StockSummary purchaseStock(int param0, String param1, int param2)
throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public StockSummary sellStock(int param13, int param14) throws
RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public float withdraw(String param16, float param17) throws
RemoteException {
+ // TODO Auto-generated method stub
+ return 0;
}
}
Modified:
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuote.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuote.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuote.java
(original)
+++
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuote.java
Mon May 1 18:48:00 2006
@@ -201,5 +201,23 @@
result.append(')');
return result.toString();
}
+ public StockQuote clone(){
+ StockQuote ret = new StockQuote();
+ ret.companyName= companyName;
+ ret.symbol= symbol;
+ ret.stockQuote= stockQuote;
+ ret.lastUpdated= lastUpdated;
+ ret.change= change;
+ ret.openPrice= openPrice;
+ ret.dayHighPrice= dayHighPrice;
+ ret.dayLowPrice= dayLowPrice;
+ ret.volume= volume;
+ ret.marketCap= marketCap;
+ ret.yearRange= yearRange;
+ ret.exDividendDate= exDividendDate;
+ ret.dividendYield= dividendYield;
+ ret.dividendPerShare= dividendPerShare;
+ return ret;
+ }
-} // Quote
+}
Modified:
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuoteServiceImpl.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
(original)
+++
incubator/tuscany/java/samples/bigbank/account/src/main/java/org/apache/tuscany/samples/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
Mon May 1 18:48:00 2006
@@ -17,16 +17,50 @@
package org.apache.tuscany.samples.bigbank.account.services.stockquote;
import java.rmi.RemoteException;
+import java.util.Hashtable;
import java.util.Map;
+import java.util.Random;
/* Dummy'd up StockQuoteService, override webservice for now */
public class StockQuoteServiceImpl implements StockQuoteService {
-
- public Map<String, StockQuote> getQuotes(String[] symbols) throws
RemoteException {
- // TODO Auto-generated method stub
- return null;
+ static Random rn = new Random(); // squence.
+
+ static Hashtable<String, StockQuote> stocks = new Hashtable<String,
StockQuote>();
+
+ 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();
+ if (!ret.containsKey(sym)) {
+ StockQuote sq = stocks.get(sym);
+ if (sq == null) {
+ sq = new StockQuote();
+ stocks.put(sym, sq);
+ sq.setSymbol(sym);
+ sq.setCompanyName(sym + " INC");
+ float val = rn.nextFloat() * 97.0F + 3.0F;
+ sq.setStockQuote(val + "");
+ sq.setDayHighPrice(val + "");
+ sq.setDayLowPrice(val + "");
+ sq.setOpenPrice(val + "");
+ } else {
+ float diff = (rn.nextFloat() * 2.0F) - 1;
+ float newval = new Float(sq.getStockQuote()) + diff; //
auto boxing cool.
+ sq.setStockQuote(newval + "");
+ float dh = Math.max(newval, new
Float(sq.getDayHighPrice()));
+ sq.setDayHighPrice(dh + "");
+ float dl = Math.min(newval, new
Float(sq.getDayLowPrice()));
+ sq.setDayLowPrice(dl +"");
+
+ }
+ ret.put(sym, (StockQuote) sq.clone());
+ }
+
+ }
+
+ return ret;
}
-}
\ No newline at end of file
+}
Modified:
incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module
(original)
+++
incubator/tuscany/java/samples/bigbank/account/src/main/resources/sca.module
Mon May 1 18:48:00 2006
@@ -49,18 +49,20 @@
<implementation.java
class="org.apache.tuscany.samples.bigbank.account.services.accountdata.AccountDataServiceDASImpl"/>
</component>
+<!-- WebservicexService
<component name="StockQuoteServiceComponent">
<implementation.java
class="org.apache.tuscany.samples.bigbank.account.services.stockquote.StockQuoteWebservicexServiceImpl"/>
<references>
<v:stockQuoteService>StockQuoteWebService</v:stockQuoteService>
</references>
</component>
+ -->
-<!-- local
- <component name="StockQuoteServiceComponet">
+<!-- local -->
+ <component name="StockQuoteServiceComponent">
<implementation.java
class="org.apache.tuscany.samples.bigbank.account.services.stockquote.StockQuoteServiceImpl"/>
</component>
- -->
+
<externalService name="StockQuoteWebService">
<interface.wsdl
interface="http://www.webserviceX.NET/#StockQuoteSoap"/>
Modified:
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/services/account/AccountServiceComponentImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/services/account/AccountServiceComponentImpl.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/services/account/AccountServiceComponentImpl.java
(original)
+++
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/services/account/AccountServiceComponentImpl.java
Mon May 1 18:48:00 2006
@@ -89,9 +89,12 @@
}
}
- public float deposit(String param6, float param7) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
+ public float deposit(String account, float amount) throws RemoteException {
+ try {
+ return accountService.deposit(account, amount);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
}
public StockSummary purchaseStock(int param0, String param1, int param2)
throws RemoteException {
@@ -104,9 +107,12 @@
return null;
}
- public float withdraw(String param12, float param13) throws
RemoteException {
- // TODO Auto-generated method stub
- return 0;
+ public float withdraw(String account, float amount) throws RemoteException
{
+ try {
+ return accountService.withdraw(account, amount);
+ } catch (Exception e) {
+ throw new ServiceUnavailableException(e);
+ }
}
public CustomerProfileData createAccount(CustomerProfileData
customerProfile, boolean createSavings, boolean createCheckings) throws
RemoteException {
Modified:
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/account/AccountStatusTag.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/account/AccountStatusTag.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/account/AccountStatusTag.java
(original)
+++
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/account/AccountStatusTag.java
Mon May 1 18:48:00 2006
@@ -23,6 +23,7 @@
import javax.servlet.jsp.tagext.TagSupport;
import
org.apache.tuscany.samples.bigbank.webclient.services.profile.ProfileService;
+import org.apache.tuscany.samples.bigbank.webclient.tags.sca.LoginBarrierTag;
import org.osoa.sca.CurrentModuleContext;
import org.osoa.sca.ModuleContext;
Modified:
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/sca/LoginBarrierTag.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/sca/LoginBarrierTag.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/sca/LoginBarrierTag.java
(original)
+++
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/tags/sca/LoginBarrierTag.java
Mon May 1 18:48:00 2006
@@ -18,6 +18,10 @@
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;
@@ -51,6 +55,11 @@
public void setUrl(String pUrl) {
mUrl = pUrl;
}
+
+ int doPage= EVAL_PAGE;
+
+// TODO REMOVE
+// public static ProfileService hackCauseSessionAreLost= null;
public int doStartTag() throws JspException {
if (mProfile == null || mProfile.length() < 1) {
@@ -58,15 +67,23 @@
}
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;
pageContext.forward(mUrl);
+ ((HttpServletResponse)
(pageContext.getResponse())).sendRedirect("login.html");
return SKIP_BODY;
} catch (ServletException e) {
throw new JspException("Unable to forward to [" + mUrl + "]");
@@ -77,7 +94,7 @@
}
public int doEndTag() throws JspException {
- return EVAL_PAGE;
+ return doPage;
}
public void release() {
Modified:
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/FormServlet.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/FormServlet.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/FormServlet.java
(original)
+++
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/FormServlet.java
Mon May 1 18:48:00 2006
@@ -18,6 +18,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.rmi.RemoteException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -25,7 +26,6 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.PageContext;
import
org.apache.tuscany.samples.bigbank.webclient.services.account.AccountServiceComponentImpl;
import org.apache.tuscany.sdo.util.SDOUtil;
@@ -49,27 +49,54 @@
InputStream xsdInputStream =
AccountServiceComponentImpl.class.getClassLoader().getResourceAsStream("wsdl/AccountService.wsdl");
xsdHelper.define(xsdInputStream, null);
}
-
-
-
private ServletContext mContext;
-
public void init(ServletConfig pCfg) throws ServletException {
mContext = pCfg.getServletContext();
}
+
public void doPost(HttpServletRequest pReq, HttpServletResponse pResp)
throws ServletException {
-
- ModuleContext moduleContext = CurrentModuleContext.getContext();
- AccountService accountServices = (AccountService)
- moduleContext.locateService("AccountServiceComponent");
-
- if (accountServices == null) {
- throw new ServletException("AccountServiceComponent");
+
+ try {
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+ AccountService accountServices = (AccountService)
moduleContext.locateService("AccountServiceComponent");
+ if (accountServices == null) {
+ throw new ServletException("AccountServiceComponent");
+ }
+ final String action = pReq.getParameter("action");
+ if ("createAccount".equals(action)) {
+ createAccount(pReq, pResp, accountServices);
+ } else if ("account".equals(action)) {
+ accountTransaction(pReq, pResp, accountServices);
+ }
+ // mContext.getRequestDispatcher("summary.jsp").forward(pReq,
pResp);
+ pResp.sendRedirect("summary.jsp");
+ } catch (ServletException e) {
+ e.printStackTrace();
+ throw e;
+
+ } catch(Exception e){
+ e.printStackTrace();
+ throw new ServletException(e);
}
+
+ }
+
+ private void accountTransaction(HttpServletRequest req,
HttpServletResponse resp, AccountService accountServices) throws
NumberFormatException, RemoteException {
+ String account = req.getParameter("account");
+ String amount = req.getParameter("Amount");
+
+ if("deposit".equals(req.getParameter("actionType")))
+ accountServices.deposit(account, Float.parseFloat(amount));
+ else
+ accountServices.withdraw(account, Float.parseFloat(amount));
+
+ }
+
+ private void createAccount(HttpServletRequest pReq, HttpServletResponse
pResp, AccountService accountServices) throws ServletException {
try {
CustomerProfileData customerProfileData =
AccountFactory.eINSTANCE.createCustomerProfileData();
customerProfileData.setFirstName(pReq.getParameter("firstName"));
@@ -80,15 +107,12 @@
customerProfileData.setPassword(pReq.getParameter("password"));
- CustomerProfileData resp =
accountServices.createAccount(customerProfileData,
"savings".equals(pReq.getParameter("savings")) ,
"checkings".equals(pReq.getParameter("checkings")));
- System.err.println(resp.getId());
-// if (resp == LoginService.SUCCESS) {
-// mContext.getRequestDispatcher("/summary.jsp").forward(pReq,
pResp);
-// } else {
-// mContext.getRequestDispatcher("/login.html").forward(pReq,
pResp);
-// }
+ 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/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/LoginServlet.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/LoginServlet.java?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/LoginServlet.java
(original)
+++
incubator/tuscany/java/samples/bigbank/webclient/src/main/java/org/apache/tuscany/samples/bigbank/webclient/ui/LoginServlet.java
Mon May 1 18:48:00 2006
@@ -17,6 +17,7 @@
package org.apache.tuscany.samples.bigbank.webclient.ui;
import java.io.IOException;
+import java.rmi.RemoteException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -24,6 +25,7 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import
org.apache.tuscany.samples.bigbank.webclient.services.profile.LoginService;
import org.osoa.sca.CurrentModuleContext;
@@ -41,29 +43,68 @@
}
public void doPost(HttpServletRequest pReq, HttpServletResponse pResp)
throws ServletException {
+
+ if("logout".equals(pReq.getParameter("logout"))){
+ HttpSession sess = pReq.getSession();
+ if(sess != null) sess.invalidate();
+ try {
+ pResp.sendRedirect("login.html");
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ throw new ServletException(e);
+ }
+
+ }else{
- ModuleContext moduleContext = CurrentModuleContext.getContext();
- LoginService loginMgr = (LoginService)
- moduleContext.locateService("LoginServiceComponent");
-
- if (loginMgr == null) {
- throw new ServletException("LoginManager not found");
- }
+// ModuleContext moduleContext = CurrentModuleContext.getContext();
+// LoginService loginMgr = (LoginService)
+// moduleContext.locateService("LoginServiceComponent");
+//
+// if (loginMgr == null) {
+// throw new ServletException("LoginManager not found");
+// }
String login = pReq.getParameter("login");
String password = pReq.getParameter("password");
try {
- if (login == null || password == null) {
- pResp.sendRedirect("summary.jsp");
- }
- int resp = loginMgr.login(login, password);
+// if (login == null || password == null) {
+// pResp.sendRedirect("/summary.jsp");
+// }
+ int resp = login(login, password);
if (resp == LoginService.SUCCESS) {
- mContext.getRequestDispatcher("/summary.jsp").forward(pReq,
pResp);
+ // mContext.getRequestDispatcher("/summary.jsp").forward(pReq,
pResp);
+ pResp.sendRedirect("summary.jsp");
} else {
- mContext.getRequestDispatcher("/login.html").forward(pReq,
pResp);
+ // mContext.getRequestDispatcher("/login.html").forward(pReq,
pResp);
+ pResp.sendRedirect("login.html");
}
} catch (IOException e) {
throw new ServletException(e);
}
}
-}
+ }
+ static int login(final String login, final String password) throws
ServletException{
+
+
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+ LoginService loginMgr = (LoginService)
+ moduleContext.locateService("LoginServiceComponent");
+
+ if (loginMgr == null) {
+ throw new ServletException("LoginManager not found");
+ }
+
+// if (login == null || password == null) {
+// pResp.sendRedirect("/summary.jsp");
+// }
+ try {
+ return loginMgr.login(login, password);
+ } catch (RemoteException e) {
+
+ throw new ServletException(e);
+ }
+
+ }
+
+ }
Modified:
incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/CustomerProfile.jsp
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/CustomerProfile.jsp?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/CustomerProfile.jsp
(original)
+++
incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/CustomerProfile.jsp
Mon May 1 18:48:00 2006
@@ -27,7 +27,8 @@
<BODY><P><FONT size="+1">Customer Account</FONT><BR>
<BR>
</P>
-<FORM method="post" action="FormServlet/createAccount">
+<FORM method="post" action="FormServlet">
+<input type="hidden" name="action" value='createAccount' />
<TABLE border="0">
<TBODY>
<TR>
Modified:
incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/summary.jsp
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/summary.jsp?rev=398769&r1=398768&r2=398769&view=diff
==============================================================================
---
incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/summary.jsp
(original)
+++
incubator/tuscany/java/samples/bigbank/webclient/src/main/webapp/summary.jsp
Mon May 1 18:48:00 2006
@@ -15,6 +15,8 @@
--%>
<%@ page import="com.bigbank.account.AccountSummary" %>
+ <%@ page session="true" %>
+ <%@ page autoFlush="true" %>
<%@ taglib uri="/WEB-INF/bigbank-tags.tld" prefix="sca" %>
<sca:login profile="ProfileServiceComponent" url="login.html">
<sca:service id="profile" name="ProfileServiceComponent"/>
@@ -25,9 +27,12 @@
<body>
Account Information for
+ <FORM method="post" action='loginAction'>
<jsp:getProperty name='profile' property='firstName'/>
<jsp:getProperty name='profile' property='lastName'/>
+ <INPUT type="submit" name='logout' value="logout">
<br>
+ </FORM>
<table>
<tr>
@@ -51,10 +56,10 @@
</td>
<td>
- <INPUT type="submit" name='deposit' value="deposit">
+ <INPUT type="submit" name='transaction' value="deposit">
</td>
<td>
- <INPUT type="submit" name='withdraw' value="withdraw">
+ <INPUT type="submit" name='transaction' value="withdraw">
</td>
</FORM>
</tr>
@@ -64,7 +69,7 @@
<hr/>
- Strocks:<br/>
+ Stocks:<br/>
<table>
<tr>
<td><strong>Symbol</strong></td>