Firstly I'd like to say that JAXB2 rocks!
With lots of help from Kohsuke (he actually wrote most of the code :)
we've hacked up a JNDI provider using JAXB2 in the xbean project...
http://geronimo.apache.org/xbean/jaxb-jndi.html
There's an example here...
https://svn.apache.org/repos/asf/geronimo/xbean/trunk/xbean-jaxb/src/test/resources/org/apache/xbean/jaxb/example1.xml
One issue we have is that JAXB2 requires a JAXBContext to be created
with the explicit package names/classes available. The problem with
using JAXB2 for things like a SOAP stacks or JNDI providers is that
the SOAP stack/JNDI provider does not know up front the entire list of
Java packages which may be used at runtime by an end user.
So what we'd like is for the parser to be able to auto-discover the
available classes on the classpath (so folks can just drop a jar on
the classpath and JAXB2 can auto-discover it when parsing).
We implemented this kind of thing in xbean-spring so I wondered if we
could do the same in JAXB2.
e.g. if I am a component developer writing some POJOs with JAXB2
annotations, I can add an extra step to my maven 2 build to
auto-generate the following (which could be added to the m2 plugin for
jaxb)
* jaxb.index files in each package
* for each namespace, generate a text file at
META-INF/services/javax/xml/bind/namespaces/${namespace}
where ${namespace} is a text encoding of the namespace URI to encode
any incompatible characters etc.
The contents of the text file could be the contents of the jaxb.index
file (or just a list of the package names so the parser can then
auto-discover the jaxb.index files for the given namespace).
We'd then just need to change the JAXB2 parser so that if it finds a
namespace that it does not understand, it attempts to auto-discover
it.
I'm totally fine with this being a flag we enable on JAXB2 and for it
to be a vendor extension and not a standard JAXB2 feature.
Thoughts?
--
James
-------
http://radio.weblogs.com/0112098/