-1

Require help: following XmlJavaTypeAdapter type is not working properly:

public class TestAdapter extends XmlAdapter<Object, Object> {

 public Object marshal(Object arg0) throws Exception {
  System.out.println("Test Adapter");
  return null;
 }

 public Object unmarshal(Object arg0) throws Exception {
  System.out.println("Test Adapter");
  return null;
 }
}

I am using the "TestAdapter" like :

'@XmlRootElement
 @XmlJavaTypeAdapter(value = TestAdapter.class)
 public TestClass{...}'

But the problem I am facing is the "TestAdapter" is never getting invoked.

manojadams
  • 2,314
  • 3
  • 26
  • 30
  • 1
    Please be more specific on what is actual issue here. Paste some more code or error or describe what is problem. – Lemonov Jun 13 '17 at 06:48

1 Answers1

1

XmlAdapter does not apply on root elements.

And i don't think there's an implementation of JAXB that is able to do it.

See : Using an adapter to marshal a class to a root element with MOXy or any other JAXB implementation

As said in the linked topic, you can apply your adapter logic manually to workaround your problem.

Dimpre Jean-Sébastien
  • 1,067
  • 1
  • 6
  • 14