cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r806116 - in /cxf/branches/2.2.x-fixes: ./ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ ...
Date Thu, 20 Aug 2009 10:54:45 GMT
Author: sergeyb
Date: Thu Aug 20 10:54:44 2009
New Revision: 806116

URL: http://svn.apache.org/viewvc?rev=806116&view=rev
Log:
Merged revisions 798816 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r798816 | sergeyb | 2009-07-29 10:03:39 +0100 (Wed, 29 Jul 2009) | 1 line
  
  CXF-2314 : Initial support for wrapping CXF DataBindings into JAXRS providers, work in progress
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
      - copied unchanged from r798816, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingProviderTest.java
      - copied unchanged from r798816, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingProviderTest.java
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookDataBindingServer.java
      - copied unchanged from r798816, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookDataBindingServer.java
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
      - copied unchanged from r798816, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_databinding/
      - copied from r798816, cxf/trunk/systests/src/test/resources/jaxrs_databinding/
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_databinding/WEB-INF/
      - copied from r798816, cxf/trunk/systests/src/test/resources/jaxrs_databinding/WEB-INF/
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml
      - copied unchanged from r798816, cxf/trunk/systests/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_databinding/WEB-INF/web.xml
      - copied unchanged from r798816, cxf/trunk/systests/src/test/resources/jaxrs_databinding/WEB-INF/web.xml
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
    cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
    cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
    cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/pom.xml
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 20 10:54:44 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
 4,798654,798748-798749,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803129,803460,803493,803689,804002,804276,805784,805907,805909
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
 4,798654,798748-798749,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803129,803460,803493,803689,804002,804276,805784,805907,805909

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
Thu Aug 20 10:54:44 2009
@@ -63,6 +63,7 @@
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAnnotated;
+import org.apache.ws.commons.schema.XmlSchemaException;
 import org.apache.ws.commons.schema.XmlSchemaForm;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
 
@@ -332,6 +333,9 @@
 
     protected void initializeMessage(Service s, TypeMapping serviceTM, AbstractMessageContainer
container,
                                      int partType, Set<Type> deps) {
+        if (container == null) {
+            return;
+        }
         for (Iterator itr = container.getMessageParts().iterator(); itr.hasNext();) {
             MessagePartInfo part = (MessagePartInfo)itr.next();
 
@@ -372,6 +376,9 @@
     }
 
     protected void initializeMessageTypes(ServiceInfo s, AbstractMessageContainer container,
int partType) {
+        if (container == null) {
+            return;
+        }
         SchemaCollection col = s.getXmlSchemaCollection();
         for (Iterator itr = container.getMessageParts().iterator(); itr.hasNext();) {
             MessagePartInfo part = (MessagePartInfo)itr.next();
@@ -473,7 +480,19 @@
                 schema.setAttributeFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
 
                 for (Type t : entry.getValue()) {
-                    t.writeSchema(schema);
+                    try {
+                        t.writeSchema(schema);
+                    } catch (XmlSchemaException ex) {
+                        QName name = t.getSchemaType();
+                        String expected = " Schema for namespace '" + name.getNamespaceURI()

+                            + "' already contains type '" + name.getLocalPart() + "'";
+                        String message = ex.getMessage();
+                        if (expected.equals(message)) {
+                            continue;
+                        } else {
+                            throw ex;
+                        }
+                    }
                 }
 
                 if (schemaImportsXmime(schema)) {
@@ -586,12 +605,30 @@
     private Method getMethod(Service s, OperationInfo op) {
         MethodDispatcher md = (MethodDispatcher)s.get(MethodDispatcher.class.getName());
         SimpleMethodDispatcher smd = (SimpleMethodDispatcher)md;
-        return smd.getPrimaryMethod(op);
+        return smd != null ? smd.getPrimaryMethod(op) : null;
     }
 
     public Type getType(MessagePartInfo part) {
         return part2Type.get(part);
     }
+    
+    public MessagePartInfo getPartFromClass(Class<?> cls) {
+        for (Map.Entry<MessagePartInfo, Type> entry : part2Type.entrySet()) {
+            if (entry.getValue().getTypeClass() == cls) {
+                return entry.getKey();
+            }
+        }
+        return null;
+    }
+    
+    public Type getTypeFromClass(Class<?> cls) {
+        for (Type t : part2Type.values()) {
+            if (t.getTypeClass() == cls) {
+                return t;
+            }
+        }
+        return null;
+    }
 
     public Service getService() {
         return service;

Modified: cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
Thu Aug 20 10:54:44 2009
@@ -65,7 +65,8 @@
     }
 
     public Object read(QName name, XMLStreamReader input, Class typeClass) {
-        return read(input);
+        MessagePartInfo info = databinding.getPartFromClass(typeClass);
+        return info == null ? read(input) : read(info, input);
     }
 
     public Object read(XMLStreamReader input) {

Modified: cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
Thu Aug 20 10:54:44 2009
@@ -69,7 +69,9 @@
 
     public void write(Object obj, MessagePartInfo part, XMLStreamWriter output) {
         Type type = databinding.getType(part);
-
+        if (type == null) {
+            type = databinding.getTypeFromClass(obj.getClass());
+        }
         if (type == null) {
             throw new Fault(new Message("NO_MESSAGE_FOR_PART", LOG, part));
         }
@@ -105,7 +107,8 @@
                 }
             }
             ElementWriter writer = new ElementWriter(output);
-            MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
+            MessageWriter w2 = writer.getElementWriter(part != null ? part.getConcreteName()

+                : type.getSchemaType());
             type.writeObject(obj, w2, context);
             w2.close();
         } catch (DatabindingException e) {

Modified: cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Thu Aug 20 10:54:44 2009
@@ -327,13 +327,10 @@
 
         }
 
-        String tns = service.getName().getNamespaceURI();
+        String tns = getNamespaceToUse();
         CachedContextAndSchemas cachedContextAndSchemas = null;
         JAXBContext ctx = null;
         try {
-            if (service.getServiceInfos().size() > 0) {
-                tns = service.getServiceInfos().get(0).getInterface().getName().getNamespaceURI();
-            }
             cachedContextAndSchemas = createJAXBContextAndSchemas(contextClasses, tns);
         } catch (JAXBException e1) {
             // load jaxb needed class and try to create jaxb context for more
@@ -436,6 +433,19 @@
         }
     }
     
+    private String getNamespaceToUse() {
+        if ("true".equals(service.get("org.apache.cxf.databinding.namespace"))) {
+            return null;    
+        }
+        String tns = null;
+        if (service.getServiceInfos().size() > 0) {
+            tns = service.getServiceInfos().get(0).getInterface().getName().getNamespaceURI();
+        } else {
+            tns = service.getName().getNamespaceURI();
+        }
+        return tns;
+    }
+    
     public void setExtraClass(Class[] userExtraClass) {
         extraClass = userExtraClass;
     }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/pom.xml?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/pom.xml (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/pom.xml Thu Aug 20 10:54:44 2009
@@ -156,6 +156,26 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency> 
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-bindings-soap</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope> 
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-databinding-jaxb</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+<!--
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-databinding-sdo</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency> 
+-->
 	<dependency>
             <groupId>org.apache.xmlbeans</groupId>
             <artifactId>xmlbeans</artifactId>

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Thu Aug 20 10:54:44 2009
@@ -18,11 +18,13 @@
  */
 package org.apache.cxf.jaxrs;
 
+import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
+import java.util.Set;
 import java.util.logging.Logger;
 
 import javax.ws.rs.WebApplicationException;
@@ -34,12 +36,14 @@
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.UserResource;
+import org.apache.cxf.jaxrs.provider.DataBindingProvider;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
@@ -232,6 +236,9 @@
         if (entityProviders != null) {
             factory.setUserProviders(entityProviders); 
         }
+        if (getDataBinding() != null) {
+            setDataBindingProvider(factory, ep.getService());
+        }
         factory.setBus(getBus());
         if (schemaLocations != null) {
             factory.setSchemaLocations(schemaLocations);
@@ -240,6 +247,19 @@
         return factory;
     }
 
+    protected void setDataBindingProvider(ProviderFactory factory, Service s) {
+        DataBinding db = getDataBinding();
+        try {
+            Method m = db.getClass().getMethod("setAllClasses", new Class[]{Set.class});
+            Set<Class<?>> allClasses = ResourceUtils.getAllRequestResponseTypes(
+                                                         serviceFactory.getRealClassResourceInfo(),
false);
+            m.invoke(db, new Object[]{allClasses});
+        } catch (Exception ex) { 
+            db.initialize(s);
+        }
+        factory.setUserProviders(Collections.singletonList(new DataBindingProvider(db)));
+    }
+    
     public void setModelBeans(UserResource... resources) {
         setModelBeans(Arrays.asList(resources));
     }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
Thu Aug 20 10:54:44 2009
@@ -19,12 +19,14 @@
 
 package org.apache.cxf.jaxrs;
 
-import java.util.Collections;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Executor;
 
+import javax.ws.rs.core.Response;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.util.PackageUtils;
@@ -33,9 +35,18 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.AbstractAttributedInterceptorProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.Parameter;
+import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.invoker.Invoker;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.workqueue.SynchronousExecutor;
 
@@ -78,7 +89,62 @@
     }
     
     public List<ServiceInfo> getServiceInfos() {
-        return Collections.emptyList();
+        // try to convert to WSDL-centric model so that CXF DataBindings can get initialized
+        // might become useful too if we support wsdl2
+        
+        // make databindings to use databinding-specific information 
+        // like @XmlRootElement for ex to select a namespace
+        this.put("org.apache.cxf.databinding.namespace", "true");
+        
+        List<ServiceInfo> infos = new ArrayList<ServiceInfo>();
+        for (ClassResourceInfo cri : classResourceInfos) {
+            ServiceInfo si = new ServiceInfo();
+            infos.add(si);
+            QName qname = JAXRSUtils.getClassQName(cri.getServiceClass());
+            si.setName(qname);
+            InterfaceInfo inf = new InterfaceInfo(si, qname);
+            si.setInterface(inf);
+            for (OperationResourceInfo ori : cri.getMethodDispatcher().getOperationResourceInfos())
{
+                Method m = ori.getMethodToInvoke();
+                QName oname = new QName(qname.getNamespaceURI(), m.getName());
+                OperationInfo oi = inf.addOperation(oname);
+                createMessagePartInfo(oi, m.getReturnType(), qname, m, false);
+                for (Parameter pm : ori.getParameters()) {
+                    
+                    if (pm.getType() == ParameterType.REQUEST_BODY) {
+                        createMessagePartInfo(oi, 
+                                              ori.getMethodToInvoke().getParameterTypes()[pm.getIndex()],
+                                              qname, m, true);    
+                    }
+                }
+            }
+            
+        }
+        return infos;
+    }
+
+    private void createMessagePartInfo(OperationInfo oi, Class<?> type, QName qname,
Method m,
+                                       boolean input) {
+        if (type == void.class) {
+            return;
+        }
+        if (InjectionUtils.isPrimitive(type) || Response.class == type) {
+            return;
+        }
+        QName mName = new QName(qname.getNamespaceURI(), 
+                                (input ? "in" : "out") + m.getName());
+        MessageInfo ms = oi.createMessage(mName, 
+                                           input ? MessageInfo.Type.INPUT : MessageInfo.Type.OUTPUT);
+        if (input) {
+            oi.setInput("in", ms);
+        } else {
+            oi.setOutput("out", ms);
+        }
+        QName mpQName = JAXRSUtils.getClassQName(type);
+        MessagePartInfo mpi = ms.addMessagePart(mpQName);
+        mpi.setConcreteName(mpQName);
+        mpi.setTypeQName(mpQName);
+        mpi.setTypeClass(type);
     }
     
     public EndpointInfo getEndpointInfo(QName endpoint) {        

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Thu Aug 20 10:54:44 2009
@@ -20,7 +20,6 @@
 
 import java.io.IOException;
 import java.io.StringWriter;
-import java.lang.annotation.Annotation;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
@@ -39,7 +38,6 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.namespace.QName;
@@ -72,8 +70,8 @@
 import org.apache.cxf.jaxrs.model.Parameter;
 import org.apache.cxf.jaxrs.model.ParameterType;
 import org.apache.cxf.jaxrs.model.URITemplate;
-import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -111,7 +109,7 @@
         
         List<ClassResourceInfo> cris = getResourcesList(m, resource);
         
-        Set<Class<?>> jaxbTypes = getAllJaxbTypes(cris);
+        Set<Class<?>> jaxbTypes = ResourceUtils.getAllRequestResponseTypes(cris,
true);
         JAXBContext context = createJaxbContext(jaxbTypes);
         SchemaCollection coll = getSchemaCollection(context);
         JAXBContextProxy proxy = null;
@@ -473,31 +471,6 @@
         return prefix;
     }
     
-    private Set<Class<?>> getAllJaxbTypes(List<ClassResourceInfo> cris)
{
-        Set<Class<?>> types = new HashSet<Class<?>>();
-        for (ClassResourceInfo root : cris) {
-            for (OperationResourceInfo ori : root.getMethodDispatcher().getOperationResourceInfos())
{
-                checkJaxbType(ori.getMethodToInvoke().getReturnType(), types);
-                for (Parameter pm : ori.getParameters()) {
-                    if (pm.getType() == ParameterType.REQUEST_BODY) {
-                        checkJaxbType(ori.getMethodToInvoke().getParameterTypes()[pm.getIndex()],
types);
-                    }
-                }
-            }
-        }
-        
-        return types;
-    }
-
-    private void checkJaxbType(Class<?> type, Set<Class<?>> types) {
-        JAXBElementProvider provider = new JAXBElementProvider();
-        if (!InjectionUtils.isPrimitive(type) 
-            && !JAXBElement.class.isAssignableFrom(type)
-            && provider.isReadable(type, type, new Annotation[0], MediaType.APPLICATION_XML_TYPE))
{
-            types.add(type);
-        }        
-    }
-    
     private JAXBContext createJaxbContext(Set<Class<?>> classes) {
         if (classes.isEmpty()) {
             return null;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Thu Aug 20 10:54:44 2009
@@ -29,10 +29,12 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
+import java.util.Set;
 import java.util.logging.Logger;
 
 import javax.ws.rs.CookieParam;
@@ -44,6 +46,8 @@
 import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.xml.bind.JAXBElement;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -64,6 +68,7 @@
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.model.UserOperation;
 import org.apache.cxf.jaxrs.model.UserResource;
+import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
 import org.apache.cxf.resource.ResourceManager;
 
 public final class ResourceUtils {
@@ -391,6 +396,42 @@
         return resources;
     }
     
+
+    public static Set<Class<?>> getAllRequestResponseTypes(List<ClassResourceInfo>
cris, boolean jaxbOnly) {
+        Set<Class<?>> types = new HashSet<Class<?>>();
+        for (ClassResourceInfo root : cris) {
+            for (OperationResourceInfo ori : root.getMethodDispatcher().getOperationResourceInfos())
{
+                if (jaxbOnly) {
+                    checkJaxbType(ori.getMethodToInvoke().getReturnType(), types);
+                } else {
+                    types.add(ori.getMethodToInvoke().getReturnType());
+                }
+                for (Parameter pm : ori.getParameters()) {
+                    if (pm.getType() == ParameterType.REQUEST_BODY) {
+                        Class<?> inType = ori.getMethodToInvoke().getParameterTypes()[pm.getIndex()];
+                        if (jaxbOnly) {
+                            checkJaxbType(inType, types);
+                        } else {
+                            types.add(inType);
+                        }
+                    }
+                }
+                
+            }
+        }
+        
+        return types;
+    }
+
+    private static void checkJaxbType(Class<?> type, Set<Class<?>> types)
{
+        JAXBElementProvider provider = new JAXBElementProvider();
+        if (!InjectionUtils.isPrimitive(type) 
+            && !JAXBElement.class.isAssignableFrom(type)
+            && provider.isReadable(type, type, new Annotation[0], MediaType.APPLICATION_XML_TYPE))
{
+            types.add(type);
+        }        
+    }
+    
     private static UserResource getResourceFromElement(Element e) {
         UserResource resource = new UserResource();
         resource.setName(e.getAttribute("name"));

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Thu Aug
20 10:54:44 2009
@@ -37,6 +37,7 @@
             <xsd:element name="executor" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="features" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="binding" type="xsd:anyType" minOccurs="0" />  
+            <xsd:element name="dataBinding" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="inInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="invoker" type="xsd:anyType" minOccurs="0"/>
@@ -72,6 +73,7 @@
             <xsd:element name="executor" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="features" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="binding" type="xsd:anyType" minOccurs="0" />
+            <xsd:element name="dataBinding" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="inInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0"/>

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
Thu Aug 20 10:54:44 2009
@@ -347,7 +347,7 @@
                   MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
         String s = os.toString();
         String data = "{\"books2\":{\"books\":{\"@xsins.type\":\"superBook\",\"id\":123,"
-            + "\"name\":\"CXF Rocks\",\"superId\":124}}}";
+            + "\"name\":\"CXF Rocks\",\"state\":\"\",\"superId\":124}}}";
         assertEquals(data, s);
     }
     

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java
Thu Aug 20 10:54:44 2009
@@ -70,6 +70,10 @@
         return "";
     }
     
+    
+    public void setState(String s) {
+    }
+    
     public int hashCode() { 
         return name.hashCode() * 37 + new Long(id).hashCode();
     }

Modified: cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java?rev=806116&r1=806115&r2=806116&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
Thu Aug 20 10:54:44 2009
@@ -64,6 +64,13 @@
     }
     
     @GET
+    @Path("/bookstore/books/{id}")
+    @Produces("application/xml")
+    public Book getBookXml(@PathParam("id") Long id) {
+        return books.get(id);
+    }
+    
+    @GET
     @Path("/bookinfo")
     public Book getBookByUriInfo() throws Exception {
         MultivaluedMap<String, String> params = ui.getQueryParameters();



Mime
View raw message