THIS INTERFACE IS SUBJECT TO CHANGE WITHOUT NOTICE.
{@link JAXBContext#newInstance(Class)} requires that application informs JAXBabout all the classes that it may see in the instance document. While this allows JAXB to take time to optimize the unmarshalling, it is sometimes inconvenient for applications.
This is where {@link ClassResolver} comes to resucue.
A {@link ClassResolver} instance can be specified on {@link Unmarshaller} via{@link Unmarshaller#setProperty(String,Object)} as follows:
unmarshaller.setProperty( ClassResolver.class.getName(), new MyClassResolverImpl() );
When an {@link Unmarshaller} encounters (i) an unknown root element or (ii) unknownelements where unmarshaller is trying to unmarshal into {@link XmlAnyElement} withlax=true, unmarshaller calls {@link #resolveElementName(String,String)}method to see if the application may be able to supply a class that corresponds to that class.
When a {@link Class} is returned, a new {@link JAXBContext} is created withall the classes known to it so far, plus a new class returned. This operation may fail (for example because of some conflicting annotations.) This failure is handled just like {@link Exception}s thrown from {@link ClassResolver#resolveElementName(String,String)}. @author Kohsuke Kawaguchi @since 2.1
|
|