diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:09:08 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:09:08 +0000 |
commit | cde3d2629677a07aa09e3c7fbe117b680c0f5df7 (patch) | |
tree | c6d50048ffad8dfa8a1c0019e7afb207cb6b4fe2 /sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account | |
parent | 4ef0430519e276c2bdecea75f7a0f42f49f0cf30 (diff) |
Moving 2.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835133 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account')
12 files changed, 657 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java new file mode 100644 index 0000000000..1625ff5b65 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import java.util.List; + +/** + */ +public class AccountReport { + private List<String> summaries; + private String currency; + + public AccountReport(String currency, List<String> summaries) { + this.currency = currency; + this.summaries = summaries; + } + + public List getAccountSummaries() { return summaries; } + + public String getCurrency() { return currency; } + + @Override + public String toString() { + return "currency: "+ currency + ", " + summaries; + } + +} diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java new file mode 100644 index 0000000000..7c9082b944 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +/** + * Interface for a account service + */ +public interface AccountService { + public AccountReport getAccountReport(String customerID); +} diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..ce41006fa6 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import java.util.ArrayList; +import java.util.List; + +import org.osoa.sca.annotations.Service; + +import bigbank.account.checking.CheckingAccountDetails; +import bigbank.account.checking.CheckingAccountService; +import bigbank.account.savings.SavingsAccountDetails; +import bigbank.account.savings.SavingsAccountService; +import bigbank.account.stock.StockAccountDetails; +import bigbank.account.stock.StockAccountService; +import bigbank.stockquote.StockQuoteService; +import bigbank.calculator.CalculatorService; + +/** + * Account service implementation + */ +@Service(AccountService.class) +public class AccountServiceImpl implements AccountService { + + private SavingsAccountService savingsAccountService; + + private CheckingAccountService checkingAccountService; + + private StockAccountService stockAccountService; + + private CalculatorService calculatorService; + + private StockQuoteService stockQuoteService; + + private String currency; + + public AccountReport getAccountReport(String customerID) { + + // Get the checking, savings and stock accounts from the AccountData + // service component + CheckingAccountDetails checking = null; + List<String> summaries = new ArrayList<String>(); + try { + checking = checkingAccountService.getAccountDetails(customerID); + System.out.println("Checking account: " + checking); + summaries.add(checking.toString()); + + SavingsAccountDetails savings = savingsAccountService.getAccountDetails(customerID); + System.out.println("Savings account: " + savings); + summaries.add(savings.toString()); + + StockAccountDetails stock = stockAccountService.getAccountDetails(customerID); + System.out.println("Stock account: " + stock); + summaries.add(stock.toString()); + + // Get the stock price in USD + double price = stockQuoteService.getQuote(stock.getSymbol()); + System.out.println("Stock price for " + stock.getSymbol() + ": " + price); + + // Convert to the configured currency + if (currency.equals("EURO")) { + + // Use our fancy calculator service to convert to the target currency + price = calculatorService.multiply(price, 0.70); + + System.out.println("Converted to " + currency + ": " + price); + } + + // Calculate the value of the stock account + double stockValue = price * stock.getQuantity(); + summaries.add(stock.toString()); + + AccountReport report = new AccountReport(currency, summaries); + + return report; + } catch ( Throwable e ) { + e.printStackTrace(); + return null; + } + } + + public SavingsAccountService getSavingsAccountService() { + return savingsAccountService; + } + + public void setSavingsAccountService(SavingsAccountService savingsAccountService) { + this.savingsAccountService = savingsAccountService; + } + + public CheckingAccountService getCheckingAccountService() { + return checkingAccountService; + } + + public void setCheckingAccountService(CheckingAccountService checkingAccountService) { + this.checkingAccountService = checkingAccountService; + } + + public StockAccountService getStockAccountService() { + return stockAccountService; + } + + public void setStockAccountService(StockAccountService stockAccountService) { + this.stockAccountService = stockAccountService; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public CalculatorService getCalculatorService() { + return calculatorService; + } + + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + public StockQuoteService getStockQuoteService() { + return stockQuoteService; + } + + public void setStockQuoteService(StockQuoteService stockQuoteService) { + this.stockQuoteService = stockQuoteService; + } +} diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.java new file mode 100644 index 0000000000..3f81f48fb9 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.java @@ -0,0 +1,45 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.checking;
+
+public class CheckingAccountDetails {
+ private String accountNumber;
+ private double balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(double b) {
+ this.balance = b;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", balance:" + balance;
+ }
+}
diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.java new file mode 100644 index 0000000000..2b52909bc1 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.java @@ -0,0 +1,34 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.checking;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+@Service
+@Remotable
+public interface CheckingAccountService {
+
+ public CheckingAccountDetails getAccountDetails(String customerID);
+
+ public double deposit(String accountNo, double depositAmt);
+
+ public double withdraw(String accountNo, double withdrawalAmount);
+
+}
diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java new file mode 100644 index 0000000000..386f7bb90d --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.feed; + +import org.apache.tuscany.sca.data.collection.Collection; +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import bigbank.account.AccountService; +import bigbank.account.AccountReport; + +/** + * @version $$Rev$$ $$Date$$ + */ + +@Service(Collection.class) +public class AccountFeedImpl implements Collection<String, String> { + + @Reference + protected AccountService accountService; + + public Entry<String, String>[] getAll() { + + // Add the Account report entry + String report = get("1234"); + Entry<String, String> entry = new Entry<String, String>("1234", report); + + return new Entry[] { entry } ; + } + + public String get(String id) { + + // Get the account report for the specified customer ID + AccountReport accreport = accountService.getAccountReport(id); + String report = accreport.getCurrency(); + + return report; + } + + public void delete(String key) throws NotFoundException { + } + + public String post(String key, String item) { + return null; + } + + public void put(String key, String item) throws NotFoundException { + } + + public Entry<String, String>[] query(String queryString) { + return null; + } +} diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.java new file mode 100644 index 0000000000..bcac678cd7 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.java @@ -0,0 +1,47 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.savings;
+
+import java.io.Serializable;
+
+public class SavingsAccountDetails implements Serializable {
+ private String accountNumber;
+ private double balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(double b) {
+ this.balance = b;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", balance:" + balance;
+ }
+}
diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.java new file mode 100644 index 0000000000..8a012c12f9 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.java @@ -0,0 +1,32 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.savings;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface SavingsAccountService {
+
+ public SavingsAccountDetails getAccountDetails(String customerID);
+
+ public double deposit(String accountNo, double depositAmt);
+
+ public double withdraw(String accountNo, double withdrawalAmount);
+
+}
diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java new file mode 100644 index 0000000000..980ec1c335 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java @@ -0,0 +1,62 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.savings;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Service;
+
+@Service(SavingsAccountService.class)
+public class SavingsAccountServiceImpl implements SavingsAccountService {
+ private Map<String, String> custAcctMap = new HashMap<String, String>();
+ private Map<String, Double> savingsAccts = new HashMap<String, Double>();
+
+ public SavingsAccountServiceImpl() {
+ custAcctMap.put("Customer_01", "SVA_Customer_01");
+ custAcctMap.put("Customer_02", "SVA_Customer_02");
+ custAcctMap.put("Customer_03", "SVA_Customer_03");
+
+ savingsAccts.put("SVA_Customer_01", new Double(1000));
+ savingsAccts.put("SVA_Customer_02", new Double(1500));
+ savingsAccts.put("SVA_Customer_03", new Double(2000));
+ }
+
+ public double deposit(String accountNo, double depositAmt) {
+ savingsAccts.put(accountNo, new Double(savingsAccts.get(accountNo).doubleValue() + depositAmt));
+ return savingsAccts.get(accountNo).doubleValue();
+ }
+
+ public SavingsAccountDetails getAccountDetails(String customerID) {
+ SavingsAccountDetails savingsAccount = new SavingsAccountDetails();
+ savingsAccount.setAccountNumber(custAcctMap.get(customerID));
+ savingsAccount.setBalance(savingsAccts.get(savingsAccount.getAccountNumber()).doubleValue());
+
+ return savingsAccount;
+ }
+
+ public double withdraw(String accountNo, double withdrawalAmount) {
+ double balance = savingsAccts.get(accountNo).doubleValue();
+ if ( balance - withdrawalAmount > 0 ) {
+ balance = balance - withdrawalAmount;
+ savingsAccts.put(accountNo, balance);
+ }
+ return balance;
+ }
+}
diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.java new file mode 100644 index 0000000000..9f06a71bae --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.java @@ -0,0 +1,63 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.stock;
+
+public class StockAccountDetails {
+ private String accountNumber;
+ private String symbol;
+ private int quantity;
+
+ public StockAccountDetails() {
+ }
+
+ public StockAccountDetails(String acNo, String symbol, int qty) {
+ this.accountNumber = acNo;
+ this.symbol = symbol;
+ this.quantity = qty;
+ }
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int a) {
+ this.quantity = a;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String s) {
+ this.symbol = s;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", symbol:" + symbol + ", quantity:" + quantity;
+ }
+}
diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.java new file mode 100644 index 0000000000..1ee386ba90 --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.java @@ -0,0 +1,33 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.stock;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface StockAccountService {
+
+ public StockAccountDetails getAccountDetails(String customerID);
+
+ public StockAccountDetails buy(String accountNo, String symbol, int quantity);
+
+ public StockAccountDetails sell(String accountNo, String symbol, int quantity);
+
+
+}
diff --git a/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java new file mode 100644 index 0000000000..61aea6869e --- /dev/null +++ b/sca-java-2.x/branches/sca-equinox/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java @@ -0,0 +1,56 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package bigbank.account.stock;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Service;
+
+@Service(StockAccountService.class)
+public class StockAccountServiceImpl implements StockAccountService {
+ private Map<String, String> custAcctMap = new HashMap<String, String>();
+ private Map<String, StockAccountDetails> stockAccts = new HashMap<String, StockAccountDetails>();
+
+ public StockAccountServiceImpl() {
+ custAcctMap.put("Customer_01", "STA_Customer_01");
+ custAcctMap.put("Customer_02", "STA_Customer_02");
+ custAcctMap.put("Customer_03", "STA_Customer_03");
+
+ stockAccts.put("STA_Customer_01", new StockAccountDetails("STA_Customer_01", "IBM", 100));
+ stockAccts.put("STA_Customer_02", new StockAccountDetails("STA_Customer_02", "IBM", 200));
+ stockAccts.put("STA_Customer_03", new StockAccountDetails("STA_Customer_03", "SYM_3", 125));
+ }
+
+
+ public StockAccountDetails buy(String accountNo, String symbol, int quantity) {
+ return null;
+ }
+
+ public StockAccountDetails getAccountDetails(String customerID) {
+ return stockAccts.get(custAcctMap.get(customerID));
+ }
+
+ public StockAccountDetails sell(String accountNo, String symbol, int quantity) {
+ return null;
+ }
+
+
+
+}
|