I am trying to use a Spring Wadl Generator: https://github.com/autentia/wadl-tools.
AFAIK, this tool uses the same idea of the Tomasz Nurkiewicz @tomasz-nurkiewicz: get the RequestMappingHandlerMapping from Spring, inspect each element and generate a appropriate WADL.
Internally, the tool will use JAXB to create an XML of the parameters in controllers. As far as good, but things doesn't run nicely with my application.
I got the following exception:
2014-02-07 15:33:41,827 WARN user=unauthenticatedUser com.autentia.xml.namespace.QNameBuilder - Cannot discover QName from JAXB annotations for class: java.util.Map. Preparing generic QName.com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.util.Map is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at java.util.Map
Which comes from (simplified stacktrack)
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:471)
(...)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
(...)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at com.autentia.xml.namespace.QNameBuilder.discoverQNameFromJaxb(QNameBuilder.java:68)
(...)
at com.autentia.web.rest.wadl.builder.ApplicationBuilder.build(ApplicationBuilder.java:36)
The question
Could I force a default adapter to an Interface?
Normally people can just put annotations for interface with specific Adapter but I don't wanna change and/or analyze hundred of classes.
Related links
- java.util.List is an interface, and JAXB can't handle interfaces
- http://blog.bdoughan.com/2013/03/jaxb-and-javautilmap.html
- https://weblogs.java.net/blog/2006/06/06/jaxb-and-interfaces
Edited
Unfortunately I cannot change REST API.
From javadoc of MessageWriter:
Contract for a provider that supports the conversion of a Java type to a stream. To add a MessageBodyWriter implementation, annotate the implementation class with @Provider.
WADL should provide info of services as they are. Adding a MessageBodyWriter via annotation for example would change the API. Since I can change QNameBuilder.discoverQNameFromJaxb, would there be possible change/provide in this very "moment" the MessageBodyWriter to java.util.Map and change back WADL generation?