ADF and JAXB
I’m currently working on a prototype for a mobile java application. It’s going to run on a laptop, so i can just use swing and j2se, nothing exciting there. The biggest challenge is to use ADF for a mostly offline jclient application. The current idea is to use xml for ofline data storage. When a network connection becomes available we’ll use a web service to send the xml document to a server.
Some weeks ago I saw Oracle’s Steven Davelaar demo ADF in combination with xml. He was using castor to create java bindings for his xml document. He showed that it’s pretty straightforward to use these castor generated classes with ADF. Now castor is OK, but i’d rather go with something standard, like JAXB. So i first tried using that. But it looks like ADF doesn’t like JAXB generated java.
The difference between JAXB and castor is that JAXB uses interfaces. It generates Interfaces for all your elements and types in an xml schema. Castor doesn’t use interfaces. So my guess is, ADF doesn’t like interfaces. You can only create data controls for javabeans (i.e., classes), not for interfaces.
Bad luck. So now we are also using castor. I also briefly looked at apache’s xmlbeans, but i think they have the same problem.
On the server side we’re using the readXml method provided by ADF’s business components to read the xml document into tables. Works really nice, sofar. I couldn’t find a lot of documentation on the readXml method, but Steve Muench has some usefull entries in his blog: Writing XML Using View Objects and Code Sample Illustrating Various BC4J Programming Techniques.
June 23rd, 2004 at 12:48 pm
I tried using JAXB recently for some JSR-198 work I’m doing, and I was horrified by the sheer amount of code it generated from my schema. For every type in the schema, there was an interface and a class.
I probably missed the point somewhere along the way, but if I were to design an object model for an XML schema, the code JAXB generates is quite a bit different from what I’d write. In particular, experience has taught me to always have a good reason to introduce an interface.
JAXB seems to take the approach of just generating an interface for every class, which (again, unless I missed the point somewhere) is like the kind of mistake developers make when they’re first learning Java and discover how cool interfaces are.
June 23rd, 2004 at 6:58 pm
JAXB may not generate the nicest code, but it’s the standard, and it works. It’s always difficult to explain why you’re not using the standard solution when the standard solution does the job. This seems to be especially true for companies which have standardized on oracle. And jaxb is part of Oracle’s XDK. Does Oracle’s XDK have an xml binding solution which works with ADF?