I am trying to run DOSGI in Apache Felix. I use CXF 3.2.0 bundles and DOSGI 2.3.0
I can successfully register services but I can not register global custom providers for my resources.
I have a Resource defined in interface:
@Path("")
public interface IToDoResource {
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
List<ToDo> getAllToDos();
@GET
@Path("{id}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
ToDo getToDoById(@PathParam("id") Long id);
...
}
Then implemented in:
@Component(//
name = "My.ToDoRestService", //
immediate = true, //
property = //
{ //
"service.exported.configs=org.apache.cxf.rs", //
"service.exported.interfaces=*", //
"org.apache.cxf.rs.address=/todos", //
} //
)
public class ToDoResource implements IToDoResource {
....
}
I try to register Global custom Providers for my classes. I can make it working with "service.exported.intents" property on the resource and "IntentName" on the provider for one provider. However for this resource I want to register 4 providers:
- ToDo XML provider
- ToDo Json provider
- ArrayList XML provider
- ArrayList Json provider
Alternatively I can also implement IntentsProvider on the resource and it also works.
However following does not work and I get no provider registered for this type error in the logs:
@Component(//
name = "My.ToDoJsonProvider", //
immediate = true, //
service = MessageBodyWriter.class, //
property = {
"service.exported.configs=org.apache.cxf.rs", //
"org.apache.cxf.rs.provider=true", //
} //
)
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class ToDoJsonProvider implements MessageBodyWriter<ToDo> {
GET on localhost:8080/cxf/todos/1 returns empty document and on logs:
JAXRSUtils:1834] No message body writer has been found for class my.todo.repository.api.ToDo, ContentType: application/xml
What do I miss here to register a custom provider globally?