From 846969218646308b4c5079a4202c74c4478bef7b Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 1 Aug 2008 08:33:24 +0000 Subject: [PATCH] Customer sample using Dojo + JSONRPC and OpenJPA git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@681631 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/samples/customer-dojo/README | 104 ++++++++ .../customer-dojo/build-dependency.xml | 110 ++++++++ java/sca/samples/customer-dojo/build-dojo.xml | 92 +++++++ java/sca/samples/customer-dojo/build.xml | 70 +++++ .../customer-dojo/customer-dojo-jsonrpc.png | Bin 0 -> 9947 bytes .../customer-dojo/customer-dojo-jsonrpc.svg | 177 +++++++++++++ java/sca/samples/customer-dojo/customer.sql | 33 +++ java/sca/samples/customer-dojo/pom.xml | 245 ++++++++++++++++++ .../src/main/java/customer/Customer.java | 93 +++++++ .../java/customer/CustomerCollection.java | 26 ++ .../java/customer/CustomerCollectionImpl.java | 101 ++++++++ .../main/java/customer/CustomerService.java | 31 +++ .../java/customer/CustomerServiceImpl.java | 117 +++++++++ .../src/main/java/launch/Launch.java | 34 +++ .../src/main/resources/META-INF/orm.xml | 51 ++++ .../main/resources/META-INF/persistence.xml | 40 +++ .../resources/META-INF/sca-contribution.xml | 26 ++ .../src/main/resources/content/customer.html | 77 ++++++ .../src/main/resources/customer.composite | 44 ++++ 19 files changed, 1471 insertions(+) create mode 100644 java/sca/samples/customer-dojo/README create mode 100644 java/sca/samples/customer-dojo/build-dependency.xml create mode 100644 java/sca/samples/customer-dojo/build-dojo.xml create mode 100644 java/sca/samples/customer-dojo/build.xml create mode 100644 java/sca/samples/customer-dojo/customer-dojo-jsonrpc.png create mode 100644 java/sca/samples/customer-dojo/customer-dojo-jsonrpc.svg create mode 100644 java/sca/samples/customer-dojo/customer.sql create mode 100644 java/sca/samples/customer-dojo/pom.xml create mode 100644 java/sca/samples/customer-dojo/src/main/java/customer/Customer.java create mode 100644 java/sca/samples/customer-dojo/src/main/java/customer/CustomerCollection.java create mode 100644 java/sca/samples/customer-dojo/src/main/java/customer/CustomerCollectionImpl.java create mode 100644 java/sca/samples/customer-dojo/src/main/java/customer/CustomerService.java create mode 100644 java/sca/samples/customer-dojo/src/main/java/customer/CustomerServiceImpl.java create mode 100644 java/sca/samples/customer-dojo/src/main/java/launch/Launch.java create mode 100644 java/sca/samples/customer-dojo/src/main/resources/META-INF/orm.xml create mode 100644 java/sca/samples/customer-dojo/src/main/resources/META-INF/persistence.xml create mode 100644 java/sca/samples/customer-dojo/src/main/resources/META-INF/sca-contribution.xml create mode 100644 java/sca/samples/customer-dojo/src/main/resources/content/customer.html create mode 100644 java/sca/samples/customer-dojo/src/main/resources/customer.composite diff --git a/java/sca/samples/customer-dojo/README b/java/sca/samples/customer-dojo/README new file mode 100644 index 0000000000..9c1729123f --- /dev/null +++ b/java/sca/samples/customer-dojo/README @@ -0,0 +1,104 @@ +Customer Dojo RPC Sample +=========================== + +Note. This sample is currently not working correctly on WebSphere - see TUSCANY-1990 + +This sample demostrates the SCA JSONRPC binding using a simple web app that +uses the RPC support of the Dojo Toolkit to an SCA service. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-helloworld-dojo-webapp.war) +to you web application server. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-helloworld-dojo-webapp + +The port and hostname will of course vary depending on your local installation. + +See also the similar helloworld-jsonrpc-webapp sample which also uses the SCA JSONRPC binding +but uses SCA scaDomain.js script on the client instead of the Dojo Toolkit. + +Sample Overview +--------------- +The sample provides a single service with an operation that reflects +a greeting back to the caller. The service is exposed using the JSONRPC +binding. The web app provided shows how the Dojo Toolkit JSON-RPC support can be +used to invoke the SCA service. + +The web app provided shows how the service can be called by using the DOJO toolkit. + +helloworld-dojo-webapp/ + build-dojo.xml - This file is an Ant script used by the + sample build process to download the Dojo Toolkit + and get it included in the WAR file + for use by the sample. + src/ + main/ + java/ + helloworldjsonrpc/ + HelloWorldService.java - service interface + HelloWorldServiceImpl.java - service implementation + resources/ + jsonrpc.composite - the SCA assembly for this sample + webapp + dojo/ - the Dojo toolkit (this directory is created only + when you build the samples from the source distribution) + META-INF/ + sca-contribution.xml - specifies the composite to be deployed + WEB-INF/ + web.xml - defines the listener that starts up the + Tuscany SCA runtime + HelloWorldJSONRPC.html - the web application that calls the + SCA service via JSONRPC + style.css - style sheet + + helloworld-jsonrpc-webapp.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file that unpacks the + dojo installation + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd helloworld-dojo-webapp +ant package + +This should result in a war file (sample-helloworld-dojo-webapp.war) in the target +directory. Copy this war file to your web app deployment directory in your +web app container. + +The process for getting the web app running will depend on which web app container +you are using. For example, if you are using Tomcat then it is simply a matter +of copying the WAR file to the webapps directory. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-helloworld-dojo-webapp + +The port and hostname will of course vary depending on your local installation. + +You should see a web page that allows you to send messages, via JSONRPC, to the +application running in the Tuscany SCA Runtime + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd helloworld-dojo-webapp +mvn + +Again this should result in a war file (sample-helloworld-dojo-webapp.war) in the target +directory. Follow the steps described in the previous section for running the web +app and for the expected results. + + diff --git a/java/sca/samples/customer-dojo/build-dependency.xml b/java/sca/samples/customer-dojo/build-dependency.xml new file mode 100644 index 0000000000..8b59283e03 --- /dev/null +++ b/java/sca/samples/customer-dojo/build-dependency.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/samples/customer-dojo/build-dojo.xml b/java/sca/samples/customer-dojo/build-dojo.xml new file mode 100644 index 0000000000..8c6bd99484 --- /dev/null +++ b/java/sca/samples/customer-dojo/build-dojo.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/samples/customer-dojo/build.xml b/java/sca/samples/customer-dojo/build.xml new file mode 100644 index 0000000000..95813af65a --- /dev/null +++ b/java/sca/samples/customer-dojo/build.xml @@ -0,0 +1,70 @@ + + +]> + + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/samples/customer-dojo/customer-dojo-jsonrpc.png b/java/sca/samples/customer-dojo/customer-dojo-jsonrpc.png new file mode 100644 index 0000000000000000000000000000000000000000..57f90aed016226234508cdca91080026947935b3 GIT binary patch literal 9947 zcmd6NRajeJ@GYf+6)4`K1&TWaw-%>Ja47B$!GlAKdy6~8-K_+d;+{hA;O?&B=J$WO z-*;c`{+u`go?5(HYO=13JMCgyquI83d#!%U{CU`mYcJaQ7xOs{qmJohk2Ki_lxg2LnXsDKTBYI`spMgCm}JO@$+Z! zPnlu)+ycBvj88>x6eD74yD4ty_5Q}Q4(+>x3o9=WwaNC>KF$eR_%}NcU-@+J6Ws^s zD9?mQzIA%&`(?#Qm+~oc|BQhd*Y8C(5EU4$4BMD>lkeuSy9k=d_B4PakcOHI60(Qg zIZ38?!}bSZD7kh?_dePrmt8(uO{_B|lEUuW!}Q4#yDV(PFz$dprN{;!KR;Do^>~tO z47l{PyLca+x0lN<8;w_amGp>Mkv=w*-I?%d%RVX3WtYpONXTRK&c8!T2{<#sKzBC$ zTe#`8@dSKNBz;#TugZ#?3uf_ox*-aL<4$4vmO0&vDY?Xx=#Qp^>7_3B*^hD}*FU`f z+{3x#G&L;^Ju<$502~QF-xt1>aaEO&$rVGMsvSvA4l65rjhremuk5Z?J}sABGTNk8 z{+p-hF#sb%_3MS*uQfcb|M~Tex`2NUzoLW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ZE~KpJBP&JO}_`%u@qsEvCtE^GtQKVr_|DvFpGvKhZw z2d2*6Trqx^U8c)6H>CYutWTH2=|DF5r@UfR^wmk!yYs4m>~ZDhQv-#C;Tj7`cF-xaKr|L>;A#??ZuzW z5+T31;6BE}yC(|=?3w>j1UX=9?qc`rB6UK;8^>%8WrDldNF~ytZ57+V$qiNf&-d+G zM|Z25m9Tk=eWAYhn>P>h=d*C1_T!bL|HMmrpL?60S#keIytI6d6FW{Ue%gS%#nv=n z?BMumEh7Mt-CT5;k8CCP|D3)5in!Zdc2t7;BhQEB+2|sf?kn#eGO8b Ph9WPmELA08{NsNC9Ko!+ literal 0 HcmV?d00001 diff --git a/java/sca/samples/customer-dojo/customer-dojo-jsonrpc.svg b/java/sca/samples/customer-dojo/customer-dojo-jsonrpc.svg new file mode 100644 index 0000000000..d5c3bc5d3e --- /dev/null +++ b/java/sca/samples/customer-dojo/customer-dojo-jsonrpc.svg @@ -0,0 +1,177 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldjsonrpc + + HelloWorldJSONServiceComponent + HelloWorldService + WebApp + DOJO + + diff --git a/java/sca/samples/customer-dojo/customer.sql b/java/sca/samples/customer-dojo/customer.sql new file mode 100644 index 0000000000..a3caf8e050 --- /dev/null +++ b/java/sca/samples/customer-dojo/customer.sql @@ -0,0 +1,33 @@ +-- +-- 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. +-- + +DROP TABLE CUSTOMER; + +CREATE TABLE CUSTOMER ( + ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, + NAME VARCHAR(30), + PHONE VARCHAR(10), + ADDRESS VARCHAR(25), + CITY VARCHAR(15), + STATE VARCHAR(2), + ZIP VARCHAR(5)); + +INSERT INTO CUSTOMER (NAME, PHONE, ADDRESS, CITY, STATE, ZIP ) VALUES('Joe Smith', '4081234567', '1440 N 1st ST', 'SAN JOSE', 'CA', '95134'); +INSERT INTO CUSTOMER (NAME, PHONE, ADDRESS, CITY, STATE, ZIP ) VALUES('Erik Johnson', '4081230987', '1440 N 1st ST', 'SAN JOSE', 'CA', '95134'); +INSERT INTO CUSTOMER (NAME, PHONE, ADDRESS, CITY, STATE, ZIP ) VALUES('Mark Pensacola', '4085679988', '1440 N 1st ST', 'SAN JOSE', 'CA', '95134'); \ No newline at end of file diff --git a/java/sca/samples/customer-dojo/pom.xml b/java/sca/samples/customer-dojo/pom.xml new file mode 100644 index 0000000000..cca88fbb00 --- /dev/null +++ b/java/sca/samples/customer-dojo/pom.xml @@ -0,0 +1,245 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-customer-dojo + Apache Tuscany SCA Customer DOJO Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-SNAPSHOT + + + + org.apache.geronimo.specs + geronimo-jpa_3.0_spec + 1.1 + + + + org.apache.openjpa + openjpa + 1.0.0 + + + javax.xml.bind + jaxb-api + + + + + + org.apache.derby + derby + 10.1.2.1 + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-antrun-plugin + + + + ant + ant-trax + 1.6.5 + + + + + install-dojo + validate + + run + + + + + + + + + + + copy-dojo-files + generate-resources + + run + + + + + + + + + + + + clean-dojo-files + clean + + run + + + + + + + + + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + true + + + generate + + + + + + org.codehaus.mojo + sql-maven-plugin + + 1.1-SNAPSHOT + + + + org.apache.derby + derby + 10.1.2.1 + + + + + + create-db + generate-resources + + execute + + + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:${pom.basedir}/target/classes/customer;create=true + true + continue + skip + ; + + ${pom.basedir}/customer.sql + + + + + + + shutdown-database-sothat-test-can-run + process-test-resources + + execute + + + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:${pom.basedir}/target/classes/customer;shutdown=true + true + + + + + + + diff --git a/java/sca/samples/customer-dojo/src/main/java/customer/Customer.java b/java/sca/samples/customer-dojo/src/main/java/customer/Customer.java new file mode 100644 index 0000000000..6d207ea2ef --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/java/customer/Customer.java @@ -0,0 +1,93 @@ +/* + * 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 customer; + +import javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class Customer { + + @Id protected int id; + @Basic protected String name; + @Basic protected String phone; + @Basic protected String address; + @Basic protected String city; + @Basic protected String state; + @Basic protected String zip; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } + +} diff --git a/java/sca/samples/customer-dojo/src/main/java/customer/CustomerCollection.java b/java/sca/samples/customer-dojo/src/main/java/customer/CustomerCollection.java new file mode 100644 index 0000000000..5ad39aad5c --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/java/customer/CustomerCollection.java @@ -0,0 +1,26 @@ +/* + * 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 customer; + +import org.apache.tuscany.sca.data.collection.Collection; + + +public interface CustomerCollection extends Collection { + +} diff --git a/java/sca/samples/customer-dojo/src/main/java/customer/CustomerCollectionImpl.java b/java/sca/samples/customer-dojo/src/main/java/customer/CustomerCollectionImpl.java new file mode 100644 index 0000000000..c0a2f25f15 --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/java/customer/CustomerCollectionImpl.java @@ -0,0 +1,101 @@ +/* + * 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 customer; + +import java.util.Iterator; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.persistence.Persistence; +import javax.persistence.Query; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; + + +public class CustomerCollectionImpl implements CustomerCollection { + EntityManagerFactory emf = null; + EntityManager em = null; + + public CustomerCollectionImpl() { + System.out.println(">>>"); + try { + emf = Persistence.createEntityManagerFactory("customer-openJPA"); + em = emf.createEntityManager(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void delete(String arg0) throws NotFoundException { + // TODO Auto-generated method stub + + } + + public Customer get(String arg0) throws NotFoundException { + // TODO Auto-generated method stub + return null; + } + + public Entry[] getAll() { + EntityTransaction tx = em.getTransaction(); + try { + tx.begin(); + + Query q = em.createQuery("SELECT c FROM customer c"); + List results = q.getResultList(); + Iterator iter = results.iterator(); + while (iter.hasNext()) { + Customer customer = (Customer)iter.next(); + + System.out.println(customer); + } + + tx.commit(); + } catch(Exception e) { + e.printStackTrace(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + + em.close(); + } + + return null; + } + + public String post(String arg0, Customer arg1) { + // TODO Auto-generated method stub + return null; + } + + public void put(String arg0, Customer arg1) throws NotFoundException { + // TODO Auto-generated method stub + + } + + public Entry[] query(String arg0) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/java/sca/samples/customer-dojo/src/main/java/customer/CustomerService.java b/java/sca/samples/customer-dojo/src/main/java/customer/CustomerService.java new file mode 100644 index 0000000000..7915cc6e77 --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/java/customer/CustomerService.java @@ -0,0 +1,31 @@ +/* + * 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 customer; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CustomerService { + + Customer[] get(); + + Customer findCustomerByName(String name); + +} diff --git a/java/sca/samples/customer-dojo/src/main/java/customer/CustomerServiceImpl.java b/java/sca/samples/customer-dojo/src/main/java/customer/CustomerServiceImpl.java new file mode 100644 index 0000000000..0cba7d8bc1 --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/java/customer/CustomerServiceImpl.java @@ -0,0 +1,117 @@ +/* + * 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 customer; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.persistence.Persistence; +import javax.persistence.Query; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; + +public class CustomerServiceImpl implements CustomerService { + EntityManagerFactory emf = null; + EntityManager em = null; + + public CustomerServiceImpl() { + + } + + @Init + public void init() { + System.out.println(">>> Initializing JPA"); + try { + emf = Persistence.createEntityManagerFactory("customer-openJPA"); + em = emf.createEntityManager(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Destroy + public void destroy() { + emf.close(); + } + + public Customer[] get() { + EntityTransaction tx = em.getTransaction(); + List customers = new ArrayList(); + try { + tx.begin(); + + Query q = em.createQuery("SELECT c FROM customer c"); + List results = q.getResultList(); + Iterator iter = results.iterator(); + while (iter.hasNext()) { + Customer customer = (Customer)iter.next(); + customers.add(customer); + } + + tx.commit(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + + em.close(); + } + + Customer[] customerArray = new Customer[customers.size()]; + customers.toArray(customerArray); + return customerArray; + } + + public Customer findCustomerByName(String name) { + EntityTransaction tx = em.getTransaction(); + Customer customer = null; + + try { + tx.begin(); + + Query q = em.createQuery("SELECT c FROM customer c WHERE c.name = '" + name + "'"); + List results = q.getResultList(); + Iterator iter = results.iterator(); + while (iter.hasNext()) { + customer = (Customer)iter.next(); + } + + tx.commit(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + + em.close(); + } + + return customer; + } + +} diff --git a/java/sca/samples/customer-dojo/src/main/java/launch/Launch.java b/java/sca/samples/customer-dojo/src/main/java/launch/Launch.java new file mode 100644 index 0000000000..d7f88b8dd4 --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/java/launch/Launch.java @@ -0,0 +1,34 @@ +/* + * 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.host.embedded.SCADomain; + +public class Launch { + public static void main(String[] args) throws Exception { + System.out.println("Starting ..."); + SCADomain scaDomain = SCADomain.newInstance("customer.composite"); + System.out.println("store.composite ready for big business !!!"); + System.in.read(); + System.out.println("Stopping ..."); + scaDomain.close(); + System.out.println(); + } +} diff --git a/java/sca/samples/customer-dojo/src/main/resources/META-INF/orm.xml b/java/sca/samples/customer-dojo/src/main/resources/META-INF/orm.xml new file mode 100644 index 0000000000..64be295302 --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/resources/META-INF/orm.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/samples/customer-dojo/src/main/resources/META-INF/persistence.xml b/java/sca/samples/customer-dojo/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..7073c8daf7 --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,40 @@ + + + + + + + orm.xml + customer.Customer + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/samples/customer-dojo/src/main/resources/META-INF/sca-contribution.xml b/java/sca/samples/customer-dojo/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..136326d1d3 --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/java/sca/samples/customer-dojo/src/main/resources/content/customer.html b/java/sca/samples/customer-dojo/src/main/resources/content/customer.html new file mode 100644 index 0000000000..dbc8aad9d0 --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/resources/content/customer.html @@ -0,0 +1,77 @@ + + + + Tuscany Dojo JSON-RPC Customer Example + + + + + + + + + + + + + + + +

Tuscany Dojo JSON-RPC Customer Sample

+ +Customer Name :
+ + + + + + + + diff --git a/java/sca/samples/customer-dojo/src/main/resources/customer.composite b/java/sca/samples/customer-dojo/src/main/resources/customer.composite new file mode 100644 index 0000000000..4c370f2a9f --- /dev/null +++ b/java/sca/samples/customer-dojo/src/main/resources/customer.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + +