You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/10/16 22:30:00 UTC

svn commit: r1532894 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/mai...

Author: sergeyb
Date: Wed Oct 16 20:29:59 2013
New Revision: 1532894

URL: http://svn.apache.org/r1532894
Log:
[CXF-5336] Various WADLGenerator improvements

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ResourceTypes.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
    cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Wed Oct 16 20:29:59 2013
@@ -254,9 +254,11 @@ public class JAXRSInInterceptor extends 
         
         Object mapProp = message.getContextualProperty("map.cxf.interceptor.fault");
         if (mapProp == null || MessageUtils.isTrue(mapProp)) {
-        
-            Response r = JAXRSUtils.convertFaultToResponse(message.getContent(Exception.class), 
-                                                           message);
+            Throwable ex = message.getContent(Exception.class);
+            if (ex instanceof Fault) {
+                ex = ((Fault)ex).getCause();
+            }
+            Response r = JAXRSUtils.convertFaultToResponse(ex, message);
             if (r != null) {
                 message.removeContent(Exception.class);
                 message.getInterceptorChain().setFaultObserver(null);

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java Wed Oct 16 20:29:59 2013
@@ -57,9 +57,11 @@ public class JAXRSOutExceptionMapperInte
             // Exception comes from JAXRSOutInterceptor or the one which follows it
             return;
         }
-        
-        Response r = JAXRSUtils.convertFaultToResponse(message.getContent(Exception.class), 
-                                                       message);
+        Throwable ex = message.getContent(Exception.class);
+        if (ex instanceof Fault) {
+            ex = ((Fault)ex).getCause();
+        }
+        Response r = JAXRSUtils.convertFaultToResponse(ex, message);
         if (r != null) {
             message.removeContent(Exception.class);
             message.getInterceptorChain().setFaultObserver(null);

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ResourceTypes.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ResourceTypes.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ResourceTypes.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ResourceTypes.java Wed Oct 16 20:29:59 2013
@@ -27,6 +27,7 @@ import javax.xml.namespace.QName;
 public class ResourceTypes {
     private Map<Class<?>, Type> allTypes = new HashMap<Class<?>, Type>();
     private Map<Class<?>, QName> collectionMap = new HashMap<Class<?>, QName>();
+    private Map<Class<?>, QName> xmlNameMap = new HashMap<Class<?>, QName>();
     public Map<Class<?>, Type> getAllTypes() {
         return allTypes;
     }
@@ -36,7 +37,7 @@ public class ResourceTypes {
     public Map<Class<?>, QName> getCollectionMap() {
         return collectionMap;
     }
-    public void setCollectionMap(Map<Class<?>, QName> collectionMap) {
-        this.collectionMap = collectionMap;
+    public Map<Class<?>, QName> getXmlNameMap() {
+        return xmlNameMap;
     }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java Wed Oct 16 20:29:59 2013
@@ -101,6 +101,7 @@ public abstract class AbstractJAXBProvid
     protected Map<String, String> jaxbElementClassMap = Collections.emptyMap();
     protected boolean unmarshalAsJaxbElement;
     protected boolean marshalAsJaxbElement;
+    protected boolean xmlTypeAsJaxbElementOnly;
     
     protected Map<String, String> outElementsMap;
     protected Map<String, String> outAppendMap;
@@ -218,6 +219,10 @@ public abstract class AbstractJAXBProvid
         marshalAsJaxbElement = value;
     }
     
+    public void setXmlTypeAsJaxbElementOnly(boolean value) {
+        this.xmlTypeAsJaxbElementOnly = value;
+    }
+    
     public void setJaxbElementClassNames(List<String> names) {
         jaxbElementClassNames = names;
     }
@@ -240,10 +245,14 @@ public abstract class AbstractJAXBProvid
         return null;
     }
     
-    protected static boolean isXmlRoot(Class<?> cls) {
+    protected boolean isXmlRoot(Class<?> cls) {
         return cls.getAnnotation(XmlRootElement.class) != null;
     }
     
+    protected boolean isXmlType(Class<?> cls) {
+        return cls.getAnnotation(XmlType.class) != null;
+    }
+    
     @SuppressWarnings({ "unchecked", "rawtypes" })
     protected Object convertToJaxbElementIfNeeded(Object obj, Class<?> cls, Type genericType) 
         throws Exception {
@@ -299,7 +308,8 @@ public abstract class AbstractJAXBProvid
             }
         }
         
-        return marshalAsJaxbElement || isSupported(type, genericType, anns);
+        return marshalAsJaxbElement && (!xmlTypeAsJaxbElementOnly || isXmlType(type)) 
+            || isSupported(type, genericType, anns);
     }
     public void writeTo(T t, Type genericType, Annotation annotations[], 
                  MediaType mediaType, 
@@ -352,7 +362,7 @@ public abstract class AbstractJAXBProvid
         XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
         if (root != null) {
             return getQNameFromNamespaceAndName(root.namespace(), root.name(), cls, pluralName);
-        } else if (cls.getAnnotation(XmlType.class) != null) {
+        } else if (isXmlType(cls)) {
             XmlType xmlType = cls.getAnnotation(XmlType.class);
             return getQNameFromNamespaceAndName(xmlType.namespace(), xmlType.name(), cls, pluralName);
         } else {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Wed Oct 16 20:29:59 2013
@@ -1217,4 +1217,13 @@ public abstract class ProviderFactory {
         }
         return theProviders;
     }
+    
+    public MessageBodyWriter<?> getRegisteredJaxbWriter() {
+        for (ProviderInfo<MessageBodyWriter<?>> pi : this.messageWriters) {    
+            if (pi.getProvider().getClass().getName().equals(JAXB_PROVIDER_NAME)) {
+                return pi.getProvider();
+            }
+        }
+        return null;
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java Wed Oct 16 20:29:59 2013
@@ -57,10 +57,12 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -525,9 +527,15 @@ public final class ResourceUtils {
 
     public static ResourceTypes getAllRequestResponseTypes(List<ClassResourceInfo> cris, 
                                                            boolean jaxbOnly) {
+        return getAllRequestResponseTypes(cris, jaxbOnly, null);
+    }
+    
+    public static ResourceTypes getAllRequestResponseTypes(List<ClassResourceInfo> cris, 
+                                                           boolean jaxbOnly,
+                                                           MessageBodyWriter<?> jaxbWriter) {
         ResourceTypes types = new ResourceTypes();
         for (ClassResourceInfo resource : cris) {
-            getAllTypesForResource(resource, types, jaxbOnly);
+            getAllTypesForResource(resource, types, jaxbOnly, jaxbWriter);
         }
         return types;
     }
@@ -545,7 +553,8 @@ public final class ResourceUtils {
     
     private static void getAllTypesForResource(ClassResourceInfo resource, 
                                                ResourceTypes types,
-                                               boolean jaxbOnly) {
+                                               boolean jaxbOnly,
+                                               MessageBodyWriter<?> jaxbWriter) {
         for (OperationResourceInfo ori : resource.getMethodDispatcher().getOperationResourceInfos()) {
             Method method = ori.getMethodToInvoke();
             Class<?> realReturnType = method.getReturnType();
@@ -556,7 +565,7 @@ public final class ResourceUtils {
             Type type = method.getGenericReturnType();
             if (jaxbOnly) {
                 checkJaxbType(cls, realReturnType == Response.class ? cls : type, types, 
-                    method.getAnnotations());
+                    method.getAnnotations(), jaxbWriter);
             } else {
                 types.getAllTypes().put(cls, type);
             }
@@ -567,7 +576,7 @@ public final class ResourceUtils {
                     Type paramType = method.getGenericParameterTypes()[pm.getIndex()];
                     if (jaxbOnly) {
                         checkJaxbType(inType, paramType, types, 
-                                      method.getParameterAnnotations()[pm.getIndex()]);
+                                      method.getParameterAnnotations()[pm.getIndex()], jaxbWriter);
                     } else {
                         types.getAllTypes().put(inType, paramType);
                     }
@@ -579,7 +588,7 @@ public final class ResourceUtils {
         
         for (ClassResourceInfo sub : resource.getSubResources()) {
             if (!isRecursiveSubResource(resource, sub)) {
-                getAllTypesForResource(sub, types, jaxbOnly);
+                getAllTypesForResource(sub, types, jaxbOnly, jaxbWriter);
             }
         }
     }
@@ -597,26 +606,40 @@ public final class ResourceUtils {
     private static void checkJaxbType(Class<?> type, 
                                       Type genericType, 
                                       ResourceTypes types,
-                                      Annotation[] anns) {
+                                      Annotation[] anns,
+                                      MessageBodyWriter<?> jaxbWriter) {
+        boolean isCollection = false;
         if (InjectionUtils.isSupportedCollectionOrArray(type)) {
             type = InjectionUtils.getActualType(genericType);
-            XMLName name = AnnotationUtils.getAnnotation(anns, XMLName.class);
-            if (name != null) {
-                types.getCollectionMap().put(type, JAXRSUtils.convertStringToQName(name.value()));
-            }
+            isCollection = true;
+        }
+        if (type == null
+            || InjectionUtils.isPrimitive(type)
+            || JAXBElement.class.isAssignableFrom(type)
+            || Response.class.isAssignableFrom(type)
+            || type.isInterface()) {
+            return;
         }
-        JAXBElementProvider<?> provider = new JAXBElementProvider<Object>();
-        if (type != null 
-            && !InjectionUtils.isPrimitive(type) 
-            && !JAXBElement.class.isAssignableFrom(type)
-            && provider.isReadable(type, type, new Annotation[0], MediaType.APPLICATION_XML_TYPE)) {
+        
+        MessageBodyWriter<?> writer = jaxbWriter;
+        if (writer == null) {
+            writer = new JAXBElementProvider<Object>();
+        }
+        if (writer.isWriteable(type, type, anns, MediaType.APPLICATION_XML_TYPE)) {
             types.getAllTypes().put(type, type);
-            
             Class<?> genCls = InjectionUtils.getActualType(genericType);
             if (genCls != type && genCls != null && genCls != Object.class 
                 && !InjectionUtils.isSupportedCollectionOrArray(genCls)) {
                 types.getAllTypes().put(genCls, genCls);
             }
+            
+            XMLName name = AnnotationUtils.getAnnotation(anns, XMLName.class);
+            QName qname = name != null ? JAXRSUtils.convertStringToQName(name.value()) : null;
+            if (isCollection) {
+                types.getCollectionMap().put(type, qname);
+            } else {
+                types.getXmlNameMap().put(type, qname);
+            }
         }
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Wed Oct 16 20:29:59 2013
@@ -120,6 +120,7 @@ public class JAXRSUtilsTest extends Asse
     
     @Test
     public void testFormParametersUTF8Encoding() throws Exception {
+        JAXRSUtils.intersectMimeTypes("application/json", "application/json+v2");
         doTestFormParamsWithEncoding("UTF-8", true);
         doTestFormParamsWithEncoding("UTF-8", false);
     }

Modified: cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java (original)
+++ cxf/trunk/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java Wed Oct 16 20:29:59 2013
@@ -56,8 +56,10 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.MessageBodyWriter;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLStreamException;
@@ -97,6 +99,7 @@ import org.apache.cxf.jaxrs.model.Parame
 import org.apache.cxf.jaxrs.model.ParameterType;
 import org.apache.cxf.jaxrs.model.ResourceTypes;
 import org.apache.cxf.jaxrs.model.URITemplate;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
@@ -133,6 +136,7 @@ public class WadlGenerator implements Co
     private boolean linkJsonToXmlSchema;
     private boolean useJaxbContextForQnames = true;
     private boolean supportCollections = true;
+    private boolean supportJaxbXmlType = true;
 
     private List<String> externalSchemasCache;
     private List<URI> externalSchemaLinks;
@@ -145,23 +149,13 @@ public class WadlGenerator implements Co
     private String applicationTitle;
     private String nsPrefix = DEFAULT_NS_PREFIX;
     private MediaType defaultMediaType = DEFAULT_MEDIA_TYPE;
-
+    private Bus bus;
+    
     public WadlGenerator() {
-
     }
-
-    public WadlGenerator(WadlGenerator other) {
-        this.wadlNamespace = other.wadlNamespace;
-        this.externalQnamesMap = other.externalQnamesMap;
-        this.externalSchemaLinks = other.externalSchemaLinks;
-        this.externalSchemasCache = other.externalSchemasCache;
-        this.ignoreMessageWriters = other.ignoreMessageWriters;
-        this.privateAddresses = other.privateAddresses;
-        this.resolver = other.resolver;
-        this.addResourceAndMethodIds = other.addResourceAndMethodIds;
-        this.singleResourceMultipleMethods = other.singleResourceMultipleMethods;
-        this.useJaxbContextForQnames = other.useJaxbContextForQnames;
-        this.useSingleSlashResource = other.useSingleSlashResource;
+    
+    public WadlGenerator(Bus bus) {
+        this.bus = bus;
     }
 
     public void filter(ContainerRequestContext context) {
@@ -221,9 +215,13 @@ public class WadlGenerator implements Co
 
         List<ClassResourceInfo> cris = getResourcesList(m, ui);
 
-        ResourceTypes resourceTypes = ResourceUtils.getAllRequestResponseTypes(cris, useJaxbContextForQnames);
+        MessageBodyWriter<?> jaxbWriter = useJaxbContextForQnames 
+            ? ServerProviderFactory.getInstance(m).getRegisteredJaxbWriter() : null;
+        ResourceTypes resourceTypes = ResourceUtils.getAllRequestResponseTypes(cris, 
+                                                                               useJaxbContextForQnames,
+                                                                               jaxbWriter);
         Set<Class<?>> allTypes = resourceTypes.getAllTypes().keySet();
-
+        
         JAXBContext jaxbContext = useJaxbContextForQnames ? ResourceUtils
             .createJaxbContext(new HashSet<Class<?>>(allTypes), null, null) : null;
 
@@ -769,19 +767,20 @@ public class WadlGenerator implements Co
                 sb.append("</representation>");
             } else {
                 boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(type);
+                Class<?> theActualType = null;
                 if (isCollection) {
-                    type = InjectionUtils.getActualType(!inbound ? opMethod.getGenericReturnType() : opMethod
+                    theActualType = InjectionUtils.getActualType(!inbound ? opMethod.getGenericReturnType() : opMethod
                         .getGenericParameterTypes()[getRequestBodyParam(ori).getIndex()]);
                 } else {
-                    type = ResourceUtils.getActualJaxbType(type, opMethod, inbound);
+                    theActualType = ResourceUtils.getActualJaxbType(type, opMethod, inbound);
                 }
                 if (isJson) {
-                    sb.append(" element=\"").append(type.getSimpleName()).append("\"");
+                    sb.append(" element=\"").append(theActualType.getSimpleName()).append("\"");
                 } else if (qnameResolver != null
                            && (mt.getSubtype().contains("xml") || linkJsonToXmlSchema
                                                                   && mt.getSubtype().contains("json"))
-                           && jaxbTypes.contains(type)) {
-                    generateQName(sb, qnameResolver, clsMap, type, isCollection,
+                           && jaxbTypes.contains(theActualType)) {
+                    generateQName(sb, qnameResolver, clsMap, theActualType, isCollection,
                                   getBodyAnnotations(ori, inbound));
                 }
                 addDocsAndCloseElement(sb, anns, "representation", docCategory, allowDefault, isJson);
@@ -1011,13 +1010,14 @@ public class WadlGenerator implements Co
                 clsMap.put(type, qname);
             } else {
                 XMLName name = AnnotationUtils.getAnnotation(annotations, XMLName.class);
-                QName collectionName = null;
+                String localPart = null;
                 if (name != null) {
-                    QName tempQName = JAXRSUtils.convertStringToQName(name.value());
-                    collectionName = new QName(qname.getNamespaceURI(), tempQName.getLocalPart(),
-                                               qname.getPrefix());
-                    writeQName(sb, collectionName);
+                    localPart = JAXRSUtils.convertStringToQName(name.value()).getLocalPart();
+                } else {
+                    localPart = qname.getLocalPart() + "s";    
                 }
+                QName collectionName = new QName(qname.getNamespaceURI(), localPart, qname.getPrefix());
+                writeQName(sb, collectionName);
             }
         }
     }
@@ -1039,17 +1039,58 @@ public class WadlGenerator implements Co
                                                                                      String.class,
                                                                                      DOMResult.class))) {
                 Document doc = (Document)r.getNode();
+                ElementQNameResolver theResolver = createElementQNameResolver(context);
+                String tns = doc.getDocumentElement().getAttribute("targetNamespace");
+                
+                String tnsDecl = 
+                    doc.getDocumentElement().getAttribute("xmlns:tns");
+                String tnsPrefix = tnsDecl != null && tnsDecl.equals(tns) ? "tns:" : "";
+                
+                if (supportJaxbXmlType) {
+                    for (Class<?> cls : resourceTypes.getAllTypes().keySet()) {
+                        if (cls.getAnnotation(XmlRootElement.class) != null) {
+                            continue;
+                        }
+                        XmlType root = cls.getAnnotation(XmlType.class);
+                        if (root != null) {
+                            QName typeName = theResolver.resolve(cls, new Annotation[] {},
+                                                           Collections.<Class<?>, QName> emptyMap());
+                            if (typeName != null && tns.equals(typeName.getNamespaceURI())) {
+                                QName elementName = resourceTypes.getXmlNameMap().get(cls);
+                                if (elementName == null) {
+                                    elementName = typeName;
+                                }
+                                Element newElement = doc
+                                    .createElementNS(Constants.URI_2001_SCHEMA_XSD, "xs:element");
+                                newElement.setAttribute("name", elementName.getLocalPart());
+                                newElement.setAttribute("type", tnsPrefix + typeName.getLocalPart());
+                                doc.getDocumentElement().appendChild(newElement);
+                            }
+                        }
+                    }
+                }
                 if (supportCollections && !resourceTypes.getCollectionMap().isEmpty()) {
-                    ElementQNameResolver theResolver = createElementQNameResolver(context);
-                    String tns = doc.getDocumentElement().getAttribute("targetNamespace");
                     for (Map.Entry<Class<?>, QName> entry : resourceTypes.getCollectionMap().entrySet()) {
-                        if (tns.equals(entry.getValue().getNamespaceURI())) {
+                        QName colQName = entry.getValue();
+                        if (colQName == null) {
+                            colQName = theResolver.resolve(entry.getKey(), new Annotation[] {},
+                                                Collections.<Class<?>, QName> emptyMap());
+                            if (colQName != null) {
+                                colQName = new QName(colQName.getNamespaceURI(), 
+                                                     colQName.getLocalPart() + "s",
+                                                     colQName.getPrefix());
+                            }
+                        }
+                        if (colQName == null) {
+                            continue;
+                        }
+                        if (tns.equals(colQName.getNamespaceURI())) {
                             QName typeName = theResolver.resolve(entry.getKey(), new Annotation[] {},
                                                                  Collections.<Class<?>, QName> emptyMap());
                             if (typeName != null) {
                                 Element newElement = doc
                                     .createElementNS(Constants.URI_2001_SCHEMA_XSD, "xs:element");
-                                newElement.setAttribute("name", entry.getValue().getLocalPart());
+                                newElement.setAttribute("name", colQName.getLocalPart());
                                 Element ctElement = doc.createElementNS(Constants.URI_2001_SCHEMA_XSD,
                                                                         "xs:complexType");
                                 newElement.appendChild(ctElement);
@@ -1059,7 +1100,7 @@ public class WadlGenerator implements Co
                                 Element xsElement = doc.createElementNS(Constants.URI_2001_SCHEMA_XSD,
                                                                         "xs:element");
                                 seqElement.appendChild(xsElement);
-                                xsElement.setAttribute("ref", "tns:" + typeName.getLocalPart());
+                                xsElement.setAttribute("ref", tnsPrefix + typeName.getLocalPart());
                                 xsElement.setAttribute("minOccurs", "0");
                                 xsElement.setAttribute("maxOccurs", "unbounded");
 
@@ -1070,8 +1111,6 @@ public class WadlGenerator implements Co
                 }
                 DOMSource source = new DOMSource(doc, r.getSystemId());
                 schemas.add(source);
-                String tns = ((Document)source.getNode()).getDocumentElement()
-                    .getAttribute("targetNamespace");
                 if (!StringUtils.isEmpty(tns)) {
                     targetNamespaces.add(tns);
                 }
@@ -1090,20 +1129,26 @@ public class WadlGenerator implements Co
         return xmlSchemaCollection;
     }
 
+    private QName getJaxbQName(String name, String namespace, Class<?> type, Map<Class<?>, QName> clsMap) {
+
+        QName qname = getQNameFromParts(name, namespace, type, clsMap);
+        if (qname != null) {
+            return qname;
+        }
+        String ns = JAXBUtils.getPackageNamespace(type);
+        if (ns != null) {
+            return getQNameFromParts(name, ns, type, clsMap);
+        } else {
+            return null;
+        }
+        
+    }
+    
     private QName getJaxbQName(JAXBContextProxy jaxbProxy, Class<?> type, Map<Class<?>, QName> clsMap) {
 
         XmlRootElement root = type.getAnnotation(XmlRootElement.class);
         if (root != null) {
-            QName qname = getQNameFromParts(root.name(), root.namespace(), type, clsMap);
-            if (qname != null) {
-                return qname;
-            }
-            String ns = JAXBUtils.getPackageNamespace(type);
-            if (ns != null) {
-                return getQNameFromParts(root.name(), ns, type, clsMap);
-            } else {
-                return null;
-            }
+            return getJaxbQName(root.name(), root.namespace(), type, clsMap);
         }
 
         try {
@@ -1302,7 +1347,7 @@ public class WadlGenerator implements Co
                     if (d.docuri().startsWith(CLASSPATH_PREFIX)) {
                         String path = d.docuri().substring(CLASSPATH_PREFIX.length());
                         is = ResourceUtils.getClasspathResourceStream(path, SchemaHandler.class,
-                                                                      BusFactory.getDefaultBus());
+                            bus == null ? BusFactory.getDefaultBus() : bus);
                         if (is != null) {
                             try {
                                 sb.append(IOUtils.toString(is));
@@ -1355,7 +1400,8 @@ public class WadlGenerator implements Co
     }
 
     private void loadSchemasIntoCache(String loc) throws Exception {
-        InputStream is = ResourceUtils.getResourceStream(loc, BusFactory.getDefaultBus());
+        InputStream is = ResourceUtils.getResourceStream(loc, 
+            bus == null ? BusFactory.getDefaultBus() : bus);
         if (is == null) {
             return;
         }
@@ -1556,13 +1602,28 @@ public class WadlGenerator implements Co
     private class JaxbContextQNameResolver implements ElementQNameResolver {
 
         private JAXBContextProxy proxy;
-
+        
         public JaxbContextQNameResolver(JAXBContextProxy proxy) {
             this.proxy = proxy;
         }
 
         public QName resolve(Class<?> type, Annotation[] annotations, Map<Class<?>, QName> clsMap) {
-            return getJaxbQName(proxy, type, clsMap);
+            QName qname = WadlGenerator.this.getJaxbQName(proxy, type, clsMap);
+            if (qname == null && supportJaxbXmlType) {
+                XmlType root = type.getAnnotation(XmlType.class);
+                if (root != null) {
+                    XMLName name = AnnotationUtils.getAnnotation(annotations, XMLName.class);
+                    if (name == null) {
+                        qname = getJaxbQName(root.name(), root.namespace(), type, clsMap);
+                    } else {
+                        QName tempQName = JAXRSUtils.convertStringToQName(name.value());
+                        qname = new QName(tempQName.getNamespaceURI(),
+                                          tempQName.getLocalPart(),
+                                          getPrefix(tempQName.getNamespaceURI(), clsMap));
+                    }
+                }
+            }
+            return qname;
         }
 
     }
@@ -1658,6 +1719,10 @@ public class WadlGenerator implements Co
         this.defaultMediaType = JAXRSUtils.toMediaType(mt);
     }
 
+    public void setSupportJaxbXmlType(boolean supportJaxbXmlType) {
+        this.supportJaxbXmlType = supportJaxbXmlType;
+    }
+
     private static class SchemaConverter extends DelegatingXMLStreamWriter {
         private static final String SCHEMA_LOCATION = "schemaLocation";
         private Map<String, String> locsMap;

Modified: cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java (original)
+++ cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java Wed Oct 16 20:29:59 2013
@@ -70,6 +70,16 @@ public class BookStore implements BookDe
         return Collections.emptyList();
     }
     
+    @GET
+    @Path("thebooks2")
+    @Produces("application/xml")
+    @Descriptions({ 
+        @Description(value = "Get Books2", target = DocTarget.METHOD)
+    })
+    public List<Book2> getBooks2(@PathParam("id") Long id) {
+        return Collections.emptyList();
+    }
+    
     @GET 
     @Produces("text/plain")
     public String getName(@PathParam("id") Long id, @QueryParam("") QueryBean query) {

Modified: cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java (original)
+++ cxf/trunk/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java Wed Oct 16 20:29:59 2013
@@ -45,6 +45,7 @@ import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
 import org.apache.cxf.jaxrs.impl.ContainerRequestContextImpl;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
@@ -212,7 +213,7 @@ public class WadlGeneratorTest extends A
         checkResponse(r);
         Document doc = StaxUtils.read(new StringReader(r.getEntity().toString()));
         checkDocs(doc.getDocumentElement(), "My Application", "", "");
-        checkGrammars(doc.getDocumentElement(), "thebook", "books", "thebook2", "thechapter");
+        checkGrammars(doc.getDocumentElement(), "thebook", "books", "thebook2s", "thebook2", "thechapter");
         List<Element> els = getWadlResourcesInfo(doc, "http://localhost:8080/baz", 1);
         checkBookStoreInfo(els.get(0), 
                            "ns1:thebook", 
@@ -305,7 +306,7 @@ public class WadlGeneratorTest extends A
                      r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE).toString());
         String wadl = r.getEntity().toString();
         Document doc = StaxUtils.read(new StringReader(wadl));
-        checkGrammars(doc.getDocumentElement(), "thebook", "books", "thebook2", "thechapter");
+        checkGrammars(doc.getDocumentElement(), "thebook", "books", "thebook2s", "thebook2", "thechapter");
         List<Element> els = getWadlResourcesInfo(doc, "http://localhost:8080/baz", 2);
         checkBookStoreInfo(els.get(0), "prefix1:thebook", "prefix1:thebook2", "prefix1:thechapter");
         Element orderResource = els.get(1);
@@ -321,11 +322,12 @@ public class WadlGeneratorTest extends A
                                String bookEl,
                                String book2El, 
                                String chapterEl) {
-        checkGrammars(appElement, bookEl, null, book2El, chapterEl);
+        checkGrammars(appElement, bookEl, null, null, book2El, chapterEl);
     }
     private void checkGrammars(Element appElement, 
                                String bookEl,
                                String booksEl,
+                               String booksEl2,
                                String book2El,
                                String chapterEl) {
         List<Element> grammarEls = DOMUtils.getChildrenWithName(appElement, WadlGenerator.WADL_NS, 
@@ -343,7 +345,7 @@ public class WadlGeneratorTest extends A
         int size = book2El == null ? 2 : 3;
         int elementSize = size;
         if (booksEl != null) {
-            elementSize++;
+            elementSize += 2;
         }
         
         assertEquals(elementSize, elementEls.size());
@@ -356,6 +358,9 @@ public class WadlGeneratorTest extends A
         if (booksEl != null) {
             assertTrue(checkElement(elementEls, booksEl, "books"));
         }
+        if (booksEl2 != null) {
+            assertTrue(checkElement(elementEls, booksEl2, "thebook2s"));
+        }
         
         List<Element> complexTypesEls = DOMUtils.getChildrenWithName(schemasEls.get(0), 
                                                                      Constants.URI_2001_SCHEMA_XSD,
@@ -406,7 +411,8 @@ public class WadlGeneratorTest extends A
                     if (type.equals(expectedType1) || type.equals(expectedType2)) {
                         return true;
                     }
-                } else if ("books".equals(name)) {
+                } else if ("books".equals(name) || "thebook2s".equals(name)) {
+                    boolean thebooks2 = "thebook2s".equals(name);
                     Element ctElement = 
                         (Element)e.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD, 
                                                           "complexType").item(0);
@@ -417,8 +423,8 @@ public class WadlGeneratorTest extends A
                         (Element)seqElement.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD, 
                                                           "element").item(0);
                     String ref = xsElement.getAttribute("ref");
-                    String expectedRef = "tns:thebook";
-                    String expectedRef2 = "os:thebook";
+                    String expectedRef = thebooks2 ? "tns:thebook2" : "tns:thebook";
+                    String expectedRef2 = thebooks2 ? "os:thebook2" : "os:thebook";
                     if (ref.equals(expectedRef) || ref.equals(expectedRef2)) {
                         return true;
                     }
@@ -444,16 +450,17 @@ public class WadlGeneratorTest extends A
         
         checkDocs(resource, "book store \"resource\"", "super resource", "en-us");
         
-        List<Element> resourceEls = getElements(resource, "resource", 8);
+        List<Element> resourceEls = getElements(resource, "resource", 9);
         
         assertEquals("/book2", resourceEls.get(0).getAttribute("path"));
         assertEquals("/books/{bookid}", resourceEls.get(1).getAttribute("path"));
         assertEquals("/chapter", resourceEls.get(2).getAttribute("path"));
         assertEquals("/chapter2", resourceEls.get(3).getAttribute("path"));
-        assertEquals("/books/\"{bookid}\"", resourceEls.get(4).getAttribute("path"));
-        assertEquals("/booksubresource", resourceEls.get(5).getAttribute("path"));
-        assertEquals("/form", resourceEls.get(6).getAttribute("path"));
-        assertEquals("/itself", resourceEls.get(7).getAttribute("path"));
+        assertEquals("/thebooks2", resourceEls.get(4).getAttribute("path"));
+        assertEquals("/books/\"{bookid}\"", resourceEls.get(5).getAttribute("path"));
+        assertEquals("/booksubresource", resourceEls.get(6).getAttribute("path"));
+        assertEquals("/form", resourceEls.get(7).getAttribute("path"));
+        assertEquals("/itself", resourceEls.get(8).getAttribute("path"));
         
         // verify root resource starting with "/"
         // must have a single template parameter
@@ -534,12 +541,12 @@ public class WadlGeneratorTest extends A
         
         // verify resource starting from /booksubresource
         // should have 2 parameters
-        verifyParameters(resourceEls.get(5), 2, 
+        verifyParameters(resourceEls.get(6), 2, 
                          new Param("id", "template", "xs:int"),
                          new Param("mid", "matrix", "xs:int"));
-        checkDocs(resourceEls.get(5), "", "Book subresource", ""); 
+        checkDocs(resourceEls.get(6), "", "Book subresource", ""); 
         // should have 4 child resources
-        List<Element> subResourceEls = getElements(resourceEls.get(5), "resource", 6);
+        List<Element> subResourceEls = getElements(resourceEls.get(6), "resource", 6);
 
         assertEquals("/book", subResourceEls.get(0).getAttribute("path"));
         assertEquals("/form1", subResourceEls.get(1).getAttribute("path"));
@@ -778,7 +785,7 @@ public class WadlGeneratorTest extends A
 
         Endpoint endpoint = new EndpointImpl(null, null, epr);
         e.put(Endpoint.class, endpoint);
-
+        endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance());
         e.setDestination(d);
         BindingInfo bi = control.createMock(BindingInfo.class);
         epr.setBinding(bi);

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Wed Oct 16 20:29:59 2013
@@ -503,6 +503,12 @@ public class BookStore {
     }
     
     @GET
+    @Path("infault2")
+    public Response infault2() {
+        throw new RuntimeException();
+    }
+    
+    @GET
     @Path("outfault")
     public Response outfault() {
         return Response.ok().build();

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java Wed Oct 16 20:29:59 2013
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.jaxrs;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -30,6 +31,8 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.util.List;
 
+import javax.xml.stream.XMLStreamReader;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -59,7 +62,7 @@ public class JAXRSClientServerResourceCr
     @Test
     public void testBasePetStoreWithoutTrailingSlash() throws Exception {
         
-        String endpointAddress = "http://localhost:" + PORT + "/webapp/resources";
+        String endpointAddress = "http://localhost:" + PORT + "/webapp/pets";
         WebClient client = WebClient.create(endpointAddress);
         HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
         conduit.getClient().setReceiveTimeout(1000000);
@@ -71,7 +74,7 @@ public class JAXRSClientServerResourceCr
     @Test
     public void testBasePetStore() throws Exception {
         
-        String endpointAddress = "http://localhost:" + PORT + "/webapp/resources/"; 
+        String endpointAddress = "http://localhost:" + PORT + "/webapp/pets/"; 
         WebClient client = WebClient.create(endpointAddress);
         HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
         conduit.getClient().setReceiveTimeout(1000000);
@@ -83,12 +86,12 @@ public class JAXRSClientServerResourceCr
     @Test
     public void testMultipleRootsWadl() throws Exception {
         List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/resources",
-                                                         "http://localhost:" + PORT + "/webapp/resources", 3);
+                                                         "http://localhost:" + PORT + "/webapp/resources", 2);
         String path1 = resourceEls.get(0).getAttribute("path");
         int bookStoreInd = path1.contains("/bookstore") ? 0 : 1;
         int petStoreInd = bookStoreInd == 0 ? 1 : 0;
         checkBookStoreInfo(resourceEls.get(bookStoreInd));
-        checkPetStoreInfo(resourceEls.get(petStoreInd));
+        checkServletInfo(resourceEls.get(petStoreInd));
     }
     
     @Test
@@ -100,9 +103,20 @@ public class JAXRSClientServerResourceCr
     
     @Test
     public void testPetStoreWadl() throws Exception {
-        List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/resources",
-            "http://localhost:" + PORT + "/webapp/resources/", 1);
+        List<Element> resourceEls = getWadlResourcesInfo("http://localhost:" + PORT + "/webapp/pets",
+            "http://localhost:" + PORT + "/webapp/pets/", 1);
         checkPetStoreInfo(resourceEls.get(0));
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(
+             (Element)resourceEls.get(0).getParentNode().getParentNode());
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        StaxUtils.copy(reader, bos);
+        String s = bos.toString();
+        assertTrue(s.contains("<xs:element name=\"elstatus\" type=\"petStoreStatusElement\"/>"));
+        assertTrue(s.contains("<xs:element name=\"status\" type=\"status\"/>"));
+        assertTrue(s.contains("<xs:element name=\"statuses\""));
+        assertTrue(s.contains("element=\"prefix1:status\""));
+        assertTrue(s.contains("element=\"prefix1:elstatus\""));
+        assertTrue(s.contains("element=\"prefix1:statuses\""));
     }
     
     @Test
@@ -126,6 +140,10 @@ public class JAXRSClientServerResourceCr
         assertEquals("/bookstore", resource.getAttribute("path"));
     }
     
+    private void checkServletInfo(Element resource) {
+        assertEquals("/servlet", resource.getAttribute("path"));
+    }
+    
     private void checkPetStoreInfo(Element resource) {
         assertEquals("/", resource.getAttribute("path"));
     }
@@ -222,7 +240,7 @@ public class JAXRSClientServerResourceCr
     public void testPostPetStatus() throws Exception {
         
         String endpointAddress =
-            "http://localhost:" + PORT + "/webapp/resources/petstore/pets";
+            "http://localhost:" + PORT + "/webapp/pets/petstore/pets";
 
         URL url = new URL(endpointAddress);   
         HttpURLConnection httpUrlConnection = (HttpURLConnection)url.openConnection();  

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java Wed Oct 16 20:29:59 2013
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.systest.jaxrs;
 
+import java.util.Collections;
+import java.util.List;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -28,6 +31,10 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.cxf.jaxrs.ext.xml.XMLName;
 
 @Path("/")
 public class PetStore {
@@ -52,6 +59,30 @@ public class PetStore {
 
         return Response.ok(CLOSED).build();
     }
+    
+    @GET
+    @Path("/petstore/jaxb/status/")
+    @Produces("text/xml")
+    public PetStoreStatus getJaxbStatus() {
+
+        return new PetStoreStatus();
+    }
+    
+    @GET
+    @Path("/petstore/jaxb/status/elements")
+    @Produces({"text/xml", "application/json" })
+    @XMLName("{http://pets}statuses")
+    public List<PetStoreStatusElement> getJaxbStatusElements() {
+        return Collections.singletonList(new PetStoreStatusElement());
+    }
+    
+    @GET
+    @Path("/petstore/jaxb/status/element")
+    @Produces("text/xml")
+    public PetStoreStatusElement getJaxbStatusElement() {
+
+        return new PetStoreStatusElement();
+    }
 
     @POST
     @Path("/petstore/pets/")
@@ -60,4 +91,22 @@ public class PetStore {
     public Response updateStatus(MultivaluedMap<String, String> params) throws Exception {
         return Response.ok(params.getFirst("status")).build();
     }
+    
+    @XmlType(name = "status", namespace = "http://pets")
+    public static class PetStoreStatus {
+        private String status = PetStore.CLOSED;
+
+        public String getStatus() {
+            return status;
+        }
+
+        public void setStatus(String status) {
+            this.status = status;
+        }
+        
+    }
+    
+    @XmlRootElement(name = "elstatus", namespace = "http://pets")
+    public static class PetStoreStatusElement extends PetStoreStatus {
+    }
 }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/formRequest.txt Wed Oct 16 20:29:59 2013
@@ -1,4 +1,4 @@
-POST /webapp/resources/petstore/pets HTTP/1.1
+POST /webapp/pets/petstore/pets HTTP/1.1
 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
 Accept-Language: en-ie
 Content-Type: application/x-www-form-urlencoded

Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=1532894&r1=1532893&r2=1532894&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml Wed Oct 16 20:29:59 2013
@@ -30,7 +30,6 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
     <jaxrs:server id="bookservice"
                   address="/resources">
         <jaxrs:serviceBeans>
-            <ref bean="petstore"/>
             <ref bean="bookstore"/>
             <ref bean="servletconfigstore"/>
         </jaxrs:serviceBeans>
@@ -41,6 +40,22 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
             <ref bean="plainTextProvider"/>
         </jaxrs:providers>
     </jaxrs:server>
+    
+    <jaxrs:server id="petservice" address="/pets">
+        <jaxrs:serviceBeans>
+            <ref bean="petstore"/>
+        </jaxrs:serviceBeans>
+        <jaxrs:providers>
+            <bean class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
+                <property name="marshallAsJaxbElement" value="true"/>
+                <property name="xmlTypeAsJaxbElementOnly" value="true"/>
+            </bean>
+            <bean class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
+                <property name="linkJsonToXmlSchema" value="true"/>
+            </bean>
+        </jaxrs:providers>
+    </jaxrs:server>
+    
     <bean id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStore"/>
     <bean id="petstore" class="org.apache.cxf.systest.jaxrs.PetStore"/>
     <bean id="servletconfigstore" class="org.apache.cxf.systest.jaxrs.SpringServletConfigStore"/>