user1079877
user1079877

Reputation: 9398

Use EJB in XmlAdapters

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
    }
    ...    
}

Upvotes: 1

Views: 90

Answers (1)

Steve C
Steve C

Reputation: 19455

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.

Upvotes: 2

Related Questions