You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/06/25 10:18:49 UTC

svn commit: r550410 - in /incubator/tuscany/java/sca/samples: ./ simple-bigbank/ simple-bigbank/src/main/java/bigbank/account/ simple-bigbank/src/main/java/bigbank/accountdata/ simple-bigbank/src/main/java/bigbank/stockquote/ simple-bigbank/src/main/re...

Author: jsdelfino
Date: Mon Jun 25 01:18:47 2007
New Revision: 550410

URL: http://svn.apache.org/viewvc?view=rev&rev=550410
Log:
Minor fixes and improvements to the simple-bigbank sample to make it more interesting (using nested composition) to implement using Spring.

Added:
    incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/
    incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java   (with props)
    incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java   (with props)
    incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/Account.composite   (with props)
    incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/StockQuote.composite   (with props)
Modified:
    incubator/tuscany/java/sca/samples/pom.xml
    incubator/tuscany/java/sca/samples/simple-bigbank/README
    incubator/tuscany/java/sca/samples/simple-bigbank/pom.xml
    incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java
    incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java
    incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/BigBank.composite

Modified: incubator/tuscany/java/sca/samples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/pom.xml?view=diff&rev=550410&r1=550409&r2=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/pom.xml (original)
+++ incubator/tuscany/java/sca/samples/pom.xml Mon Jun 25 01:18:47 2007
@@ -64,6 +64,9 @@
                 -->
                 <module>simple-bigbank</module>
                 <module>simple-callback</module>
+                <!--
+                <module>spring-bigbank</module>
+                -->
                 <module>supplychain</module>
                 <module>web-resource</module>
             </modules>

Modified: incubator/tuscany/java/sca/samples/simple-bigbank/README
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/README?view=diff&rev=550410&r1=550409&r2=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/README (original)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/README Mon Jun 25 01:18:47 2007
@@ -39,7 +39,9 @@
                                     deploys the BigBank.composite. 
                                     It then calls the deployed AccountService 
       resources/
-        BigBank.composite         - the SCA assembly for this sample
+        Account.composite         - SCA assembly for this sample
+        BigBank.composite         - SCA assembly for this sample
+        StockQuote.composite      - SCA assembly for this sample
     test/
       java/
         bigbank/
@@ -79,7 +81,7 @@
 -------------------------------------------------------
 Running bigbank.BigBankTestCase
 Account summary: currency: USD, [ID:Foo_CHA12345, balance:1500.0, ID:Foo_SAA1234
-5, balance:1500.0, ID:Foo_STA12345, symbol:IBM, quantity:100]
+5, balance:1500.0, ID:Foo_STA12345, symbol:IBM, quantity:100, balance:10432.0]]
 Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.592 sec
 
 Results :

Modified: incubator/tuscany/java/sca/samples/simple-bigbank/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/pom.xml?view=diff&rev=550410&r1=550409&r2=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/pom.xml (original)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/pom.xml Mon Jun 25 01:18:47 2007
@@ -50,12 +50,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-core-databinding</artifactId>
-            <version>1.0-incubating-SNAPSHOT</version>
-        </dependency>
-                
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>4.2</version>

Modified: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java?view=diff&rev=550410&r1=550409&r2=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java (original)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java Mon Jun 25 01:18:47 2007
@@ -29,6 +29,7 @@
 import bigbank.accountdata.CheckingAccount;
 import bigbank.accountdata.SavingsAccount;
 import bigbank.accountdata.StockAccount;
+import bigbank.stockquote.StockQuoteService;
 
 /**
  * Account service implementation
@@ -39,6 +40,9 @@
     @Reference
     public AccountDataService accountDataService;
     
+    @Reference
+    public StockQuoteService stockQuoteService;
+    
     @Property
     public String currency;
 
@@ -52,6 +56,10 @@
         summaries.add(sa.getSummary());
 
         StockAccount sk = accountDataService.getStockAccount(s);
+        
+        double price = stockQuoteService.getQuote(sk.getSymbol());
+        sk.setBalance(sk.getQuantity() * price);
+        
         summaries.add(sk.getSummary());
 
         AccountReport report = new AccountReport(currency, summaries);

Modified: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java?view=diff&rev=550410&r1=550409&r2=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java (original)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java Mon Jun 25 01:18:47 2007
@@ -25,6 +25,7 @@
     private String accountNumber;
     private String symbol;
     private int quantity;
+    private double balance;
 
     public String getAccountNumber() { return accountNumber; }
     public void setAccountNumber(String n) { this.accountNumber = n; }
@@ -34,6 +35,9 @@
 
     public String getSymbol() { return symbol; }
     public void setSymbol(String s) { this.symbol = s; }
+    
+    public double getBalance() { return balance; }
+    public void setBalance(double balance) { this.balance = balance; }
 
-    public String getSummary() { return "ID:" + accountNumber + ", symbol:" + symbol + ", quantity:" + quantity; }
+    public String getSummary() { return "ID:" + accountNumber + ", symbol:" + symbol + ", quantity:" + quantity + ", balance:" + balance; }
 }

Added: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java?view=auto&rev=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java (added)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java Mon Jun 25 01:18:47 2007
@@ -0,0 +1,38 @@
+/*
+ * 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.stockquote;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the StockQuote service.
+ */
+@Service(StockQuoteService.class)
+public class StockQuoteImpl implements StockQuoteService {
+
+    public double getQuote(String symbol) {
+        double price = 104.0 + Math.random();
+        price = ((int)(price * 100)) / 100.0;
+
+        System.out.println("Getting stock quote for: " + symbol + ", value: "+ price);
+
+        return price;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java?view=auto&rev=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java (added)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java Mon Jun 25 01:18:47 2007
@@ -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.stockquote;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This is the business interface of the StockQuote service.
+ */
+@Remotable
+@Service
+public interface StockQuoteService {
+
+    public double getQuote(String symbol);
+}
+

Propchange: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/Account.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/Account.composite?view=auto&rev=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/Account.composite (added)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/Account.composite Mon Jun 25 01:18:47 2007
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	targetNamespace="http://account"
+	name="Account">
+           
+    <service name="AccountService" promote="AccountServiceComponent"/>
+
+    <component name="AccountServiceComponent">
+        <implementation.java class="bigbank.account.AccountServiceImpl"/>
+        <reference name="accountDataService" target="AccountDataServiceComponent"/>
+        <property name="currency">USD</property>
+    </component>
+
+    <component name="AccountDataServiceComponent">
+        <implementation.java class="bigbank.accountdata.AccountDataServiceImpl"/>
+    </component>
+    
+    <reference name="stockQuoteService" promote="AccountServiceComponent/stockQuoteService"/>
+
+</composite>

Propchange: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/Account.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/Account.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/BigBank.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/BigBank.composite?view=diff&rev=550410&r1=550409&r2=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/BigBank.composite (original)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/BigBank.composite Mon Jun 25 01:18:47 2007
@@ -18,16 +18,18 @@
  * under the License.    
 -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-           name="BigBank">
+	targetNamespace="http://bigbank"
+	xmlns:a="http://account"
+	xmlns:s="http://stockquote"
+	name="BigBank">
 
     <component name="AccountServiceComponent">
-        <implementation.java class="bigbank.account.AccountServiceImpl"/>
-        <reference name="accountDataService" target="AccountDataServiceComponent"/>
-        <property name="currency">USD</property>
+        <implementation.composite name="a:Account"/>
+        <reference name="stockQuoteService" target="StockQuoteServiceComponent"/>
     </component>
 
-    <component name="AccountDataServiceComponent">
-        <implementation.java class="bigbank.accountdata.AccountDataServiceImpl"/>
+    <component name="StockQuoteServiceComponent">
+        <implementation.composite name="s:StockQuote"/>
     </component>
 
 </composite>

Added: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/StockQuote.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/StockQuote.composite?view=auto&rev=550410
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/StockQuote.composite (added)
+++ incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/StockQuote.composite Mon Jun 25 01:18:47 2007
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	targetNamespace="http://stockquote"
+    name="StockQuote">
+
+    <service name="StockQuoteService" promote="StockQuoteServiceComponent"/>
+
+    <component name="StockQuoteServiceComponent">
+        <implementation.java class="bigbank.stockquote.StockQuoteImpl" />
+    </component>
+
+</composite>

Propchange: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/StockQuote.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/simple-bigbank/src/main/resources/StockQuote.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org