syncope-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Chicchiriccò <ilgro...@apache.org>
Subject Re: [PROPOSAL] Get rid of JAXB
Date Wed, 06 Jul 2016 07:39:55 GMT
Hi,
FYI I am currently experimenting with some different approaches about 
generating the missing XSD for WADLGenerator:

  1.  use Javassist for adding JAXB annotations to POJOs and then 
generating XSD (to be passed as parameter to WADLGenerator) via JAXB; it 
is kind of working, but (a) there are things that cannot be easily 
inferred (as Map support) and (b) the JAXB annoations might require 
tweaking in order to produce results similar to the effective XML 
payloads as generated by Jackson

  2. generate XSD with Apache XmlSchema having swagger.json (output of 
Swagger2Feature) as input; it is working but (a) there are some missing 
bits, especially with POJO inheritance and (b) again the XSD entities do 
not map 100% with effective XML payloads as generated by Jackson

  3. use jackson-module-jsonSchema [5] to natively generate JSON schemas 
out of POJOs, then translate into XSD via Apache XmlSchema (I am asking 
for support about this at the jackson-user ML [6])

This last approach seems the most promising to me, especially because I 
expect it to generate the schema information most adherent to Jackson's 
XML payload representation.
Once completed my reference implementation, I will need to asses whether 
it is better to extend the CXF WADLGenerator to incorporate it, or 
instead to add a new Maven plugin to Syncope source tree for XSD 
generation, and then pass such XSD to the standard WADLGenerator.

I'll keep you posted.
Regards.

[5] https://github.com/FasterXML/jackson-module-jsonSchema
[6] https://groups.google.com/d/msg/jackson-user/4HzGsfRgIz4/YzpNugpcBgAJ

