I have list of XML files for the user to send the request. By runtime only i comes know what type of object JAXB is going to create. For example if user sends the request like
<books>
<name>Java</name>
</books>
Then i wants create a Book object. If the user sends the request like
<Customer>
<id>1</id>
</Customer>
Then i wants to create a Customer object . But when i unmarshalling the XML using JAXB i need to specify the object type like
Person person= (Person) jaxbUnmarshaller.unmarshal(file);
Is this anyway to create those objects dynamically?
Please help me.
Without the explicit cast, with the code below
objectcould hold an instance ofBookorPersonbased on the content of the XML file.