Using injection in JAXB XmlAdapters for Spring RESTful Controller

MrChevy

New Member
My application requires instances of the JAXB XmlAdapter such as\[code\]public class CategoryTypeAdapter extends XmlAdapter<String, Category> { @Autowired protected CategoryService categoryService; public CategoryTypeAdapter() { } @Override public String marshal(Category v) throws Exception { return (v == null) ? null : v.getId(); } @Override public Category unmarshal(String v) throws Exception { // noop if (StringUtils.isBlank(v)) { return null; } // load via service return this.categoryService.getCategory(v); }}\[/code\]Question: How can I configure Spring's Jaxb2RootElementHttpMessageConverter to set this adapter in the appropriate mashaller?I know there is the Spring OXM library but I am not clear on how I can use the OXM classes together with my annotation driven REST controllers.
 
Back
Top