Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is possible to achieve this for this simple case without using a 3rd Party plugin using the <a href="http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/2.0/jaxb/vendorCustomizations.html" rel="nofollow" title="JAXB RI Vendor Extensions">JAXB RI Vendor Extensions</a> xjc:superInterface customization. It should be noted this approach will cause all generated classes to implement the interface. </p> <p>Example bindings file:</p> <pre><code>&lt;jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jxb:extensionBindingPrefixes="xjc"&gt; &lt;jxb:bindings schemaLocation="adult.xsd" node="/xs:schema"&gt; &lt;jxb:globalBindings&gt; &lt;xjc:superInterface name="com.example.model.Person"/&gt; &lt;/jxb:globalBindings&gt; &lt;/jxb:bindings&gt; &lt;/jxb:bindings&gt; </code></pre> <p>You then just need to run <a href="http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/1.6/jaxb/xjc.html" rel="nofollow">xjc</a> specifying the binding file and setting the -extension flag. Much quicker/simpler than bringing in JAXB2Basics!</p> <p>I was initially sceptical that this would work as the documentation states:</p> <blockquote> <p>The customization allows you to specify the fully qualified name of the Java interface that is to be used as the root interface of all the generated interfaces. This customization has no effect unless you are specifically generating interfaces with the globalBindings generateValueClass="false" switch.</p> </blockquote> <p>But when I tried it out with a bindings similar to the one above (without specifying generateValueClass="false", and generating classes, not interfaces), it gave me the output I required - all my generated classes implemented the common interface. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload