fafaano
fafaano

Reputation: 35

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 interface and can be in any package.

thanks

Upvotes: 2

Views: 864

Answers (2)

skaffman
skaffman

Reputation: 403441

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.

Upvotes: 3

Vladimir Ivanov
Vladimir Ivanov

Reputation: 43088

Try to locate your classes, which can come in xml in one package and then pass the list of it to JAXBContext.

Upvotes: 0

Related Questions