From 1f29c4ef1374655383a0a065d2839a8ad43717e2 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 19 Oct 2011 20:24:43 +0000 Subject: Person service example git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1186454 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca-2.x/samples/person-jsonrpc/pom.xml | 110 +++++++++++++++++++++ .../src/main/java/launch/Launch.java | 39 ++++++++ .../src/main/java/services/Person.java | 82 +++++++++++++++ .../src/main/java/services/PersonService.java | 28 ++++++ .../src/main/java/services/PersonServiceImpl.java | 40 ++++++++ .../src/main/resources/person.composite | 39 ++++++++ .../src/main/resources/uiservices/widget.html | 84 ++++++++++++++++ 7 files changed, 422 insertions(+) create mode 100644 sandbox/lresende/sca-2.x/samples/person-jsonrpc/pom.xml create mode 100644 sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/launch/Launch.java create mode 100644 sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/Person.java create mode 100644 sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonService.java create mode 100644 sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/java/services/PersonServiceImpl.java create mode 100644 sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/person.composite create mode 100644 sandbox/lresende/sca-2.x/samples/person-jsonrpc/src/main/resources/uiservices/widget.html 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 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-SNAPSHOT + ../../pom.xml + + sample-person-jsonrpc + Apache Tuscany SCA Sample Getting Started Online Store + + + + org.apache.tuscany.sca + tuscany-base-runtime-pom + 2.0-SNAPSHOT + pom + + + org.apache.tuscany.sca + tuscany-data-api + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime-dojo + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-web-javascript-dojo + 2.0-SNAPSHOT + + + org.mortbay.jetty + jetty + 6.1.19 + test + + + net.sourceforge.htmlunit + htmlunit + 2.6 + test + + + junit + junit + 4.8.1 + test + + + + + ${project.artifactId} + + + org.codehaus.mojo + exec-maven-plugin + 1.1.1 + + + + java + + + + + test + store.StoreTestCase + + + + + + 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 persons = new ArrayList(); + + @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 @@ + + + + + + + + + + + + + + + + + + + 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 @@ + + + +Store + + + + + + + + + +

Store

+
+

Persons

+
+
+
+ +
+
+
+ + -- cgit v1.2.3