users@jaxb.java.net

Re: Getting Simple Plugins to work

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Thu, 09 Mar 2006 10:58:21 +0100

Hi.

> I am struggling to get the simplest of jax-b plugins working. Ultimately
> I would like to write a plugin that uses interfaces for objects it
> defines, and creates a factory for instantiation. Basically we have the
> problem that we have many schemas that we are provided that are nearly
> identical, but not quite. I would like to hide the implementation of
> each marshelled schema behind interfaces and factories so that the code
> we write is none-the-wiser. Looking at the users list here, it seems
> that a custom plugin is the ticket.

If you're developing onm JAXB 1, take a look at
http://jaxbcommons.dev.java.net. There's a number of add-ons for
internationalization, equals and hashcode, cloning and so on.

> So I started by writting a stubbed out plugin that just prints the
> method name. I just want to see that the plugin is getting executed. I
> then compile and jar it up according to the documentation and create a
> META-INF/services file called com.sun.tools.xjc.MyPlugin which contains
> the fully qualifed name of my plugin.
>
> Then I try to run XJC:
>
> <path id="custom.jaxb.path">
> <fileset dir="${lib.dir}">
> <include name="*.jar"/>
> </fileset>
> <pathelement location="${java.home}/lib/tools.jar"/>
> <fileset dir="C:/dev/java/jaxb-ri
> -20051003/lib">
> <include name="*.jar"/>
> </fileset>
> </path>
> <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask"
> classpathref="custom.jaxb.path">
> </taskdef>
>
> <target name="build">
> <xjc target="${src.dir}" readonly="true"
> package="org.mytest.foo"
> schema="schema/message/efileMessage.xsd">
> <arg line="-foo"/>
> <arg line="-Xverification"/>
> </xjc>
> </target>
>
> You can see that I set the optionName to foo. When this did not work (I
> get "unrecognized parameter -foo"), I downloaded jaxb-verification and
> tried that too. For grins I looked at how their plugin was created and
> how the services file was defined to make sure I did not have any
> inconsistancies.

Ah, ok, so you saw one of my add-ons. By the way, it's
jaxbvalidation.dev.java.net now.

> Basically I cannot get any plugins to work with the latest JAX-B EA3
> release. I know I must be doing something wrong since others seem to be
> able to get this to work.
>
> Any help would be greatly appreciated.

My developments are mainly JAXB 1-based. This may help:

https://jaxbcommons.dev.java.net/guide.html
https://hyperjaxb2.dev.java.net/nonav/reference/html_single/index.html#d0e1828

However I do not know how relevant is it to JAXB 2 (which you seem to
apply for).

Bye.
/lexi