You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Wei Zhang (JIRA)" <ji...@apache.org> on 2015/04/30 04:02:05 UTC
[jira] [Created] (CXF-6380) Context provider not working
Wei Zhang created CXF-6380:
------------------------------
Summary: Context provider not working
Key: CXF-6380
URL: https://issues.apache.org/jira/browse/CXF-6380
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 3.0.3
Reporter: Wei Zhang
Come from a TCK test. In the test, there is an Entity provider with readFrom returns null. And a context provider which provides a customized JAXBContext and corresponding Marshaller and unmarshaller.
@Provider
public class JaxbContextProvider
implements ContextResolver
{
public JAXBContext getContext(Class type)
{
JAXBContext ctx = new MyJaxbContext();
return ctx;
}
public volatile Object getContext(Class clazz)
{
return getContext(clazz);
}
}
@Provider
public class MyJaxbProvider
implements MessageBodyReader, MessageBodyWriter
{
......
public JAXBElement readFrom(Class type, Type genericType, Annotation annotations[], MediaType mediatype, MultivaluedMap multivaluedmap, InputStream inputstream)
throws IOException, WebApplicationException
{
return null;
}
......
}
And there is a resource class which returns a JAXBElement object.
@Path("resource")
public class Resource
{
@Path("jaxb")
@POST
public JAXBElement jaxb(JAXBElement jaxb)
{
return jaxb;
}
}
When accessing this resource, I found only the entity provider is working, and null response(status code 204) is returned. And the context Provider was not working(getContext method defined in this provider was not triggered at all).
When removing this entity provider from our test application, the context provider is working and an JAXB object is mashalled to the response(with status code 200).
In the JSR339, I only found following declaration about the usage of entity provider and context provider.
See 4.2.4
An implementation MUST support application-provided entity providers and MUST use those in preference
to its own pre-packaged providers when either could handle the same request. More precisely, step
4 in Section 4.2.1 and step 5 in Section 4.2.2 MUST prefer application-provided over pre-packaged entity
providers.
In my understanding, if user only defines its own context provider without customized entity provider, application providered context provider should be preferred over CXF default implmentation of entity provider.
And this usage of both customized context provider and customerized entity provider, which provider should be prefered is out of specification definition.
But when testing on Apache/Jersy with this test applicatoin, response with status code 200 is returned.
Would you please advice if this can be a defect in CXF, or you think it's out of specification definition.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)