On 05/07/2016 18:30, Sergey Beryozkin wrote:
> Hi Francesco
> thanks, see comments inline
> On 05/07/16 16:50, Francesco Chicchiriccò wrote:
>> Hi Sergey,
>> thanks for your comments.
>>
>> See my replies in-line.
>> Regards.
>>
>> On 05/07/2016 14:25, Sergey Beryozkin wrote:
>>> Hi Francesco
>>>
>>> Here are some thoughts/comments.
>>>
>>> The question is and I guess this is something the team will need to
>>> decide upon is how important having a WADL representation for Syncope
>>> is. Having WADL without a schema is probably not worth it - the UI
>>> View is incomplete as a result and if someone tries to generate a
>>> client from this WADL it won't work either. But then if no-one is
>>> working with WADL on the client or really depending on Syncope WADL UI
>>> View then may be it is a feature that can be let go easily enough.
>>
>> AFAICT, I haven't heard about anyone generating non-Java classes from
>> Syncope WADL, and so the most important usage that Syncope users make of
>> WADL is via the REST reference documentation available which every
>> deployment at at
>>
>> http://syncope.apache.org/rest/2.0/index.html
>>
>> Without information from XSD, I agree that even the pure documentation
>> purpose of WADL fades off.
>>
> Yes
>>> So, suppose you have decided to let it go.
>>>
>>> Then it all looks nice, indeed, having a uniform set of annotations is
>>> advantageous.
>>>
>>> But the absence of a schema can be a bit problematic if the
>>> interoperability with the non Java XML clients is required. May be
>>> everyone uses Syncope clients, but if not, then without a schema it
>>> can be tricky for such clients to get the beans generated, etc.
>>> Perhaps it is not going to be a problem because as far as I know only
>>> WADL has a schema and I'm not sure if anyone in the Syncope community
>>> has ever tried this schema to get the non-Java POJOs generated.
>>
>> As said above, I don't think this could be an issue anyway - at least,
>> no one has reported about such usage.
>>
> Indeed
>>> By the way, I believe you may be able to use JAXB without the
>>> annotations, with the help of JAXBElement. Perhaps might be worth
>>> doing a quick try with Moxy JAXB - it might be able to deal better
>>> with some of the JAXB issues.
>>
>> Could you please elaborate on JAXBElement? Do you mean we could process
>> the POJOs, generate the XSD offline and then pass it to WADL? We would
>> probably solve the documentation issue, but the effective XML objects
>> built via Jackson would likely differ from this XSD content.
>>
>
> I only meant that one can configure CXF JAXBElementProvider with a 
> 'marshallAsJaxbElement' property and it should work without the JAXB 
> annotations. I forgot about the schema issue though, sorry.
>
>>> So I suppose if you are happy with Jackson XML and dropping WADL is
>>> acceptable then do give it a try :-) You can always revert back to
>>> JAXB without affecting the clients too much.
>>
>> Well, not the clients using JSON nor the ones using XML but via the
>> Syncope client library, at least.
>>
>>> Oh yes, re WADL and manually supporting the schemas. May be it can be
>>> somehow done such that if a new property is added to one of the
>>> Syncope POJOs then a 'red flag' is raised at the build time if the
>>> schema document has not been synced. That would solve the issue of
>>> maintaining the schema without depending on JAXB all the time, but it
>>> is porbably impossible to implement
>>
>> Hum, I don't like very much the idea of manually keeping a second set of
>> information which needs to be kept in sync with the actual classes...
>>
> I agree
>
> Thanks, Sergey
>
>>> On 05/07/16 11:02, Francesco Chicchiriccò wrote:
>>>> Hi all,
>>>> Syncope core is currently enabled with REST services which are 
>>>> available
>>>> to work with both JSON and XML payloads; JSON support is provided via
>>>> Jackson, XML via JAXB.
>>>>
>>>> The recent SYNCOPE-884 brought again to my attention how difficult 
>>>> is to
>>>> keep supporting both formats, especially considering that often JAXB
>>>> does not provide anything special out-of-the-box (take the fix for
>>>> SYNCOPE-884 [1] as an example of such troubles).
>>>>
>>>> Hence, I went forward and provided a feature branch [2] where JAXB is
>>>> compltely removed and XML payloads are instead managed via Jackson 
>>>> [3].
>>>> At present all tests are running fine, both with application/json and
>>>> application/xml and the Swagger UI extension is working as well.
>>>>
>>>> The benefits to me are: (1) manageability (no need to maintain two
>>>> different sets of annotations) and possibly (2) performance - even
>>>> though I realize that probably the vast majority is using
>>>> application/json.
>>>>
>>>> The only problem I can see, instead, is related to WADL: CXF's 
>>>> generator
>>>> relies on JAXB for providing the <grammars> section, so currently no
>>>> grammar is available and, as a consequence, there are no links to
>>>> payload objects definition in the REST services documentation, as
>>>> instead shown at [4].
>>>> To given an idea, when you go to [4], click on "numbers", then "GET
>>>> (numbers)", you will see a modal window with a table under "Response"
>>>> which shows a "syncope1:numbersInfo" link, bringing to the XSD 
>>>> reference
>>>> of such object.
>>>> In [2], no link is shown.
>>>>
>>>> There is the possibility of passing an existing XSD file to the WADL
>>>> generator, but then the problem of generating such XSD file via 
>>>> Jackson
>>>> arises, which is something I couldn't find a way to.
>>>>
>>>> Questions:
>>>>
>>>> 1. how do you see this feature (e.g. removing JAXB) in general?
>>>> 2. do you think that missing XSD from WADL is grave, considering that
>>>>     Swagger provides much more and is still working fine?
>>>> 3. any clever idea about pre-generating the XSD file from a bunch of
>>>>     Jackson-annotated POJOs?
>>>>
>>>> Regards.
>>>>
>>>> [1] https://git-wip-us.apache.org/repos/asf?p=syncope.git;h=4f6818b
>>>> [2] 
>>>> https://git-wip-us.apache.org/repos/asf?p=syncope.git;a=tree;h=refs/heads/2_0_NO_JAXB

>>>>
>>>> [3] https://github.com/FasterXML/jackson-dataformat-xml
>>>> [4] http://syncope.apache.org/rest/2.0/index.html

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC,
CXF Committer, OpenJPA Committer, PonyMail PPMC
http://home.apache.org/~ilgrosso/



Mime
View raw message