How to handle various concrete implementations of an Interface with JAX-B

noah137

New Member
I have a class that any I need to marshal to XML.\[code\]@XmlRootElement@XmlAccessorType(XmlAccessType.FIELD)public class ClassToBeMarshalled { public Interface object;}\[/code\]The Interface is implemented by a lot of concrete classes and most of them are vendor specific whose source code I don't have access to. So my problem is:If I try to marshal that class, JAX-B will complain that the current concrete implementation of Interface is not known in the context - In another words, the concrete class was not loaded into the context by calling JAXBContext.newInstance providing the current implementation.The most common ways to sort out that problem are:1) Use XMLSeeAlso - not a viable option as there are a lot of concrete classes2) Annotate each class with @XmlRootElement - not a viable option as I don't have access to all the classesDoes anyone know a way to make JAX-B load the concrete class into its context as the need arises? Thanks. P.S.: I'm using JAX-B RI
 
Back
Top