diff options
Diffstat (limited to 'sca-java-1.x/trunk/tutorials/store/warehouse-spring')
7 files changed, 391 insertions, 0 deletions
diff --git a/sca-java-1.x/trunk/tutorials/store/warehouse-spring/META-INF/sca-contribution.xml b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..99863d56cc --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ +<?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. +--> +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:s="http://store"> + <import.java package="services" /> + <deployable composite="s:warehouse" /> +</contribution>
\ No newline at end of file diff --git a/sca-java-1.x/trunk/tutorials/store/warehouse-spring/build.xml b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/build.xml new file mode 100644 index 0000000000..b2a1387dab --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/build.xml @@ -0,0 +1,75 @@ +<!-- + * 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. +--> + +<project name="tutorial-warehouse-spring" default="compile"> + + <target name="compile"> + <mkdir dir="target/classes"/> + <javac destdir="target/classes" debug="on" source="1.5" target="1.5"> + <src path="."/> + <classpath> + <fileset refid="tuscany.jars"/> + <fileset refid="3rdparty.jars"/> + </classpath> + </javac> + <copy todir="target/classes"> + <fileset dir="." excludes="**/*.java, pom.xml, build.xml, target"/> + </copy> + <jar destfile="target/tutorial-warehouse-spring.jar" basedir="target/classes"> + <manifest> + </manifest> + </jar> + </target> + + <target name="package" depends="compile"/> + + <target name="clean"> + <delete includeemptydirs="true"> + <fileset dir="target"/> + </delete> + </target> + + <fileset id="tuscany.jars" dir="../../../modules"> + <include name="tuscany-assembly-1.6-SNAPSHOT.jar"/> + <include name="tuscany-assembly-xml-1.6-SNAPSHOT.jar"/> + <include name="tuscany-binding-jms-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-java-1.6-SNAPSHOT.jar"/> + <include name="tuscany-contribution-namespace-1.6-SNAPSHOT.jar"/> + <include name="tuscany-core-spi-1.6-SNAPSHOT.jar"/> + <include name="tuscany-data-api-1.6-SNAPSHOT.jar"/> + <include name="tuscany-definitions-1.6-SNAPSHOT.jar"/> + <include name="tuscany-extensibility-1.6-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-1.6-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-1.6-SNAPSHOT.jar"/> + <include name="tuscany-monitor-1.6-SNAPSHOT.jar"/> + <include name="tuscany-policy-1.6-SNAPSHOT.jar"/> + <include name="tuscany-sca-api-1.6-SNAPSHOT.jar"/> + <include name="tuscany-sca-api-extension-1.6-SNAPSHOT.jar"/> + <include name="tutorial-assets-1.6-SNAPSHOT.jar"/> + </fileset> + <fileset id="3rdparty.jars" dir="../../../lib"> + <include name="derby-10.3.1.4.jar"/> + <include name="jsr181-api-1.0-MR1.jar"/> + <include name="stax-api-1.0-2.jar"/> + <include name="wstx-asl-3.2.4.jar"/> + </fileset> + +</project> diff --git a/sca-java-1.x/trunk/tutorials/store/warehouse-spring/pom.xml b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/pom.xml new file mode 100644 index 0000000000..939d3b24bc --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/pom.xml @@ -0,0 +1,98 @@ +<?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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-tutorial-store</artifactId> + <version>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tutorial-warehouse-spring</artifactId> + <name>Apache Tuscany SCA Store Tutorial Warehouse Spring</name> + + <repositories> + <repository> + <id>apache.incubator</id> + <url>http://people.apache.org/repo/m2-incubating-repository</url> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jms</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tutorial-assets</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <sourceDirectory>${basedir}</sourceDirectory> + <resources> + <resource> + <directory>${basedir}</directory> + <excludes> + <exclude>**/*.java</exclude> + <exclude>**/.*/**</exclude> + <exclude>pom.xml</exclude> + <exclude>build.xml</exclude> + <exclude>target/**</exclude> + </excludes> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-maven-ant-generator</artifactId> + <version>1.6-SNAPSHOT</version> + <executions> + <execution> + <configuration> + <pathToRootDir>../../..</pathToRootDir> + </configuration> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/trunk/tutorials/store/warehouse-spring/services/WarehouseImpl.java b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/services/WarehouseImpl.java new file mode 100644 index 0000000000..d14def1e8e --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/services/WarehouseImpl.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; + +import java.util.ArrayList; +import java.util.List; + +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class WarehouseImpl implements Warehouse { + + private List<Order> orders = new ArrayList<Order>(); + + public void addOrder(Order order) { + System.out.println("Received order: " + order.toString()); + orders.add(order); + } + + public Order[] getOrders() { + return orders.toArray(new Order[orders.size()]); + } +} diff --git a/sca-java-1.x/trunk/tutorials/store/warehouse-spring/uiservices/warehouse.html b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/uiservices/warehouse.html new file mode 100644 index 0000000000..b215f9a3cd --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/uiservices/warehouse.html @@ -0,0 +1,76 @@ +<!-- + * 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. +--> +<html> +<head> +<title>Warehouse</title> + +<script type="text/javascript" src="warehouse.js"></script> + +<script language="JavaScript"> + + //@Reference + var warehouse = new tuscany.sca.Reference("warehouse"); + + function getOrders() { + warehouse.getOrders(warehouse_getOrdersResponse); + } + + function warehouse_getOrdersResponse(orders,exception) { + if(exception){ + alert(exception.message); + return; + } + + var orderHTML = ""; + for (var i=0; i<orders.length; i++) { + var order = orders[i]; + var items = order.items; + orderHTML += "Order</br>"; + for (var j=0; j<items.length; j++) { + var item = items[j].name + ' - ' + items[j].price; + orderHTML += " " + item + "<br/>"; + } + } + document.getElementById('orders').innerHTML=orderHTML; + } + + function init() { + try { + getOrders(); + } + catch(e) { + alert(e); + } + } + +</script> + +</head> + +<body onload="init()"> +<h1>Pending Orders</h1> + <div id="warehouse"> + <form name="ordersForm"> + <div id="orders" ></div> + <br> + <input type="button" onClick="getOrders()" value="Refresh"> + </form> + </div> +</body> +</html> diff --git a/sca-java-1.x/trunk/tutorials/store/warehouse-spring/warehouse-context.xml b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/warehouse-context.xml new file mode 100644 index 0000000000..ed718d1403 --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/warehouse-context.xml @@ -0,0 +1,29 @@ +<?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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:sca="http://www.springframework.org/schema/sca" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + + <bean id="warehouse" class="services.WarehouseImpl"> + </bean> + +</beans> diff --git a/sca-java-1.x/trunk/tutorials/store/warehouse-spring/warehouse-spring.composite b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/warehouse-spring.composite new file mode 100644 index 0000000000..bfe789542d --- /dev/null +++ b/sca-java-1.x/trunk/tutorials/store/warehouse-spring/warehouse-spring.composite @@ -0,0 +1,49 @@ +<?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="warehouse"> + + <component name="WarehouseUI"> + <t:implementation.widget location="uiservices/warehouse.html"/> + <service name="Widget"> + <t:binding.http uri="http://localhost:8088/ui"/> + </service> + <reference name="warehouse"> + <t:binding.jsonrpc uri="http://localhost:8088/Warehouse"/> + </reference> + </component> + + <component name="Warehouse"> + <implementation.spring location="warehouse-context.xml"/> + <service name="Warehouse"> + <t:binding.jsonrpc uri="http://localhost:8088/Warehouse"/> + <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" + jndiURL="tcp://localhost:61619"> + <destination name="RequestQueue" create="ifnotexist"/> + <response> + <destination name="ResponseQueue" create="ifnotexist"/> + </response> + </binding.jms> + </service> + </component> + +</composite> |