Added functionality for code_injector/PluginImpl.java

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Added functionality for code_injector/PluginImpl.java

Karsten Engelke
Hi,

I noticed that the current code injection plugin doesn't allow to
inject code into enums. This is due to the plugin only iterating over
getClasses() and not getEnums(). A very simple addition would add
support for code injection in enums:

for (EnumOutline eo : model.getEnums()) {
            CPluginCustomization c =
eo.target.getCustomizations().find(Const.NS, "code");
            if (c == null) {
                continue;   // no customization --- nothing to inject
here
            }

            c.markAsAcknowledged();
            // TODO: ideally you should validate this DOM element to
make sure
            // that there's no typo/etc. JAXP 1.3 can do this very
easily.
            String codeFragment = DOMUtils.getElementText(c.element);

            // inject the specified code fragment into the
implementation class.
            eo.clazz.direct(codeFragment);
}

Please let me know if there is proper way to propose code changes.


Regards,

Karsten
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Added functionality for code_injector/PluginImpl.java

Iaroslav Savytskyi
Hi Karsten,

Thank you for your report.

The common way how to do code changes is to fire bug on Jira ( https://java.net/jira/browse/JAXB ).
You can propose code changes there. Meantime you have to sign Oracle Contribution Agreement. So we will be able to work with your patch.

[1]: http://www.oracle.com/technetwork/oca-405177.pdf
[2]: http://www.oracle.com/technetwork/oca-faq-405384.pdf


Best regards.
Yarda

On 9 Sep 2014, at 13:38, <[hidden email]> <[hidden email]> wrote:

> Hi,
>
> I noticed that the current code injection plugin doesn't allow to
> inject code into enums. This is due to the plugin only iterating over
> getClasses() and not getEnums(). A very simple addition would add
> support for code injection in enums:
>
> for (EnumOutline eo : model.getEnums()) {
>    CPluginCustomization c =
> eo.target.getCustomizations().find(Const.NS, "code");
>    if (c == null) {
> continue;   // no customization --- nothing to inject
> here
>    }
>
>    c.markAsAcknowledged();
>    // TODO: ideally you should validate this DOM element to
> make sure
>    // that there's no typo/etc. JAXP 1.3 can do this very
> easily.
>    String codeFragment = DOMUtils.getElementText(c.element);
>
>    // inject the specified code fragment into the
> implementation class.
>    eo.clazz.direct(codeFragment);
> }
>
> Please let me know if there is proper way to propose code changes.
>
>
> Regards,
>
> Karsten

Loading...