users@jaxb.java.net

Re: xjc and PropertyChangeSupport

From: Marcos <marcos_at_softingsystems.com.br>
Date: Tue, 09 Jan 2007 17:14:53 -0300
Hi all,

I was browsing the JAXB RI API trying to better understand how to write plugins to the binding compiler.
I think the plugin I've mentioned in my previous message doesn't put the "fireXXX" methods expected in bound properties,
so I've decided to try to write my own plugin to add these fireXXX methods.

Question.: How can I customize the method's body ?
                I didn't find a class MethodOutline ... ;-( not sure if this is the right approach to produce the code below ?

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

    /**
     * Sets the value of the returnCode property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *    
     */
    public void setReturnCode(String value) {
        /* Method body inserted by my own plugin.*/
        String oldReturnCode = this.returnCode;
        this.returnCode = value;
        changes.firePropertyChange ("returnCode", oldReturnCode, returnCode);
    }


Thank you very much
Marcos

Marcos escreveu:

Also, from what I've seen of your nifty plugin, in order to force the  injection one must do the following:
   - have the plugin jar on the classpath
   - pass -Xinject-listener-code to xjc
Hi all,
I followed the recommendation above, compiled the plugin 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 and I obtained the following results.:


@XmlRootElement(name = "loaderJob")
public class LoaderJob {

    // Ok, support added from the plugin ;-)
    @XmlTransient
    private VetoableChangeSupport support = (new VetoableChangeSupport(this));

    /**
     * Sets the value of the returnCode property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *    
     */
    public void setReturnCode(String value) {
        this.returnCode = value;
        /* Why didn't I get the fireXXX methods ;-( Am I doing something wrong ? */
    }

    /* Ok, wrapper methods added from the plugin ;-)*/
    public void addVetoableChangeListener(String param0, VetoableChangeListener param1) {
        support.addVetoableChangeListener(param0,param1);
    }

    public void addVetoableChangeListener(VetoableChangeListener param0) {
        support.addVetoableChangeListener(param0);
    }

    public void removeVetoableChangeListener(VetoableChangeListener param0) {
        support.removeVetoableChangeListener(param0);
    }

    public void removeVetoableChangeListener(String param0, VetoableChangeListener param1) {
        support.removeVetoableChangeListener(param0,param1);
    }


}

I really need this fireXXX methods,  so I appreciate any help ;-) or some mentoring to solve that.
Thank you very much
Marcos

--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@jaxb.dev.java.net For additional commands, e-mail: users-help@jaxb.dev.java.net