cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r541592 - in /incubator/cxf/trunk: rt/bindings/http/src/main/java/org/apache/cxf/binding/http/ rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/ systests/src/test/java/org/apache/cxf/systest/rest/ testutils/src/main/ja...
Date Fri, 25 May 2007 09:13:23 GMT
Author: ffang
Date: Fri May 25 02:13:22 2007
New Revision: 541592

URL: http://svn.apache.org/viewvc?view=rev&rev=541592
Log:
[CXF-680] rest binding support input class without @XmlRootElement

Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Book.java   (with
props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundDetails.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundFault.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceImpl.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Books.java  
(with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetAnotherBook.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetBook.java
  (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/package-info.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java?view=diff&rev=541592&r1=541591&r2=541592
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
(original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
Fri May 25 02:13:22 2007
@@ -36,6 +36,7 @@
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.ws.commons.schema.XmlSchemaAnnotated;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
@@ -187,18 +188,31 @@
      * @param params
      * @return
      */
-    public static Document buildDocument(XmlSchemaElement element,
+    public static Document buildDocument(XmlSchemaAnnotated schemaAnnotation,
                                          Collection<SchemaInfo> schemas,
                                          List<Param> params) {
-        Document doc = DOMUtils.createDocument();
-        XmlSchemaComplexType cplxType = (XmlSchemaComplexType)element.getSchemaType();
-        if (cplxType == null) {
-            cplxType = (XmlSchemaComplexType)findSchemaType(schemas, element.getSchemaTypeName());
+        
+        XmlSchemaElement element = null;
+        QName qname = null;
+        XmlSchemaComplexType cplxType = null;
+        if (schemaAnnotation instanceof XmlSchemaElement) {
+            element = (XmlSchemaElement)schemaAnnotation;
+            qname = element.getQName();
+            cplxType = (XmlSchemaComplexType)element.getSchemaType();
+            if (cplxType == null) {
+                cplxType = (XmlSchemaComplexType)findSchemaType(schemas, element.getSchemaTypeName());
+            }
+        }
+        if (schemaAnnotation instanceof XmlSchemaComplexType) {
+            cplxType = (XmlSchemaComplexType)schemaAnnotation;
+            qname = cplxType.getQName();
         }
+        Document doc = DOMUtils.createDocument();
+         
+              
         XmlSchemaSequence seq = (XmlSchemaSequence)cplxType.getParticle();
-        Element e = doc.createElementNS(element.getQName().getNamespaceURI(), element.getQName()
-            .getLocalPart());
-        e.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, element.getQName().getNamespaceURI());
+        Element e = doc.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
+        e.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, qname.getNamespaceURI());
         doc.appendChild(e);
         
         if (seq == null || seq.getItems() == null) {
@@ -216,7 +230,7 @@
             }
             Element ec = doc.createElementNS(elChild.getQName().getNamespaceURI(), elChild.getQName()
                 .getLocalPart());
-            if (!elChild.getQName().getNamespaceURI().equals(element.getQName().getNamespaceURI()))
{
+            if (!elChild.getQName().getNamespaceURI().equals(qname.getNamespaceURI())) {
                 ec.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, elChild.getQName().getNamespaceURI());
             }
             if (param != null) {
@@ -229,19 +243,30 @@
     }
     
     public static Document interopolateParams(Document doc,
-                                              XmlSchemaElement element,
+                                              XmlSchemaAnnotated schemaAnnotation,
                                               Collection<SchemaInfo> schemas,
                                               List<Param> params) {
-        XmlSchemaComplexType cplxType = (XmlSchemaComplexType)element.getSchemaType();
-        if (cplxType == null) {
-            cplxType = (XmlSchemaComplexType)findSchemaType(schemas, element.getSchemaTypeName());
+        XmlSchemaElement element = null;
+        QName qname = null;
+        XmlSchemaComplexType cplxType = null;
+        if (schemaAnnotation instanceof XmlSchemaElement) {
+            element = (XmlSchemaElement)schemaAnnotation;
+            qname = element.getQName();
+            cplxType = (XmlSchemaComplexType)element.getSchemaType();
+            if (cplxType == null) {
+                cplxType = (XmlSchemaComplexType)findSchemaType(schemas, element.getSchemaTypeName());
+            }
+        }
+        if (schemaAnnotation instanceof XmlSchemaComplexType) {
+            cplxType = (XmlSchemaComplexType)schemaAnnotation;
+            qname = cplxType.getQName();
         }
         XmlSchemaSequence seq = (XmlSchemaSequence)cplxType.getParticle();
         Element root = doc.getDocumentElement();
         if (root == null) {
-            root = doc.createElementNS(element.getQName().getNamespaceURI(), 
-                                    element.getQName().getLocalPart());
-            root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, element.getQName().getNamespaceURI());
+            root = doc.createElementNS(qname.getNamespaceURI(), 
+                                    qname.getLocalPart());
+            root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, qname.getNamespaceURI());
             doc.appendChild(root);
         }
         
@@ -262,7 +287,7 @@
             if (ec == null) {
                 ec = doc.createElementNS(elChild.getQName().getNamespaceURI(), elChild.getQName()
                                          .getLocalPart());
-                if (!elChild.getQName().getNamespaceURI().equals(element.getQName().getNamespaceURI()))
{
+                if (!elChild.getQName().getNamespaceURI().equals(qname.getNamespaceURI()))
{
                     ec.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, elChild.getQName().getNamespaceURI());
                 }
                 

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java?view=diff&rev=541592&r1=541591&r2=541592
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/interceptor/URIParameterInInterceptor.java
Fri May 25 02:13:22 2007
@@ -48,7 +48,7 @@
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.staxutils.StaxUtils;
-import org.apache.ws.commons.schema.XmlSchemaElement;
+
 
 public class URIParameterInInterceptor extends AbstractPhaseInterceptor<Message> {
     private static final Logger LOG = Logger.getLogger(URIParameterInInterceptor.class.getName());
@@ -122,11 +122,11 @@
                 throw new Fault(e);
             }
             doc = IriDecoderHelper.interopolateParams(doc, 
-                                                      (XmlSchemaElement)part.getXmlSchema(),
+                                                      part.getXmlSchema(),
                                                       schemas,
                                                       params);
         } else {
-            doc = IriDecoderHelper.buildDocument((XmlSchemaElement)part.getXmlSchema(),
+            doc = IriDecoderHelper.buildDocument(part.getXmlSchema(),
                                                  schemas,
                                                  params);
         }

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
Fri May 25 02:13:22 2007
@@ -0,0 +1,120 @@
+/**
+ * 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 org.apache.cxf.systest.rest;
+
+
+
+import java.util.logging.Logger;
+
+
+import org.apache.cxf.binding.http.HttpBindingFactory;
+import org.apache.cxf.customer.book.Book;
+import org.apache.cxf.customer.book.BookService;
+import org.apache.cxf.customer.book.BookServiceImpl;
+import org.apache.cxf.customer.book.GetAnotherBook;
+import org.apache.cxf.customer.book.GetBook;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.service.invoker.BeanInvoker;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class RestClientServerBookTest extends AbstractBusClientServerTestBase {
+    static final Logger LOG = Logger.getLogger(RestClientServerBookTest.class.getName());
+    
+    public static class MyServer extends AbstractBusTestServerBase {
+
+        protected void run() {
+            BookServiceImpl serviceObj = new BookServiceImpl();
+            JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+            sf.setServiceClass(BookService.class);
+            // Use the HTTP Binding which understands the Java Rest Annotations
+            sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
+            sf.setAddress("http://localhost:9080/xml/");
+            sf.getServiceFactory().setInvoker(new BeanInvoker(serviceObj));
+
+            // Turn the "wrapped" style off. This means that CXF won't generate
+            // wrapper XML elements and we'll have prettier XML text. This
+            // means that we need to stick to one request and one response
+            // parameter though.
+            sf.getServiceFactory().setWrapped(false);
+
+            sf.create();
+        }
+
+        public static void main(String[] args) {
+            try {
+                MyServer s = new MyServer();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                LOG.info("done!");
+            }
+        }
+    }
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(MyServer.class));
+    }
+
+    @Test
+    public void testGetBookWithXmlRootElement() throws Exception {
+        JaxWsProxyFactoryBean sf = new JaxWsProxyFactoryBean();
+        sf.setServiceClass(BookService.class);
+
+        // Turn off wrapped mode to make our xml prettier
+        sf.getServiceFactory().setWrapped(false);
+
+        // Use the HTTP Binding which understands the Java Rest Annotations
+        sf.getClientFactoryBean().setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
+        sf.setAddress("http://localhost:9080/xml/");
+        BookService bs = (BookService)sf.create();
+        GetBook getBook = new GetBook();
+        getBook.setId(123);
+        Book book = bs.getBook(getBook);
+        assertEquals(book.getId(), (long)123);
+        assertEquals(book.getName(), "CXF in Action");
+    }
+    
+    @Test
+    public void testGetBookWithOutXmlRootElement() throws Exception {
+        JaxWsProxyFactoryBean sf = new JaxWsProxyFactoryBean();
+        sf.setServiceClass(BookService.class);
+
+        // Turn off wrapped mode to make our xml prettier
+        sf.getServiceFactory().setWrapped(false);
+
+        // Use the HTTP Binding which understands the Java Rest Annotations
+        sf.getClientFactoryBean().setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
+        sf.setAddress("http://localhost:9080/xml/");
+        BookService bs = (BookService)sf.create();
+        GetAnotherBook getAnotherBook = new GetAnotherBook();
+        getAnotherBook.setId(123);
+        Book book = bs.getAnotherBook(getAnotherBook);
+        assertEquals(book.getId(), (long)123);
+        assertEquals(book.getName(), "CXF in Action");
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Book.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Book.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Book.java (added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Book.java Fri
May 25 02:13:22 2007
@@ -0,0 +1,46 @@
+/**
+ * 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 org.apache.cxf.customer.book;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+// START SNIPPET: bean
+@XmlRootElement(name = "Book")
+public class Book {
+    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;
+    }
+}
+// END SNIPPET: bean

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Book.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Book.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundDetails.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundDetails.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundDetails.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundDetails.java
Fri May 25 02:13:22 2007
@@ -0,0 +1,36 @@
+/**
+ * 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 org.apache.cxf.customer.book;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class BookNotFoundDetails {
+    private long id;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundDetails.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundDetails.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundFault.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundFault.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundFault.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundFault.java
Fri May 25 02:13:22 2007
@@ -0,0 +1,36 @@
+/**
+ * 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 org.apache.cxf.customer.book;
+
+import javax.xml.ws.WebFault;
+
+@WebFault
+public class BookNotFoundFault extends Exception {
+    private BookNotFoundDetails details;
+
+    public BookNotFoundFault(BookNotFoundDetails details) {
+        super();
+        this.details = details;
+    }
+
+    public BookNotFoundDetails getFaultInfo() {
+        return details;
+    }
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundFault.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookNotFoundFault.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
Fri May 25 02:13:22 2007
@@ -0,0 +1,66 @@
+/**
+ * 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 org.apache.cxf.customer.book;
+
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+
+import org.codehaus.jra.Delete;
+import org.codehaus.jra.Get;
+import org.codehaus.jra.HttpResource;
+import org.codehaus.jra.Post;
+import org.codehaus.jra.Put;
+
+@WebService
+public interface BookService {
+
+    @Get
+    @HttpResource(location = "/books")
+    @WebResult(name = "Books")
+    Books getBooks();
+
+    @Get
+    @HttpResource(location = "/books/{id}")
+    Book getBook(@WebParam(name = "GetBook")
+                         GetBook getBook) throws BookNotFoundFault;
+
+    @Get
+    @HttpResource(location = "/books/another/{id}")
+    Book getAnotherBook(@WebParam(name = "GetAnotherBook")
+                         GetAnotherBook getAnotherBook) throws BookNotFoundFault;
+
+    
+    @Put
+    @HttpResource(location = "/books/{id}")
+    void updateBook(@WebParam(name = "Book")
+                        Book c);
+
+    @Post
+    @HttpResource(location = "/books")
+    long addBook(@WebParam(name = "Book")
+                     Book c);
+
+    @Delete
+    @HttpResource(location = "/books/{id}")
+    void deleteBook(@WebParam(name = "id")
+                        long id) throws BookNotFoundFault;
+
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceImpl.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceImpl.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceImpl.java
Fri May 25 02:13:22 2007
@@ -0,0 +1,124 @@
+/**
+ * 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 org.apache.cxf.customer.book;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jws.WebService;
+
+
+@WebService(endpointInterface = "org.apache.cxf.customer.book.BookService")
+public class BookServiceImpl implements BookService {
+    long currentId = 1;
+    Map books = new HashMap();
+
+    @SuppressWarnings("unchecked")
+    public BookServiceImpl() {
+        Book book = createBook();
+        System.out.println("Enregistre Book de id " + book.getId());
+        books.put(book.getId(), book);
+    }
+
+    @SuppressWarnings("unchecked")
+    public Books getBooks() {
+        for (Iterator iter = books.entrySet().iterator(); iter.hasNext();) { 
+            Map.Entry me = (Map.Entry)iter.next();
+            System.out.println("getBooks -> " + me.getKey() + " : " + me.getValue());
+        }
+        Books b = new Books();
+        b.setBooks((Book[])books.values().toArray(new Book[books.size()]));
+        return b;
+    }
+
+    public Book getBook(GetBook getBook) throws BookNotFoundFault {
+        for (Iterator iter = books.entrySet().iterator(); iter.hasNext();) { 
+            Map.Entry me = (Map.Entry)iter.next();
+            System.out.println("getBook -> " + me.getKey() + " : " 
+                               + ((Book)me.getValue()).getName() + ", " + ((Book)me.getValue()).getId());
+        }
+        System.out.println("Book de id " + getBook.getId());
+        Book b = (Book)books.get(((Long)getBook.getId()).longValue());
+
+        if (b == null) {
+            BookNotFoundDetails details = new BookNotFoundDetails();
+            details.setId(getBook.getId());
+            throw new BookNotFoundFault(details);
+        }
+        return b;
+    }
+
+    public Book getAnotherBook(GetAnotherBook getAnotherBook) throws BookNotFoundFault {
+        for (Iterator iter = books.entrySet().iterator(); iter.hasNext();) { 
+            Map.Entry me = (Map.Entry)iter.next();
+            System.out.println("getBook -> " + me.getKey() + " : " 
+                               + ((Book)me.getValue()).getName() + ", " + ((Book)me.getValue()).getId());
+        }
+        System.out.println("Book de id " + getAnotherBook.getId());
+        Book b = (Book)books.get(((Long)getAnotherBook.getId()).longValue());
+
+        if (b == null) {
+            BookNotFoundDetails details = new BookNotFoundDetails();
+            details.setId(getAnotherBook.getId());
+            throw new BookNotFoundFault(details);
+        }
+        return b;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void updateBook(Book b) {
+        books.put(b.getId(), b);
+        for (Iterator iter = books.entrySet().iterator(); iter.hasNext();) { 
+            Map.Entry me = (Map.Entry)iter.next();
+            System.out.println("updateBook -> " + me.getKey() + " : " + me.getValue());
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public long addBook(Book b) {
+        long id = ++currentId;
+        System.out.println("addBook : " + b.getName());
+        b.setId(id);
+        books.put(id, b);
+        for (Iterator iter = books.entrySet().iterator(); iter.hasNext();) { 
+            Map.Entry me = (Map.Entry)iter.next();
+            System.out.println("addBook -> " + me.getKey() + " : " 
+                               + ((Book)me.getValue()).getName() + ", " + ((Book)me.getValue()).getId());
+        }
+
+        return b.getId();
+    }
+
+    public void deleteBook(long id) {
+        books.remove(id);
+        for (Iterator iter = books.entrySet().iterator(); iter.hasNext();) { 
+            Map.Entry me = (Map.Entry)iter.next();
+            System.out.println("deleteBook -> " + me.getKey() + " : " + me.getValue());
+        }
+    }
+
+    final Book createBook() {
+        Book b = new Book();
+        b.setName("CXF in Action");
+        b.setId(123);
+        return b;
+    }
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Books.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Books.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Books.java (added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Books.java Fri
May 25 02:13:22 2007
@@ -0,0 +1,35 @@
+/**
+ * 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 org.apache.cxf.customer.book;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Books {
+    private Book[] books;
+
+    public Book[] getBooks() {
+        return books;
+    }
+
+    public void setBooks(Book[] b) {
+        this.books = b;
+    }
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Books.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/Books.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetAnotherBook.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetAnotherBook.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetAnotherBook.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetAnotherBook.java
Fri May 25 02:13:22 2007
@@ -0,0 +1,35 @@
+/**
+ * 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 org.apache.cxf.customer.book;
+
+
+public class GetAnotherBook {
+ 
+    private long id;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetAnotherBook.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetAnotherBook.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetBook.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetBook.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetBook.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetBook.java
Fri May 25 02:13:22 2007
@@ -0,0 +1,36 @@
+/**
+ * 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 org.apache.cxf.customer.book;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "GetBook")
+public class GetBook {
+    private long id;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetBook.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/GetBook.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/package-info.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/package-info.java?view=auto&rev=541592
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/package-info.java
(added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/package-info.java
Fri May 25 02:13:22 2007
@@ -0,0 +1,25 @@
+/**
+ * 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.
+ */
+
+
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://book.acme.com", 
+                                     elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.apache.cxf.customer.book;
+
+

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message