@XMLRootElement(name="BookStore")
@XMLJavaTypeAdapter(BookStoreAdapter.class)
public class BookStore{}
when I unmarshall xml into BookStore POJO, BookStoreAdapter.class is not invoked. and yes BookStoreAdapter.class extends XmlAdapter<String, BookStore> and implements abstract methods.
the reason I am trying this contraption is bcz I have a rest web service like this
class interface{
@PUT
@Consumes({"application/xml"})
public void service(BookStore bs);
}
so without Adapter I can receive xml request and Apache CXF through JAXB would create a POJO for me from xml to BookStore, but I want both pojo and xml as I want to store xml request in DB. for this reason I was thinking I could have adapter on BookStore than in adapter's unmarshall method I would take xml String and store it in DB and Create BootStore pojo as well like following
@Override
public BookStore unmarshal(String bookStoreXML) {
storeXMLInDB(bookStoreXML);
BookStore bs = null;
try {
bs = ((BookStore) JAXBContext.newInstance(BookStore.class);.createUnmarshaller().unmarshal(new StringReader(bookStoreXML)));
} catch (Exception ex) {
}
return bs;
}
I know its bad code, I am just learning, please help. Thanks for your time and inputs.