Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may also want to look at <a href="http://community.jboss.org/wiki/JAXBIntroductions" rel="nofollow">JAXBIntroductions</a> project which is intended for similar purpose. The annotation configuration is kept in a file, without requiring modification to source code. It does work nicely with Jersey, by implementing a JAX-RS provider. You can check out my blog <a href="http://aruld.info/hate-jaxb-annotations-moxy-and-jaxbintroductions-comes-to-the-rescue/" rel="nofollow">entry</a> which explains this in detail with an example. Here is a simple JAXBContextResolver provide for JAXBIntroductions that can be used in your Jersey application.</p> <pre><code>import com.sun.xml.bind.api.JAXBRIContext; import org.jboss.jaxb.intros.IntroductionsAnnotationReader; import org.jboss.jaxb.intros.IntroductionsConfigParser; import org.jboss.jaxb.intros.configmodel.JaxbIntros; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; import javax.xml.bind.JAXBContext; import java.util.*; @Provider public class JAXBContextResolverForJAXBIntroductions implements ContextResolver&lt;JAXBContext&gt; { private final JAXBContext context; private final Set&lt;Class&gt; types; private final Class[] cTypes = {Customer.class}; public JAXBContextResolverForJAXBIntroductions() throws Exception { this.types = new HashSet(Arrays.asList(cTypes)); JaxbIntros config = IntroductionsConfigParser.parseConfig(this.getClass().getResourceAsStream("/intro-config.xml")); IntroductionsAnnotationReader reader = new IntroductionsAnnotationReader(config); Map&lt;String, Object&gt; jaxbConfig = new HashMap&lt;String, Object&gt;(); jaxbConfig.put(JAXBRIContext.ANNOTATION_READER, reader); this.context = JAXBContext.newInstance(cTypes, jaxbConfig); } public JAXBContext getContext(Class&lt;?&gt; objectType) { return (types.contains(objectType)) ? context : null; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload