I moved the plugin from Glassfish workspace to jaxb2-commons.
See
https://jaxb2-commons.dev.java.net/property-listener-injector/
This is mostly the same code that Jerome had.
Marcos, it looks like you found a bug in it. If you are interested in
looking at the code, I'd be happy to make you a committer. Otherwise, if
you can send me a test case, I'd be happy to take a look.
Kohsuke Kawaguchi wrote:
> Marcos wrote:
>> 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
>
> We are just talking about moving this to jaxb2-commons.
>
>> 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 ?
>
> It really depends on what kind of code you want to inject. Why don't you
> start by looking at Jerome's code and modify it to fit your needs?
>
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com