The Source for Java Technology Collaboration
User: Password:



Kohsuke Kawaguchi

Kohsuke Kawaguchi's Blog

A JAXB2 plugin to handle all-capital element names nicely

Posted by kohsuke on March 02, 2006 at 05:09 PM | Comments (4)

Nicola Fagnani wrote a small but nice JAXB plugin that turns all capital element names like "FIRST_NAME" and "LAST_NAME" into a nice method name like "getFirstName" (the spec turns it into "getFIRSTNAME".) Besides being useful on its own, it's a good example of how you can programatically customize the XML name -> Java name conversion. I think writing a little code to do this is much more flexible than writing JAXB customization.

I'm asking him to move this plugin to JAXB2-commons, so that we can host a pre-built jar and etc there.

It also makes me wonder if it might be good if we let a plugin to be written in a scripting language. If a useful plugin like this could be written in this short code, then setting up a classpath, compiling, and packaging it up in a jar is actually a lot more work than writing it. If you can write it in Groovy (for example) and just pass that around, wouldn't it be more convenient? Or maybe all we need is a Maven goal to generate a plugin project template...


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • or perhaps even in JavaScript, specially that that is now in Mustang?

    In any case, I think that simple extensions are a very good fit for scripting languages. I really liked using elisp inside (X)Emacs. It made me extremely productive...

    - eduard/o

    Posted by: pelegri on March 02, 2006 at 05:46 PM

  • The thing with JavaScript is that I don't think you can use it to define a new class, which is often necessary. For example, this plugin does define one new class besides a plugin class.

    Posted by: kohsuke on March 02, 2006 at 05:49 PM

  • Well, what would the template look like? Other than extending Plugin.... nothing else is common, right?

    Posted by: malachid on March 03, 2006 at 12:31 PM

  • The point is to generate a pom.xml with all the right dependencies, a META-INF/services/... file, and so on.

    Posted by: kohsuke on March 03, 2006 at 12:37 PM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds