From f5a67eabb6d251a61eb958d7b54f4227f036faa7 Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 3 Jul 2009 13:34:44 +0000 Subject: Update assets and domain to support the enterprise example git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@790911 13f79535-47bb-0310-9956-ffa450edef68 --- .../tutorials/store/assets/services/Order.java | 40 ++++++++++++++++ .../store/assets/services/ShoppingCartImpl.java | 17 +++++++ .../tutorials/store/assets/services/Total.java | 1 + .../tutorials/store/assets/services/Warehouse.java | 28 +++++++++++ .../assets/services/db/ShoppingCartTableImpl.java | 4 ++ .../tutorials/store/assets/uiservices/store.html | 32 +++++++++++-- .../tutorials/store/domain/cloud.composite | 1 + .../domain/cloud/StoreEnterpriseNode.composite | 35 ++++++++++++++ .../tutorials/store/domain/domain.composite | 1 + .../domain/launch/LaunchStoreEnterpriseNode.java | 28 +++++++++++ .../store/domain/launch/LaunchWarehouseSpring.java | 55 ++++++++++++++++++++++ .../sca-java-1.x/tutorials/store/domain/pom.xml | 34 +++++++++++++ .../tutorials/store/domain/workspace.xml | 1 + branches/sca-java-1.x/tutorials/store/pom.xml | 2 + 14 files changed, 275 insertions(+), 4 deletions(-) create mode 100644 branches/sca-java-1.x/tutorials/store/assets/services/Order.java create mode 100644 branches/sca-java-1.x/tutorials/store/assets/services/Warehouse.java create mode 100644 branches/sca-java-1.x/tutorials/store/domain/cloud/StoreEnterpriseNode.composite create mode 100644 branches/sca-java-1.x/tutorials/store/domain/launch/LaunchStoreEnterpriseNode.java create mode 100644 branches/sca-java-1.x/tutorials/store/domain/launch/LaunchWarehouseSpring.java (limited to 'branches') 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 cart; + @Reference(required=false) + protected Warehouse warehouse; + @Init public void init() { cart = new HashMap(); @@ -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='

' + 'Thanks for Shopping With Us!

'+ '

Your Order

'+ '
'+ - document.getElementById('shoppingCart').innerHTML+ + cartHtml + '
'+ - document.getElementById('total').innerHTML+ + totalHtml + '
'+ '
'+ - ''+ + ''+ '
'; - 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 @@ + 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 @@ + + + + + + + + + + + + + + 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 @@ + 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 @@ 1.6-SNAPSHOT runtime + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + runtime + org.apache.tuscany.sca @@ -146,6 +160,26 @@ 10.3.1.4 runtime + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + 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 @@ + 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 @@ store-market store-eu store-mashup + store-enterprise + warehouse-spring web-services catalog-webapp catalog-ejb -- cgit v1.2.3