JAXB unmarshalling
Is it possible to unmarshall a class without knowing it's type (JAXBContext.newInstance(clazz)
) , or what is proper way to test what is comming?
I do get messages for unmarshaling from plain text - String
Incomming classes doesn't implement any int开发者_如何转开发erface and can be in any package.
thanks
No, not really. The JAXB context needs some information about what classes should be bound to. if necessary, pass a list of every possible JAXB-annotated class to the context factory method.
This shouldn't be a limitation, though - your own code also needs to know what classes to expect. If your code doesn't know or care about the type of the bound classes, then JAXB isn't the tool for the job, you should just be unmarshalling into a generic DOM of some kind.
Try to locate your classes, which can come in xml in one package and then pass the list of it to JAXBContext.
精彩评论