cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r584525 - in /incubator/cxf/branches/jliu: distribution/ distribution/src/main/release/samples/restful_jaxrs/ distribution/src/main/release/samples/restful_jaxrs/src/ distribution/src/main/release/samples/restful_jaxrs/src/demo/ distributio...
Date Sun, 14 Oct 2007 10:43:12 GMT
Author: jliu
Date: Sun Oct 14 03:43:08 2007
New Revision: 584525

URL: http://svn.apache.org/viewvc?rev=584525&view=rev
Log:
Add a sample for JSR-311

Added:
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/README.txt
  (with props)
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/build.xml
  (with props)
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/Client.java
  (with props)
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/add_customer.txt
  (with props)
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/update_customer.txt
  (with props)
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Customer.java
  (with props)
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/CustomerService.java
  (with props)
    incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Server.java
  (with props)
Modified:
    incubator/cxf/branches/jliu/distribution/pom.xml
    incubator/cxf/branches/jliu/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java

Modified: incubator/cxf/branches/jliu/distribution/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/pom.xml?rev=584525&r1=584524&r2=584525&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/distribution/pom.xml (original)
+++ incubator/cxf/branches/jliu/distribution/pom.xml Sun Oct 14 03:43:08 2007
@@ -221,6 +221,11 @@
             <artifactId>cxf-bundle</artifactId>
             <version>${pom.version}</version>
         </dependency>
+        <dependency>
+	    <groupId>commons-httpclient</groupId>
+	    <artifactId>commons-httpclient</artifactId>
+	    <version>3.1-rc1</version>
+        </dependency>
     </dependencies>
 
     <build>

