users@jaxb.java.net

(JAXB Plugin) Customize the body of a setter method to fire bound properties

From: Marcos <marcos_at_softingsystems.com.br>
Date: Wed, 10 Jan 2007 13:54:17 -0300

Hi all,

I'm trying to write a plugin based on the one developed by Mr.
Jerome Dochez, found at.:
http://fisheye5.cenqua.com/browse/glassfish/admin-core/xjc-plugin/src/com/sun/tools/xjc/addon/property_listener_injector/PluginImpl.java?r1=1.1&r2=1.1.2.1

JAXB's binding compiler generate setter methods for all elements found
in the .xsd file
but I would like to replace some parts to suit my needs .... as follows.:

Before.: (Without the plugin)

    /**
     * Sets the value of the returnCode property.
     *
     * @param value
     * allowed object is
     * {_at_link String }
     *
     */
    public void setReturnCode(String value) {
        this.returnCode = value;
    }

After.: (Using the plugin)

    /* PropertyChangeSupport inserted by my own plugin.*/
    private PropertyChangeSupport changes = new PropertyChangeSupport(this);

    /**
     * Sets the value of the returnCode property.
     *
     * @param value
     * allowed object is
     * {_at_link String }
     *
     */
    public void setReturnCode(String value) {
        String oldReturnCode = this.returnCode; // This must be
inserted by my plugin
        this.returnCode = value; // I'm not
sure if I can invoke the default implementation of JAXB to retrieve this
line of code ...
        changes.firePropertyChange ("returnCode", oldReturnCode,
returnCode); // This must be inserted by my plugin
    }

I know that each plugin has 02 interesting hook methods.:
    onActivated (Options opt)
    run (Outline model, Options opt, ErrorHandler)

How can I use these methods and JAXB RI API to inject the piece of code
that I need ?

Thank you very much
Marcos