Tighter Integration of JAXB & JAX-RPC

Working with the XML specifications for Java has always been a pleasure for me. Yes, some criticise them fiercely, however I feel they are mostly adequate for t he task.

I recently encountered a problem with JAXB; the specification requires two behaviours which I find to cause integration hassles:

  1. You must use ObjectFactory to get new beans,
  2. ObjectFactory creates beans with null references

Both issues crop up when using JAXB with a container such as PicoContainer, Spring or anything else that expects to be able to instantiate empty beans without special knowledge.

The second issue becomes a difficulty when using JAXB beans with “dot notation”. For example, you cannot simply create an empty bean and then try and set a property like car.engine.timing since the reference to engine is null until you create an Engine object and assign it. Would it be more appropriate to recursively populate the bean?

George Datuashvili mentioned on the JAXB mailing list:

“In future JAX-RPC 2.0 will be based on JAXB 2.0, and since JAX-RPC already requires EJB bindings, your issue will have to be resolved by JAXB or JAX-RPC working groups.”

That thread also talks about using java.lang.Proxy, which I find very interesting.

Comments are closed.