You must create JAXB annotations in the package-info.java file from the binding file

I have an annotation for XmlAdapterwhich I need to add to package-info.java. The problem is that our package-info.java is automatically created from XJC. Is there a way to use the JAXB binding file to automatically add this annotation to package-info.java when I create it?

@javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters
({
    @javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter(value=Adapter.class,type=Original.class)
})

Thank you for your help!

+5
source share
1 answer

, . Annotate XJC XmlAdapter. package-info.java.

<jaxb:bindings
  version="2.1"
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:annox="http://annox.dev.java.net" 
  jaxb:extensionBindingPrefixes="annox">

  <jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema">
    ...
    <jaxb:bindings node="xs:complexType[@name='...']/xs:sequence/xs:element[@name='name']">
      <annox:annotate>
        <annox:annotate
          annox:class="org.hibernate.search.annotations.FieldBridge"
          impl="com.acme.foo.MyFieldBridge">
          <annox:annotate annox:field="params">
            <annox:annotate annox:class="org.hibernate.search.annotations.Parameter"
              name="foo"
              value="bar"/>
          </annox:annotate>
        </annox:annotate>
      </annox:annotate>
    </jaxb:bindings>
    ...
  </jaxb:bindings>

</jaxb:bindings>

:

@FieldBridge(impl = com.acme.foo.MyFieldBridge.class, params = {
  @Parameter(name = "foo", value = "bar")
})

: :

.

0

All Articles