You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2015/06/24 12:25:04 UTC
[jira] [Commented] (CXF-6472) Cannot create ContextResolver for
class extending HttpServletRequest, HttpServletResponse, etc.
[ https://issues.apache.org/jira/browse/CXF-6472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14599223#comment-14599223 ]
Sergey Beryozkin commented on CXF-6472:
---------------------------------------
Unfortunately this issue is invalid. ContextResolver is not a mechanism to override the runtime providing the standard contexts. As far as I know its primary and only use is to have it working alongside a JAXB provider, it even has a mediaType parameter in one of its methods for supporting a media type version strategy.
I believe RI, RestEasy, and indeed CXF all offer its own mechanisms to support the injection of custom providers, in case of CXF it is ContextProvider. I know there's a demand to support the custom contexts in a standard way in 2.0.
However, putting the issue of ContextResolver aside, I agree the issue of whether a framework-specific mechanism (CXF ContextProvider) can be used to override the contexts which the runtime is expected to offer by default, i.e, if say ContextProvider<UriInfo> is available then should the runtime trust this provider to offer a rather complex UriInfo implementation, etc ? I doubt it but I'll double check
> Cannot create ContextResolver for class extending HttpServletRequest, HttpServletResponse, etc.
> -----------------------------------------------------------------------------------------------
>
> Key: CXF-6472
> URL: https://issues.apache.org/jira/browse/CXF-6472
> Project: CXF
> Issue Type: Bug
> Affects Versions: 3.0.4, 3.1.1
> Environment: all
> Reporter: tomek778
>
> I tried to wrap HttpServletRequest by using ContextProvider, lets assume such a simple implementation:
> @Provider
> public class CustomHttpRequestContextResolver implements ContextResolver<CustomHttpRequest> {
> @Context
> private HttpServletRequest request;
> public CustomHttpRequest getContext(Class<?> type) {
> return new CustomHttpRequest(request);
> }
> }
> However, before calling context provider CXF first calls JAXRSUtils.createServletResourceValue() method that tries to cast HttpServletRequest into my wrapped request and it fails with ClassCastException.
> I havent found in JAX_RS spec anything telling that such a ContextResolver is forbidden.This works also with Apache Wink.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)