Hi,
On 02/02/12 22:08, hdave wrote:
Sergey,

The workaround is functioning well.  Let me know if you create a CXF issue
on this so I can track it.

Please see
https://issues.apache.org/jira/browse/CXF-4086

it has been resolved on the trunk and all the branches,

Give it a try please
Cheers, Sergey


FYI - here is the (rough) code for the workaround:


public class JaxbContextResolverSelector
                implements ContextResolver<JAXBContext>  {

        @Context
        private HttpHeaders hdrs;

        private JaxbContextResolverNav nodeResolver;
        private JaxbContextResolverDomain domainResolver;


        /**
         * {@inheritDoc}
         */
        public JAXBContext getContext(Class<?>  clazz) {
                JAXBContext jc = null;
                String mediaSubtype = extractMediaSubtype();

                // Check for "node" mapping
                if (mediaSubtype.equals("vnd.nav+xml")
                                || mediaSubtype.equals("vnd.nav+xml;version=1") 
||
                                mediaSubtype.equals("vnd.nav+json")
                                || 
mediaSubtype.equals("vnd.nav+json;version=1")) {
                        jc = nodeResolver.getContext(clazz);
                } else { // we'll assume we are to use the annotation based 
domain mapping
                        jc = domainResolver.getContext(clazz);
                }

                return jc;
        }

        private String extractMediaSubtype() {
                String subtype;
                List<MediaType>  mediaTypes = hdrs.getAcceptableMediaTypes();

                // Assume there is only 1
                subtype = mediaTypes.get(0).getSubtype();

                return subtype;
        }

        /**
         * Constructor
         */
        public JaxbContextResolverSelector(JaxbContextResolverNav nodeResolver,
                        JaxbContextResolverDomain domainResolver) {
                this.nodeResolver = nodeResolver;
                this.domainResolver = domainResolver;
        }
}


--
View this message in context: 
http://cxf.547215.n5.nabble.com/Issue-with-JAX-RS-providers-getContextResolver-tp5451093p5452118.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to