diff options
Diffstat (limited to '')
14 files changed, 275 insertions, 4 deletions
diff --git a/branches/sca-java-1.x/tutorials/store/assets/services/Order.java b/branches/sca-java-1.x/tutorials/store/assets/services/Order.java new file mode 100644 index 0000000000..07a9f9d0b0 --- /dev/null +++ b/branches/sca-java-1.x/tutorials/store/assets/services/Order.java @@ -0,0 +1,40 @@ +/* + * 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; + + +public class Order { + private Item[] items; + + public Order() { + } + + public Order(Item[] items) { + this.items = items; + } + + public Item[] getItems() { + return items; + } + + public void setItems(Item[] items) { + this.items = items; + } +} diff --git a/branches/sca-java-1.x/tutorials/store/assets/services/ShoppingCartImpl.java b/branches/sca-java-1.x/tutorials/store/assets/services/ShoppingCartImpl.java index 9889921a96..d297a8ccf1 100644 --- a/branches/sca-java-1.x/tutorials/store/assets/services/ShoppingCartImpl.java +++ b/branches/sca-java-1.x/tutorials/store/assets/services/ShoppingCartImpl.java @@ -28,6 +28,7 @@ import java.util.UUID; import org.apache.tuscany.sca.data.collection.Entry; import org.apache.tuscany.sca.data.collection.NotFoundException; import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; import org.osoa.sca.annotations.Scope; @Scope("COMPOSITE") @@ -35,6 +36,9 @@ public class ShoppingCartImpl implements Cart, Total { private Map<String, Item> cart; + @Reference(required=false) + protected Warehouse warehouse; + @Init public void init() { cart = new HashMap<String, Item>(); @@ -109,4 +113,17 @@ public class ShoppingCartImpl implements Cart, Total { } return currencySymbol + String.valueOf(total); } + + public void confirmTotal() { + if (warehouse != null){ + System.out.println("Confirm total"); + try { + Order order = new Order(cart.values().toArray(new Item[cart.values().size()])); + warehouse.addOrder(order); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + cart.clear(); + } } diff --git a/branches/sca-java-1.x/tutorials/store/assets/services/Total.java b/branches/sca-java-1.x/tutorials/store/assets/services/Total.java index 8f464e526f..b29b321e25 100644 --- a/branches/sca-java-1.x/tutorials/store/assets/services/Total.java +++ b/branches/sca-java-1.x/tutorials/store/assets/services/Total.java @@ -25,5 +25,6 @@ import org.osoa.sca.annotations.Remotable; public interface Total { String getTotal(); + void confirmTotal(); } diff --git a/branches/sca-java-1.x/tutorials/store/assets/services/Warehouse.java b/branches/sca-java-1.x/tutorials/store/assets/services/Warehouse.java new file mode 100644 index 0000000000..f04b0dd52d --- /dev/null +++ b/branches/sca-java-1.x/tutorials/store/assets/services/Warehouse.java @@ -0,0 +1,28 @@ +/* + * 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 Warehouse { + void addOrder(Order order); + Order[] getOrders(); +} diff --git a/branches/sca-java-1.x/tutorials/store/assets/services/db/ShoppingCartTableImpl.java b/branches/sca-java-1.x/tutorials/store/assets/services/db/ShoppingCartTableImpl.java index cfc52c563c..24eca045ab 100644 --- a/branches/sca-java-1.x/tutorials/store/assets/services/db/ShoppingCartTableImpl.java +++ b/branches/sca-java-1.x/tutorials/store/assets/services/db/ShoppingCartTableImpl.java @@ -168,4 +168,8 @@ public class ShoppingCartTableImpl implements Cart, Total { } return currencySymbol + total; } + + public void confirmTotal() { + + } } diff --git a/branches/sca-java-1.x/tutorials/store/assets/uiservices/store.html b/branches/sca-java-1.x/tutorials/store/assets/uiservices/store.html index dfe28bb260..5f4182972e 100644 --- a/branches/sca-java-1.x/tutorials/store/assets/uiservices/store.html +++ b/branches/sca-java-1.x/tutorials/store/assets/uiservices/store.html @@ -51,6 +51,7 @@ } function shoppingCart_getResponse(feed) { + document.getElementById("shoppingCart").innerHTML = ""; if (feed != null) { var entries = feed.getElementsByTagName("entry"); var list = ""; @@ -99,25 +100,48 @@ } } function checkoutCart() { + var cartHtml = document.getElementById('shoppingCart').innerHTML; + var totalHtml = document.getElementById('total').innerHTML; + + document.getElementById('shoppingCart').innerHTML = ""; + document.getElementById('total').innerHTML = ""; + document.getElementById('store').innerHTML='<h2>' + 'Thanks for Shopping With Us!</h2>'+ '<h2>Your Order</h2>'+ '<form name="orderForm">'+ - document.getElementById('shoppingCart').innerHTML+ + cartHtml + '<br>'+ - document.getElementById('total').innerHTML+ + totalHtml + '<br>'+ '<br>'+ - '<input type="submit" value="Continue Shopping">'+ + '<input type="submit" value="Place Order" onClick="confirmTotal()">'+ '</form>'; - shoppingCart.del("", null); } + function deleteCart() { shoppingCart.del("", null); document.getElementById('shoppingCart').innerHTML = ""; document.getElementById('total').innerHTML = ""; } + function confirmTotal() { + try { + shoppingTotal.confirmTotal(shoppingTotal_confirmTotalResponse); + alert("Order dispatched to warehouse"); + } + catch(e) { + alert(e); + } + } + + function shoppingTotal_confirmTotalResponse(exception) { + if(exception){ + alert(exception.message); + return; + } + } + function init() { try { catalog.get(catalog_getResponse); diff --git a/branches/sca-java-1.x/tutorials/store/domain/cloud.composite b/branches/sca-java-1.x/tutorials/store/domain/cloud.composite index c01653adb7..ea0ff1e637 100644 --- a/branches/sca-java-1.x/tutorials/store/domain/cloud.composite +++ b/branches/sca-java-1.x/tutorials/store/domain/cloud.composite @@ -28,6 +28,7 @@ <include name="ns2:StoreDBNode" uri="http://tuscany.apache.org/cloud" xmlns:ns2="http://tuscany.apache.org/cloud"/> <include name="ns2:StoreSupplierNode" uri="http://tuscany.apache.org/cloud" xmlns:ns2="http://tuscany.apache.org/cloud"/> <include name="ns2:StoreEUNode" uri="http://tuscany.apache.org/cloud" xmlns:ns2="http://tuscany.apache.org/cloud"/> + <include name="ns2:StoreEnterpriseNode" uri="http://tuscany.apache.org/cloud" xmlns:ns2="http://tuscany.apache.org/cloud"/> <!--include name="ns2:StoreMashupNode" uri="http://tuscany.apache.org/cloud" xmlns:ns2="http://tuscany.apache.org/cloud"/--> <!--include name="ns2:StoreMarketNode" uri="http://tuscany.apache.org/cloud" xmlns:ns2="http://tuscany.apache.org/cloud"/--> <!--include name="ns2:CatalogWebAppNode" uri="http://tuscany.apache.org/cloud" xmlns:ns2="http://tuscany.apache.org/cloud"/--> diff --git a/branches/sca-java-1.x/tutorials/store/domain/cloud/StoreEnterpriseNode.composite b/branches/sca-java-1.x/tutorials/store/domain/cloud/StoreEnterpriseNode.composite new file mode 100644 index 0000000000..e4cc62a8c3 --- /dev/null +++ b/branches/sca-java-1.x/tutorials/store/domain/cloud/StoreEnterpriseNode.composite @@ -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://tuscany.apache.org/cloud" + xmlns:s="http://store" + name="StoreEnterpriseNode"> + + <component name="StoreEnterpriseNode"> + <t:implementation.node uri="store-enterprise" composite="s:store-enterprise"/> + <service name="Node"> + <t:binding.http uri="http://localhost:8108"/> + <t:binding.jsonrpc uri="http://localhost:8108"/> + <t:binding.atom uri="http://localhost:8108"/> + </service> + </component> + +</composite> diff --git a/branches/sca-java-1.x/tutorials/store/domain/domain.composite b/branches/sca-java-1.x/tutorials/store/domain/domain.composite index aa56546ab7..6d883b84b8 100644 --- a/branches/sca-java-1.x/tutorials/store/domain/domain.composite +++ b/branches/sca-java-1.x/tutorials/store/domain/domain.composite @@ -30,6 +30,7 @@ <!-- include name="ns2:store-mashup" uri="store-mashup" xmlns:ns2="http://store"/--> <include name="ns2:catalogs" uri="web-services" xmlns:ns2="http://services"/> <include name="ns2:currency" uri="web-services" xmlns:ns2="http://services"/> + <include name="ns2:store-enterprise" uri="store-enterprise" xmlns:ns2="http://store"/> <!--include name="ns2:catalog-web" uri="catalog-webapp" xmlns:ns2="http://catalog"/--> <!--include name="ns2:catalog-mediation" uri="catalog-mediation" xmlns:ns2="http://catalog"/--> <!--include name="ns2:catalog-ejb" uri="catalog-ejb" xmlns:ns2="http://catalog"/--> diff --git a/branches/sca-java-1.x/tutorials/store/domain/launch/LaunchStoreEnterpriseNode.java b/branches/sca-java-1.x/tutorials/store/domain/launch/LaunchStoreEnterpriseNode.java new file mode 100644 index 0000000000..1fbdbee497 --- /dev/null +++ b/branches/sca-java-1.x/tutorials/store/domain/launch/LaunchStoreEnterpriseNode.java @@ -0,0 +1,28 @@ +/* + * 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 launch; + +import org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchStoreEnterpriseNode { + public static void main(String[] args) throws Exception { + NodeLauncher.main(new String[] {"http://localhost:9990/node-config/StoreEnterpriseNode"}); + } +} diff --git a/branches/sca-java-1.x/tutorials/store/domain/launch/LaunchWarehouseSpring.java b/branches/sca-java-1.x/tutorials/store/domain/launch/LaunchWarehouseSpring.java new file mode 100644 index 0000000000..a07a4bf635 --- /dev/null +++ b/branches/sca-java-1.x/tutorials/store/domain/launch/LaunchWarehouseSpring.java @@ -0,0 +1,55 @@ +/* + * 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 launch; + +import java.io.IOException; + +import org.apache.activemq.broker.BrokerService; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.launcher.Contribution; +import org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchWarehouseSpring { + public static void main(String[] args) throws Exception { + + BrokerService jmsBroker; + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + + NodeLauncher launcher = NodeLauncher.newInstance(); + SCANode node = launcher.createNode(null, + new Contribution("assets", "../assets/target/classes"), + new Contribution("warehouse", "../warehouse-spring/target/classes")); + node.start(); + + System.out.println("Press a key to stop"); + try { + System.in.read(); + } catch (IOException e) {} + + node.stop(); + + jmsBroker.stop(); + + } +} diff --git a/branches/sca-java-1.x/tutorials/store/domain/pom.xml b/branches/sca-java-1.x/tutorials/store/domain/pom.xml index 8ca75e8633..5172714f55 100644 --- a/branches/sca-java-1.x/tutorials/store/domain/pom.xml +++ b/branches/sca-java-1.x/tutorials/store/domain/pom.xml @@ -132,6 +132,20 @@ <version>1.6-SNAPSHOT</version> <scope>runtime</scope> </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jms-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-jms-asf</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> @@ -146,6 +160,26 @@ <version>10.3.1.4</version> <scope>runtime</scope> </dependency> + + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-core</artifactId> + <version>5.2.0</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-jms_1.1_spec</artifactId> + <version>1.1</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-jms_1.1_spec</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> diff --git a/branches/sca-java-1.x/tutorials/store/domain/workspace.xml b/branches/sca-java-1.x/tutorials/store/domain/workspace.xml index b982255012..b01bd0c1d8 100644 --- a/branches/sca-java-1.x/tutorials/store/domain/workspace.xml +++ b/branches/sca-java-1.x/tutorials/store/domain/workspace.xml @@ -26,6 +26,7 @@ <contribution location="file:../store-supplier/target/tutorial-store-supplier.jar" uri="store-supplier"/> <!-- contribution location="file:../store-market/target/tutorial-store-market.jar" uri="store-market"/--> <contribution location="file:../store-eu/target/tutorial-store-eu.jar" uri="store-eu"/> + <contribution location="file:../store-enterprise/target/tutorial-store-enterprise.jar" uri="store-enterprise"/> <!-- contribution location="file:../store-mashup" uri="store-mashup"/--> <contribution location="file:../web-services/target/tutorial-web-services.jar" uri="web-services"/> <!-- contribution location="file:../catalog-webapp/target/tutorial-catalog-webapp.war" uri="catalog-webapp"/--> diff --git a/branches/sca-java-1.x/tutorials/store/pom.xml b/branches/sca-java-1.x/tutorials/store/pom.xml index b2e62f1404..36c7bf6d00 100644 --- a/branches/sca-java-1.x/tutorials/store/pom.xml +++ b/branches/sca-java-1.x/tutorials/store/pom.xml @@ -46,6 +46,8 @@ <module>store-market</module> <module>store-eu</module> <module>store-mashup</module> + <module>store-enterprise</module> + <module>warehouse-spring</module> <module>web-services</module> <module>catalog-webapp</module> <module>catalog-ejb</module> |