How can I inject EJBs into the XmlAdapters?
The idea is I want to get list of IDs by rest API and convert this array of IDs to List of Objects for Entity Object. For example:
public class Post {
List<Category> categories;
...
}
public class AdaptedPost {
List<Long> categories;
...
}
public class PostAdapter extends XmlAdapter<AdaptedPost, Post> {
@EJB
CategoryFacade categoryFacade;
@Override
public Post unmarshal(final AdaptedPost adaptedPost) throws Exception {
// Use facade class to retrieve category object from ID
}
...
}
There is no support defined for injection into javax.xml.bind.annotation.adapters.XmlAdapter objects.
You will need to acquire your EJB the old fashioned way using a JNDI lookup.