Skip to content

JAXB Property Listener Injector Plugin

Laurent Schoelens edited this page Dec 6, 2023 · 1 revision

This XJC plugin will generate property change events on each setXXX if specified in the additional generated methods.

Added in 4.0.1 version of JAXB-Tools.

Usage

  • Activate the plugin using the -Xinject-listener-code switch.

You can customize the PropertyListener by declaring urn:jaxb.jvnet.org:plugin:propertyListenerInjector as an extension namespace.

<jaxb:bindings ...
  xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:li="urn:jaxb.jvnet.org:plugin:propertyListenerInjector"
  jaxb:extensionBindingPrefixes="... li">

...
   <jaxb:bindings node="/xsd:schema">
      <li:listener>java.beans.PropertyChangeListener</li:listener>
   </jaxb:bindings>
...

</jaxb:bindings>

Accepted listeners are java.beans.VetoableChangeListener (default) or java.beans.PropertyChangeListener.

See also Using JAXB2 Basics Plugins.

Clone this wiki locally