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/10/25 20:06:37 UTC
svn commit: r588297 - in /incubator/tuscany/java/sca/tutorial:
store-catalog/src/main/java/launch/ store-catalog/src/main/java/services/
store-catalog/src/main/resources/ store-domain/src/main/java/launch/
store/src/main/java/launch/ store/src/main/jav...
Author: jsdelfino
Date: Thu Oct 25 11:06:35 2007
New Revision: 588297
URL: http://svn.apache.org/viewvc?rev=588297&view=rev
Log:
Making progress with the tutorial. Now able to run the store and an external catalog on different SCA nodes.
Added:
incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalog.java (with props)
incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalogImpl.java
- copied, changed from r588055, incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/CatalogImpl.java
incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/LaunchStore.java
- copied, changed from r587995, incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/Launch.java
incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/
incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/NewCatalogImpl.java (with props)
incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/VegetablesCatalog.java (with props)
incubator/tuscany/java/sca/tutorial/store/src/main/resources/merger/
incubator/tuscany/java/sca/tutorial/store/src/main/resources/merger/new-catalog.composite (with props)
Removed:
incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/Catalog.java
incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/CatalogImpl.java
incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/Launch.java
Modified:
incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/launch/LaunchCatalog.java
incubator/tuscany/java/sca/tutorial/store-catalog/src/main/resources/store-catalog.composite
incubator/tuscany/java/sca/tutorial/store-domain/src/main/java/launch/LaunchDomain.java
incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CatalogImpl.java
incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverter.java
incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverterImpl.java
incubator/tuscany/java/sca/tutorial/store/src/main/resources/store.composite
incubator/tuscany/java/sca/tutorial/store/src/main/resources/uiservices/store.html
Modified: incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/launch/LaunchCatalog.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/launch/LaunchCatalog.java?rev=588297&r1=588296&r2=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/launch/LaunchCatalog.java (original)
+++ incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/launch/LaunchCatalog.java Thu Oct 25 11:06:35 2007
@@ -19,16 +19,32 @@
package launch;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.util.SCAContributionUtil;
public class LaunchCatalog {
public static void main(String[] args) throws Exception {
System.out.println("Starting ...");
- SCADomain scaDomain = SCADomain.newInstance("store-catalog.composite");
- System.out.println("store-catalog.composite ready for big business !!!");
+ SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+ SCANode node = nodeFactory.createSCANode("http://localhost:8200/store", "http://localhost:9999");
+
+ URL contribution = SCAContributionUtil.findContributionFromClass(LaunchCatalog.class);
+ node.addContribution("http://store-catalog", contribution);
+
+ node.addToDomainLevelComposite(new QName("http://store", "store-catalog"));
+ node.start();
+
+ System.out.println("store.composite ready for big business !!!");
System.in.read();
+
System.out.println("Stopping ...");
- scaDomain.close();
+ node.stop();
+ node.destroy();
System.out.println();
}
}
Added: incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalog.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalog.java?rev=588297&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalog.java (added)
+++ incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalog.java Thu Oct 25 11:06:35 2007
@@ -0,0 +1,29 @@
+/*
+ * 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 services;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface VegetablesCatalog {
+
+ String[] get();
+
+}
Propchange: incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalog.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalog.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalogImpl.java (from r588055, incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/CatalogImpl.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalogImpl.java?p2=incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalogImpl.java&p1=incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/CatalogImpl.java&r1=588055&r2=588297&rev=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/CatalogImpl.java (original)
+++ incubator/tuscany/java/sca/tutorial/store-catalog/src/main/java/services/VegetablesCatalogImpl.java Thu Oct 25 11:06:35 2007
@@ -24,17 +24,19 @@
import org.osoa.sca.annotations.Init;
-public class CatalogImpl implements Catalog {
+public class VegetablesCatalogImpl implements VegetablesCatalog {
private List<String> catalog = new ArrayList<String>();
@Init
public void init() {
- catalog.add("Broccoli - " + 2.99f);
- catalog.add("Asparagus - " + 3.55f);
- catalog.add("Cauliflower - " + 1.55f);
+ catalog.add("Broccoli" + " - " + 2.99);
+ catalog.add("Asparagus" + " - " + 3.55);
+ catalog.add("Cauliflower" + " - " + 1.55);
}
- public List<String> get() {
- return catalog;
+ public String[] get() {
+ String[] catalogArray = new String[catalog.size()];
+ catalog.toArray(catalogArray);
+ return catalogArray;
}
}
Modified: incubator/tuscany/java/sca/tutorial/store-catalog/src/main/resources/store-catalog.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-catalog/src/main/resources/store-catalog.composite?rev=588297&r1=588296&r2=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-catalog/src/main/resources/store-catalog.composite (original)
+++ incubator/tuscany/java/sca/tutorial/store-catalog/src/main/resources/store-catalog.composite Thu Oct 25 11:06:35 2007
@@ -22,11 +22,8 @@
targetNamespace="http://store"
name="store-catalog">
- <component name="Catalog">
- <implementation.java class="services.CatalogImpl"/>
- <service name="Catalog">
- <binding.ws/>
- </service>
+ <component name="VegetablesCatalog">
+ <implementation.java class="services.VegetablesCatalogImpl"/>
</component>
</composite>
Modified: incubator/tuscany/java/sca/tutorial/store-domain/src/main/java/launch/LaunchDomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-domain/src/main/java/launch/LaunchDomain.java?rev=588297&r1=588296&r2=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-domain/src/main/java/launch/LaunchDomain.java (original)
+++ incubator/tuscany/java/sca/tutorial/store-domain/src/main/java/launch/LaunchDomain.java Thu Oct 25 11:06:35 2007
@@ -28,7 +28,7 @@
System.out.println("Starting ...");
SCADomainFactory domainFactory = SCADomainFactory.newInstance();
- SCADomain domain = domainFactory.createSCADomain("http://localhost:8877");
+ SCADomain domain = domainFactory.createSCADomain("http://localhost:9999");
System.out.println("store domain controller ready for big business !!!");
System.in.read();
Copied: incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/LaunchStore.java (from r587995, incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/Launch.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/LaunchStore.java?p2=incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/LaunchStore.java&p1=incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/Launch.java&r1=587995&r2=588297&rev=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/Launch.java (original)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/java/launch/LaunchStore.java Thu Oct 25 11:06:35 2007
@@ -27,13 +27,13 @@
import org.apache.tuscany.sca.node.SCANodeFactory;
import org.apache.tuscany.sca.node.util.SCAContributionUtil;
-public class Launch {
+public class LaunchStore {
public static void main(String[] args) throws Exception {
System.out.println("Starting ...");
SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
- SCANode node = nodeFactory.createSCANode("http://localhost:8086/store", "http://localhost:8877");
+ SCANode node = nodeFactory.createSCANode("http://localhost:8100/store", "http://localhost:9999");
- URL contribution = SCAContributionUtil.findContributionFromClass(Launch.class);
+ URL contribution = SCAContributionUtil.findContributionFromClass(LaunchStore.class);
node.addContribution("http://store", contribution);
node.addToDomainLevelComposite(new QName("http://store", "store"));
@@ -46,6 +46,5 @@
node.stop();
node.destroy();
System.out.println();
-
}
}
Modified: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CatalogImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CatalogImpl.java?rev=588297&r1=588296&r2=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CatalogImpl.java (original)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CatalogImpl.java Thu Oct 25 11:06:35 2007
@@ -27,18 +27,21 @@
import org.osoa.sca.annotations.Reference;
public class CatalogImpl implements Catalog {
+
@Property
public String currencyCode = "USD";
+
@Reference
public CurrencyConverter currencyConverter;
+
private List<String> catalog = new ArrayList<String>();
@Init
public void init() {
String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
- catalog.add("Apple - " + currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99f));
- catalog.add("Orange - " + currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55f));
- catalog.add("Pear - " + currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55f));
+ catalog.add("Apple - " + currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99));
+ catalog.add("Orange - " + currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55));
+ catalog.add("Pear - " + currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55));
}
public String[] get() {
Modified: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverter.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverter.java?rev=588297&r1=588296&r2=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverter.java (original)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverter.java Thu Oct 25 11:06:35 2007
@@ -23,7 +23,7 @@
@Remotable
public interface CurrencyConverter {
- public float getConversion(String fromCurrenycCode, String toCurrencyCode, float amount);
+ public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount);
public String getCurrencySymbol(String currencyCode);
}
Modified: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverterImpl.java?rev=588297&r1=588296&r2=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverterImpl.java (original)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/java/services/CurrencyConverterImpl.java Thu Oct 25 11:06:35 2007
@@ -20,11 +20,11 @@
package services;
public class CurrencyConverterImpl implements CurrencyConverter {
- public float getConversion(String fromCurrencyCode, String toCurrencyCode, float amount) {
+ public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) {
if (toCurrencyCode.equals("USD"))
return amount;
else if (toCurrencyCode.equals("EUR"))
- return amount * 0.7256f;
+ return amount * 0.7256;
return 0;
}
Added: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/NewCatalogImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/NewCatalogImpl.java?rev=588297&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/NewCatalogImpl.java (added)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/NewCatalogImpl.java Thu Oct 25 11:06:35 2007
@@ -0,0 +1,50 @@
+/*
+ * 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 services.merger;
+
+import org.osoa.sca.annotations.Reference;
+
+import services.Catalog;
+
+public class NewCatalogImpl implements Catalog {
+
+ @Reference
+ public Catalog fruitsCatalog;
+
+ @Reference
+ public VegetablesCatalog vegetablesCatalog;
+
+ public String[] get() {
+ String[] fruits = fruitsCatalog.get();
+ String[] vegetables = vegetablesCatalog.get();
+
+ String[] catalog = new String[fruits.length + vegetables.length];
+ int i =0;
+ for (String fruit: fruits) {
+ catalog[i++] = fruit;
+ }
+ for (String vegetable: vegetables) {
+ catalog[i++] = vegetable;
+ }
+
+ return catalog;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/NewCatalogImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/NewCatalogImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/VegetablesCatalog.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/VegetablesCatalog.java?rev=588297&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/VegetablesCatalog.java (added)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/VegetablesCatalog.java Thu Oct 25 11:06:35 2007
@@ -0,0 +1,29 @@
+/*
+ * 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 services.merger;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface VegetablesCatalog {
+
+ String[] get();
+
+}
Propchange: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/VegetablesCatalog.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/tutorial/store/src/main/java/services/merger/VegetablesCatalog.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/tutorial/store/src/main/resources/merger/new-catalog.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/resources/merger/new-catalog.composite?rev=588297&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/resources/merger/new-catalog.composite (added)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/resources/merger/new-catalog.composite Thu Oct 25 11:06:35 2007
@@ -0,0 +1,35 @@
+<?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"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://store"
+ name="new-catalog">
+
+ <component name="NewCatalog">
+ <implementation.java class="services.merger.NewCatalogImpl"/>
+ <service name="Catalog">
+ <t:binding.jsonrpc/>
+ <binding.ws uri="healthyFood"/>
+ </service>
+ <reference name="fruitsCatalog" target="Catalog"/>
+ <reference name="vegetablesCatalog" target="VegetablesCatalog"/>
+ </component>
+
+</composite>
Propchange: incubator/tuscany/java/sca/tutorial/store/src/main/resources/merger/new-catalog.composite
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/tutorial/store/src/main/resources/store.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/resources/store.composite?rev=588297&r1=588296&r2=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/resources/store.composite (original)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/resources/store.composite Thu Oct 25 11:06:35 2007
@@ -19,8 +19,11 @@
-->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
- targetNamespace="http://store"
- name="store">
+ targetNamespace="http://store"
+ xmlns:s="http://store"
+ name="store">
+
+ <include name="s:new-catalog"/>
<component name="ui">
<t:implementation.resource location="uiservices"/>
@@ -33,7 +36,8 @@
<implementation.java class="services.CatalogImpl"/>
<property name="currencyCode">USD</property>
<service name="Catalog">
- <t:binding.jsonrpc/>
+ <binding.sca/>
+ <t:binding.jsonrpc/>
</service>
<reference name="currencyConverter" target="CurrencyConverter"/>
</component>
Modified: incubator/tuscany/java/sca/tutorial/store/src/main/resources/uiservices/store.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/src/main/resources/uiservices/store.html?rev=588297&r1=588296&r2=588297&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/src/main/resources/uiservices/store.html (original)
+++ incubator/tuscany/java/sca/tutorial/store/src/main/resources/uiservices/store.html Thu Oct 25 11:06:35 2007
@@ -25,7 +25,7 @@
<script language="JavaScript">
//Reference
- catalog = (new JSONRpcClient("../Catalog")).Catalog;
+ catalog = (new JSONRpcClient("../NewCatalog")).Catalog;
//Reference
shoppingCart = new AtomClient("../ShoppingCart");
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org