cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cristiano Costantini <cristiano.costant...@gmail.com>
Subject Re: Java2Ws and JSR 303 Annotations
Date Wed, 25 Nov 2015 10:25:51 GMT
Hi Benedickt,

Your example is really clear, and I think it should be supported by CXF!

To summarize to other members of the mailing list, the concept is that if I
annotate my class with these 303 annotations:

public class TestDTO {
    @Min(100) private int number;
    @Pattern(regexp = "mypattern") private String patternCheck;
    @Size(max = 100) private String lengthCheck;
}

I would get an XML schema like this:
<complexType name="testDTO">
  <sequence>
    <element minOccurs="0" name="lengthCheck">
      <simpleType>
*        <restriction base="string"><maxLength value="100"/></restriction>*
      </simpleType>
    </element>
    <element name="number">
      <simpleType>
*        <restriction base="int"><maxInclusive value="100"/></restriction>*
      </simpleType>
    </element>
    <element minOccurs="0" name="patternCheck">
      <simpleType>
*        <restriction base="string"><pattern
value="mypattern"/></restriction>*
      </simpleType>
    </element>
  </sequence>
</complexType>

(for full code see, Benedickt's examples on GitHub, I just shrank its
examples)

Well, here some feedback.
It is maybe something more related to JaxB rather than JaxWs: it is JaxB
that handle the binding and the XML schema generation. JaxB is standardized
by a JSR (maybe it is JSR 222) and the specification does not take into
account (I think) the JSR 303, so if this is to be embraced by CXF (and I
would like it to be), it should be developed as something pluggable and
that need to keep compliance with JSR 222.

Taking into account potential regressions, it should be something that need
to be enabled via some kind of flags or CXF specific annotation: for
example, there could exist people who have implementations using CXF and
JSR 303 for different reason, and if the JSR 303 support is added
transparently this broke their WSDL ! So enabling of this feature should be
something people is aware of.

Also, the main use case of mine does not take into account direct
generation of the WSDL using java2ws-maven-plugin: we develop (a lot) of
JaxWS annotated Java interfaces, and we publish them directly
org.apache.cxf.jaxws.JaxWsServerFactoryBean
or from Camel in xml routes (WSDL is generated at runtime). While in the
maven plugin it could be sufficient to put an attribute on the maven
configuration, in these cases it would require a change on the API to
launch and support the generation of XML schemas that takes into account
JSR 303.

I think you should open a ticket on CXF's Jira to propose the feature, or
ask more feedback from the main committers.
I think that if they understand the idea, they would like it.

thanks,
Cristiano




Il giorno mer 25 nov 2015 alle ore 08:13 Benedikt Ritter <britter@apache.org>
ha scritto:

> 2015-11-21 12:44 GMT+01:00 Benedikt Ritter <britter@apache.org>:
>
> > Hello Christiano,
> >
> > 2015-11-20 7:52 GMT+01:00 Cristiano Costantini <
> > cristiano.costantini@gmail.com>:
> >
> >> Hi,
> >> your idea seems interesting,
> >> could you write an example of what you mean? An example of a class
> >> annotated with JSR 303 and the WSDL/XSD you do expect would be great.
> >>
> >
> > we've put together an example at github [1]. The README.md contains an
> > overview of how annotations could be mapped to WSDL.
> >
>
> Any comments on the proposal? Does it fit into CXF? Is the CXF project
> interested in such a proposal?
>
> Thanks.
> Benedikt
>
>
> >
> > Regards,
> > Benedikt
> >
> > [1] https://github.com/codecentric/cxf-bean-validation
> >
> >
> >>
> >> Thank you,
> >> Cristiano
> >>
> >>
> >> Il giorno gio 19 nov 2015 alle ore 21:21 Benedikt Ritter <
> >> britter@apache.org>
> >> ha scritto:
> >>
> >> > Hello,
> >> >
> >> > one of the projects at my company currently has the need to generate
> >> WSDLs
> >> > from Java classes annotated with JSR 303 annotations [1]. They are
> using
> >> > CXF's java2ws-maven-plugin, but the plugin does not process JSR 303
> >> > annotations.
> >> > We're currently evaluating ways to generate XSD facets for
> representing
> >> the
> >> > annotations. One idea is to extend the java2ws-maven-plugin so that is
> >> can
> >> > generate this as well.
> >> > Would the CXF project be interested in such a contribution? If so, I
> can
> >> > elaborate more about how JSR 303 annotations could be mapped to
> facets.
> >> >
> >> > Regards,
> >> > Benedikt
> >> >
> >> > [1] http://beanvalidation.org/
> >> >
> >> > --
> >> > http://people.apache.org/~britter/
> >> > http://www.systemoutprintln.de/
> >> > http://twitter.com/BenediktRitter
> >> > http://github.com/britter
> >> >
> >>
> >
> >
> >
> > --
> > http://people.apache.org/~britter/
> > http://www.systemoutprintln.de/
> > http://twitter.com/BenediktRitter
> > http://github.com/britter
> >
>
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message