Added: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/README.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/README.txt?rev=584525&view=auto
==============================================================================
--- incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/README.txt
(added)
+++ incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/README.txt
Sun Oct 14 03:43:08 2007
@@ -0,0 +1,133 @@
+RESTful Hello World Demo 
+========================
+
+The demo shows REST based Web Services using JAX-RS (JSR-311). The REST server provides the
following services: 
+
+A RESTful customer service is provided on URL http://localhost:9000/customers. 
+Users access this URI to operate on customer.
+
+A HTTP GET request to URL http://localhost:9000/customers/1234 
+returns a customer instance whose id is 1234. The XML document returned:
+
+<Customer>
+  <id>1234</id>
+  <name>John</name>
+  <phoneNumber>123456</phoneNumber>
+</Customer>
+
+A HTTP POST request to URL http://localhost:9000/customers 
+with the data:
+
+<Customer>
+  <id>1234</id>
+  <name>John</name>
+  <phoneNumber>123456</phoneNumber>
+</Customer>
+
+updates customer 1234 with the data provided. 
+
+The client code demonstrates how to send HTTP POST with XML data using 
+JAX-WS Dispatch and how to send HTTP GET using URL.openStream(). The 
+server code demonstrates how to build a RESTful endpoints through 
+JAX-RS (JSR-311) APIs.
+
+
+Please review the README in the samples directory before
+continuing.
+
+
+Prerequisites
+------------
+
+If your environment already includes cxf-manifest-incubator.jar on the
+CLASSPATH, and the JDK and ant bin directories on the PATH
+it is not necessary to set the environment as described in
+the samples directory README.  If your environment is not
+properly configured, or if you are planning on using wsdl2java,
+javac, and java to build and run the demos, you must set the
+environment.
+
+
+
+Building and running the demo using Ant
+---------------------------------------
+From the base directory of this sample (i.e., where this README file is
+located), the Ant build.xml file can be used to build and run the demo. 
+The server and client targets automatically build the demo.
+
+Using either UNIX or Windows:
+
+  ant server  (from one command line window)
+  ant client  (from a second command line window)
+    
+
+To remove the code generated from the WSDL file and the .class
+files, run "ant clean".
+
+
+
+Building the demo using wsdl2java and javac
+-------------------------------------------
+
+From the samples/restful_jaxrs directory, first create the target
+directory build/classes and then compile the provided client 
+and server applications with the commands:
+
+For UNIX:  
+  mkdir -p build/classes
+  
+  export CLASSPATH=$CLASSPATH:$CXF_HOME/lib/cxf-manifest-incubator.jar:./build/classes
+  javac -d build/classes src/demo/jaxrs/client/*.java
+  javac -d build/classes src/demo/jaxrs/server/*.java
+
+For Windows:
+  mkdir build\classes
+    Must use back slashes.
+
+  set classpath=%classpath%;%CXF_HOME%\lib\cxf-manifest-incubator.jar;.\build\classes
+  javac -d build\classes src\demo\jaxrs\client\*.java
+  javac -d build\classes src\demo\jaxrs\server\*.java
+
+
+Finally, copy resource files into the build/classes directory with the commands:
+
+For UNIX:    
+  cp ./src/demo/jaxrs/client/*.xml ./build/classes/demo/jaxrs/client
+  cp ./src/demo/jaxrs/server/*.xml ./build/classes/demo/jaxrs/server
+
+For Windows:
+  copy src\demo\jaxrs\client\*.xml build\classes\demo\jaxrs\client
+  copy src\demo\jaxrs\server\*.xml build\classes\demo\jaxrs\server
+
+
+Running the demo using java
+---------------------------
+
+From the samples/restful_jaxrs directory run the following commands. They 
+are entered on a single command line.
+
+For UNIX (must use forward slashes):
+    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
+         demo.jaxrs.server.Server &
+
+    java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties
+         demo.jaxrs.client.Client
+
+The server process starts in the background.  After running the client,
+use the kill command to terminate the server process.
+
+For Windows (may use either forward or back slashes):
+  start 
+    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
+       demo.jaxrs.server.Server
+
+    java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties
+       demo.jaxrs.client.Client
+
+A new command windows opens for the server process.  After running the
+client, terminate the server process by issuing Ctrl-C in its command window.
+
+To remove the code generated from the WSDL file and the .class
+files, either delete the build directory and its contents or run:
+
+  ant clean

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/README.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/build.xml?rev=584525&view=auto
==============================================================================
--- incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/build.xml
(added)
+++ incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/build.xml
Sun Oct 14 03:43:08 2007
@@ -0,0 +1,33 @@
+<?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 name="RESTful demo" default="build" basedir=".">
+    <property name="codegen.notrequired" value="true"/>
+
+    <import file="../common_build.xml"/>        
+        
+    <target name="client" description="run demo client" depends="build">
+        <cxfrun classname="demo.jaxrs.client.Client"/>
+    </target> 
+        
+    <target name="server" description="run demo server" depends="build">
+        <cxfrun classname="demo.jaxrs.server.Server"/>
+    </target>
+
+</project>

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/build.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/build.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/Client.java?rev=584525&view=auto
==============================================================================
--- incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/Client.java
(added)
+++ incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/Client.java
Sun Oct 14 03:43:08 2007
@@ -0,0 +1,114 @@
+/**
+ * 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 demo.jaxrs.client;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.FileRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+
+public final class Client {
+
+    private Client() {
+    }
+
+    public static void main(String args[]) throws Exception {
+        // Sent HTTP GET request to query all customer info
+        /*
+         * URL url = new URL("http://localhost:9000/customers");
+         * System.out.println("Invoking server through HTTP GET to query all
+         * customer info"); InputStream in = url.openStream(); StreamSource
+         * source = new StreamSource(in); printSource(source);
+         */
+
+        // Sent HTTP GET request to query customer info
+        url = new URL("http://localhost:9000/customers/1234");
+        System.out.println("Invoking server through HTTP GET to query customer info");
+        in = url.openStream();
+        source = new StreamSource(in);
+        printSource(source);
+
+        // Sent HTTP PUT request to update customer info
+        String inputFile = getClass().getResource("update_customer.txt").getFile();
+        File input = new File(inputFile);
+        PutMethod put = new PutMethod("http://localhost:9000/customers");
+        RequestEntity entity = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1");
+        put.setRequestEntity(entity);
+        HttpClient httpclient = new HttpClient();
+
+        try {
+            int result = httpclient.executeMethod(post);
+            assertEquals(200, result);
+            System.out.println("Response status code: " + result);
+            System.out.println("Response body: ");
+            System.out.println(post.getResponseBodyAsString());
+        } finally {
+            // Release current connection to the connection pool once you are
+            // done
+            put.releaseConnection();
+        }
+
+        // Sent HTTP POST request to add customer
+        inputFile = getClass().getResource("add_customer.txt").getFile();
+        input = new File(inputFile);
+        PostMethod post = new PostMethod("http://localhost:9000/customers");
+        entity = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1");
+        post.setRequestEntity(entity);
+        httpclient = new HttpClient();
+
+        try {
+            int result = httpclient.executeMethod(post);
+            assertEquals(200, result);
+            System.out.println("Response status code: " + result);
+            System.out.println("Response body: ");
+            System.out.println(post.getResponseBodyAsString());
+        } finally {
+            // Release current connection to the connection pool once you are
+            // done
+            post.releaseConnection();
+        }
+
+        System.out.println("Client Invoking is succeeded!");
+        System.exit(0);
+    }
+
+    private static void printSource(Source source) {
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            StreamResult sr = new StreamResult(bos);
+            Transformer trans = TransformerFactory.newInstance().newTransformer();
+            Properties oprops = new Properties();
+            oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
+            trans.setOutputProperties(oprops);
+            trans.transform(source, sr);
+            System.out.println("**** Response ******");
+            System.out.println(bos.toString());
+            bos.close();
+            System.out.println();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/Client.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/Client.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/add_customer.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/add_customer.txt?rev=584525&view=auto
==============================================================================
--- incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/add_customer.txt
(added)
+++ incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/add_customer.txt
Sun Oct 14 03:43:08 2007
@@ -0,0 +1,4 @@
+<Customer>
+  <name>John</name>
+  <id>123456</id>
+</Customer> 
\ No newline at end of file

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/add_customer.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/add_customer.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/update_customer.txt
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/update_customer.txt?rev=584525&view=auto
==============================================================================
--- incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/update_customer.txt
(added)
+++ incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/update_customer.txt
Sun Oct 14 03:43:08 2007
@@ -0,0 +1,4 @@
+<Customer>
+  <name>John</name>
+  <id>123456</id>
+</Customer> 
\ No newline at end of file

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/update_customer.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/client/update_customer.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Customer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Customer.java?rev=584525&view=auto
==============================================================================
--- incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Customer.java
(added)
+++ incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Customer.java
Sun Oct 14 03:43:08 2007
@@ -0,0 +1,43 @@
+/**
+ * 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 demo.jaxrs.server;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "Customer")
+public class Customer {
+    private long id;
+    private String name;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Customer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Customer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/CustomerService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/CustomerService.java?rev=584525&view=auto
==============================================================================
--- incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/CustomerService.java
(added)
+++ incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/CustomerService.java
Sun Oct 14 03:43:08 2007
@@ -0,0 +1,104 @@
+/**
+ * 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 demo.jaxrs.server;
+
+import javax.ws.rs.HttpMethod;
+// import javax.ws.rs.ProduceMime;
+import javax.ws.rs.UriParam;
+import javax.ws.rs.UriTemplate;
+import javax.ws.rs.core.HttpContext;
+import javax.ws.rs.core.Response;
+
+// import javax.ws.rs.core.UriInfo;
+
+@UriTemplate("/customers/")
+public class CustomerService {
+    @HttpContext
+    UriInfo uriInfo;
+
+    long currentId = 1;
+    Map<Long, Customer> customers = new HashMap<Long, Customer>();
+
+    public CustomerServiceImpl() {
+        Customer customer = createCustomer();
+        customers.put(customer.getId(), customer);
+    }
+
+    @HttpMethod("GET")
+    @UriTemplate("/customers/{id}/")
+    Customer getCustomer(@UriParam("id") String id) {
+        System.out.println("----invoking getCustomer, Customer id is: " + id);
+        Customer c = customers.get(id);
+        return c;
+    }
+
+    @HttpMethod("PUT")
+    @UriTemplate("/customers/")
+    void updateCustomer(Customer customer) {
+        System.out.println("----invoking updateCustomer, Customer name is: " + customer.getName());
+        Customer c = customers.get(customer.getId());
+        Response r;
+        if (c != null) {
+            customers.put(customer.getId(), customer);
+            r = Response.Builder.ok().build();
+        } else {
+            r = Response.Builder.notModified().build();
+        }
+
+        return r;
+    }
+
+    @HttpMethod("POST")
+    @UriTemplate("/customers")
+    public Response addCustomer(Customer customer) {
+        System.out.println("----invoking addCustomer, customer name is: " + customer.getName());
+        customer.setId(++currentId);
+
+        customers.add(customer);
+
+        return Response.Builder.ok(customer).build();
+    }
+
+    @HttpMethod("DELETE")
+    @UriTemplate("/customers/{id}/")
+    public Response deleteCustomer(@UriParam("id") String id) {
+        System.out.println("----invoking deleteCustomer with id: " + id);
+        long idNumber = Long.parseLong(id);
+        boolean found = false;
+        Customer c = customers.get(idNumber);
+
+        Response r;
+        if (c != null) {
+            r = Response.Builder.ok().build();
+            customers.remove(i);
+        } else {
+            r = Response.Builder.notModified().build();
+        }
+
+        return r;
+    }
+
+    final Customer createCustomer() {
+        Customer c = new Customer();
+        c.setName("John");
+        c.setId(123);
+        return c;
+    }
+
+}

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/CustomerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/CustomerService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Server.java?rev=584525&view=auto
==============================================================================
--- incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Server.java
(added)
+++ incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Server.java
Sun Oct 14 03:43:08 2007
@@ -0,0 +1,44 @@
+/**
+ * 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 demo.jaxrs.server;
+
+import org.apache.cxf.jaxrs.JAXRSBindingFactory;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+
+public class Server {
+
+    protected Server() throws Exception {
+        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+        sf.setResourceClasses(BookStore.class);
+        sf.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
+        sf.setAddress("http://localhost:9080/xml/");
+
+        sf.create();
+    }
+
+    public static void main(String args[]) throws Exception {
+        new Server();
+        System.out.println("Server ready...");
+
+        Thread.sleep(5 * 60 * 1000);
+        System.out.println("Server exiting");
+        System.exit(0);
+    }
+}

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/branches/jliu/distribution/src/main/release/samples/restful_jaxrs/src/demo/jaxrs/server/Server.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/branches/jliu/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=584525&r1=584524&r2=584525&view=diff
==============================================================================
--- incubator/cxf/branches/jliu/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ incubator/cxf/branches/jliu/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Sun Oct 14 03:43:08 2007
@@ -147,9 +147,10 @@
     @HttpMethod("GET")
     @UriTemplate("/cd/{CDId}/")
     @ProduceMime("application/json")
-    //FIXME: getCDJSON and getCDs dont have to use different URLs, but we seems have problem

-    //to match "/cds/" and "/cds/123" correctly using ".*?" as suggested by spec. The former
-    //one's pattern is "/cds/(/)?" the later one is "/cds/(.*?)(/)?
+    // FIXME: getCDJSON and getCDs dont have to use different URLs, but it looks
+    // like we are having problem
+    // to match "/cds/" and "/cds/123" correctly using ".*?" as suggested by
+    // spec. The former one's pattern is "/cds/(/)?" the later one is "/cds/(.*?)(/)?
     public CD getCDJSON(@UriParam("CDId") String id) {
         System.out.println("----invoking getCDJSON with cdId: " + id);
         long idNumber = Long.parseLong(id);



Mime
View raw message