[
https://issues.apache.org/jira/browse/DOSGI-266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16001383#comment-16001383
]
Ivo Leitão commented on DOSGI-266:
----------------------------------
Hello Christian,
Well I can confirm that the first approach does not work :-(. I've pulled
latest DOSGi code with your changes, added the SearchContextProvider to the
list of intents and the SearchContext is not injected (in paxexam or karaf).
On the bright side you are absolutely right in your suggestion something like
this (taken from my sample source code) :
{code:title=ResourceImpl.java|borderStyle=solid}
@Override
public List<TaskDTO> getTasks(@Context SearchContext searchContext) {
System.out.println("SearchContext is " + searchContext);
return
TodoResourceMapper.INSTANCE.toTaskList(taskDAO.getTasks());
}
{code}
Works, so I can confirm that this injection works only at the method level. My
problem with this approach is the binding to CXF at interface level :-S since I
need to add this to the interface also:
{code:title=Resource.java|borderStyle=solid}
@GET
@ApiOperation(value = "Fetches all the tasks", response =
TaskDTO.class, responseContainer = "List")
List<TaskDTO> getTasks(@Context SearchContext searchContext);
{code}
However I think I can abstract this with a custom wrapper class. I was hopping
for a better approach but I think this is the best I can get...
> Support for org.apache.cxf.jaxrs.ext.ContextProvider
> ----------------------------------------------------
>
> Key: DOSGI-266
> URL: https://issues.apache.org/jira/browse/DOSGI-266
> Project: CXF Distributed OSGi
> Issue Type: New Feature
> Components: provider-rs
> Affects Versions: 2.1.0
> Reporter: Ivo Leitão
> Assignee: Christian Schneider
> Fix For: 2.2.0
>
>
> I would like to use CXF support for search
> http://cxf.apache.org/docs/jax-rs-search.html and for that I need to register
> a provider. In my tests the SearchContext is always null and I think it is
> caused by
> https://github.com/apache/cxf-dosgi/blob/master/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
> where
> {code:title=RsProvider.java|borderStyle=solid}
> ....
> private boolean isProvider(Object intent) {
> return (intent instanceof ExceptionMapper) //
> || (intent instanceof MessageBodyReader) //
> || (intent instanceof MessageBodyWriter) //
> || (intent instanceof ContextResolver);
> }
> ....
> {code}
> only supports ContextResolver and not ContextProvider
> I'm going to try to make a workaround with a features but this is needed in
> order to make this work.
> Quoting CXF documentation:
> "Additionally, starting from CXF 2.6.0, SearchContextProvider needs to be
> registered as jaxrs:provider."
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)