summaryrefslogtreecommitdiffstats
path: root/sandbox/lresende
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/lresende')
-rw-r--r--sandbox/lresende/sca-2.x/samples/person-jsonrpc/pom.xml110
-rw-r--r--sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/launch/Launch.java39
-rw-r--r--sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/Person.java82
-rw-r--r--sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonService.java28
-rw-r--r--sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonServiceImpl.java40
-rw-r--r--sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/person.composite39
-rw-r--r--sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/uiservices/widget.html84
7 files changed, 422 insertions, 0 deletions
diff --git a/sandbox/lresende/sca-2.x/samples/person-jsonrpc/pom.xml b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/pom.xml
new file mode 100644
index 0000000000..823e2dff72
--- /dev/null
+++ b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/pom.xml
@@ -0,0 +1,110 @@
+<?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-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-person-jsonrpc</artifactId>
+ <name>Apache Tuscany SCA Sample Getting Started Online Store</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime-pom</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-widget-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-widget-runtime-dojo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-web-javascript-dojo</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <classpathScope>test</classpathScope>
+ <mainClass>store.StoreTestCase</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/launch/Launch.java b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/launch/Launch.java
new file mode 100644
index 0000000000..5f225462c9
--- /dev/null
+++ b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/launch/Launch.java
@@ -0,0 +1,39 @@
+/*
+ * 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.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class Launch {
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ...");
+ String contribution = ContributionLocationHelper.getContributionLocation(Launch.class);
+ Node node = NodeFactory.newInstance().createNode("person.composite", new Contribution("test", contribution));
+ node.start();
+ System.out.println("person.composite ready for big business !!!");
+ System.in.read();
+ System.out.println("Stopping ...");
+ node.stop();
+ System.out.println();
+ }
+}
diff --git a/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/Person.java b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/Person.java
new file mode 100644
index 0000000000..23df63588f
--- /dev/null
+++ b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/Person.java
@@ -0,0 +1,82 @@
+/*
+ * 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 Person implements java.io.Serializable {
+
+ private Integer id;
+ private String firstName;
+ private String lastName;
+ private String longitude;
+ private String latitude;
+ private String description;
+
+ public Person() {
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getLongatude() {
+ return this.longitude;
+ }
+
+ public void setLongatude(String longatude) {
+ this.longitude = longatude;
+ }
+
+ public String getLatitude() {
+ return this.latitude;
+ }
+
+ public void setLatitude(String latitude) {
+ this.latitude = latitude;
+ }
+
+ public Integer getID() {
+ return this.id;
+ }
+
+ public void setID(Integer id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
diff --git a/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonService.java b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonService.java
new file mode 100644
index 0000000000..9c547697ce
--- /dev/null
+++ b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonService.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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface PersonService {
+ void createPerson(Person person);
+ Person[] get();
+}
diff --git a/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonServiceImpl.java b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonServiceImpl.java
new file mode 100644
index 0000000000..7a4e294264
--- /dev/null
+++ b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonServiceImpl.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;
+
+public class PersonServiceImpl implements PersonService {
+ private List<Person> persons = new ArrayList<Person>();
+
+ @Override
+ public void createPerson(Person person) {
+ System.out.println("adding person " + person.getFirstName());
+ persons.add(person);
+
+ }
+
+ public Person[] get() {
+ Person[] catalogArray = new Person[persons.size()];
+ persons.toArray(catalogArray);
+ return catalogArray;
+ }
+}
diff --git a/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/person.composite b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/person.composite
new file mode 100644
index 0000000000..4c4741f71b
--- /dev/null
+++ b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/person.composite
@@ -0,0 +1,39 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://person"
+ name="person">
+
+ <component name="widget">
+ <tuscany:implementation.widget location="uiservices/widget.html"/>
+ <service name="Widget">
+ <tuscany:binding.http uri="/ui"/>
+ </service>
+ <reference name="personService" target="PersonComponent/PersonService"/>
+ </component>
+
+ <component name="PersonComponent">
+ <implementation.java class="services.PersonServiceImpl"/>
+ <service name="PersonService">
+ <tuscany:binding.jsonrpc uri="/PersonService"/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/uiservices/widget.html b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/uiservices/widget.html
new file mode 100644
index 0000000000..887ef11bfb
--- /dev/null
+++ b/sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/uiservices/widget.html
@@ -0,0 +1,84 @@
+<!--
+ * 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>Store</title>
+
+<script type="text/javascript" src="../dojo/dojo.js"></script>
+<script type="text/javascript" src="widget.js"></script>
+
+<script language="JavaScript">
+
+ //@Reference
+ var personService = new tuscany.sca.Reference("personService");
+
+ function personService_getResponse(items,exception) {
+ if(exception){
+ alert(exception.message);
+ return;
+ }
+ var persons = "";
+
+ for (var i=0; i<items.length; i++) {
+ var person = items[i].firstName + ' - ' + items[i].lastName;
+ persons += '<input name="items" type="checkbox" value="' +
+ item + '">' + item + ' <br>';
+ }
+ document.getElementById('persons').innerHTML=catalog;
+ }
+
+ function addNewPerson() {
+ var person = new Object();
+ person.id = "001"
+ person.firstName = "Luciano";
+ person.lastName = "R";
+
+ personService.createPerson(person).addCallback(addPerson_getResponse);
+ }
+
+ function addPerson_getResponse(something) {
+ personService.get().addCallback(personService_getResponse);
+ }
+
+ function init() {
+ try {
+ personService.get().addCallback(personService_getResponse);
+ }
+ catch(e){
+ alert(e);
+ }
+ }
+
+</script>
+
+</head>
+
+<body onload="init()">
+<h1>Store</h1>
+ <div id="application">
+ <h2>Persons</h2>
+ <form name="personsForm">
+ <div id="persons" ></div>
+ <br>
+ <input type="button" onClick="addNewPerson()" value="Add new person">
+ </form>
+ <br>
+ </div>
+</body>
+</html>