cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Holtzman <>
Subject Re: Whiteboard pattern for JAX-RS services
Date Thu, 25 Jun 2009 01:17:04 GMT
On Tue, Jun 23, 2009 at 8:46 AM, Sergey Beryozkin <>wrote:

> Hi Josh
>  I've got some code that allows OSGI bundles to use the whiteboard pattern
>> to
>> register restful services.  When a service is registered with a specific
>> property, say, "jaxrs.resource=true" the JAX-RS implementation registers
>> that service as a JAX-RS resource.  The same could be done with message
>> body
>> readers and writers, too.  In my implementation, the JAX-RS servlet is
>> registered under the "/rest/*" URL, and all of the JAX-RS resources fall
>> below that, so /rest/foo can be provided by one bundle and /rest/bar could
>> be provided by another.
> I'd like to ask your opinion about providing JAXRS providers through this
> pattern.
> In DOSGi we can now handle the registration of services and expose them as
> web services using whatever style/frontend is needed (ws/rs).
> As far as JAX-RS providers are concerned, we can only handle at the moment
> a limited number of them, specifically JAXB/Aegis
> MessageBodyReaders/Writers. It would be easy to add shortcuts for other
> ones, say if a databinding property says 'atom' or 'xmlbeans' then we can
> figure out what to do.
> But in JAX-RS we can also have exception mappers, CXF specific exception
> mappers which are used to handle exceptions on the client side, filters,
> etc, they all can act as providers. Now, one option would be to scan an
> implementation bundle for provider classes, those which have @Provider
> annotation.
> This may or may not always work as these providers may actually come from
> some other bundle, say from some bundle acting as a providers repository.
> So my thinking is that it should possible to supply provider instances
> during the service registration or lookup from a given activator, as an
> array value of some service property. This will make it possible to
> configure individual provider instances too.
> Does it make sense ? Any other ideas ?
> cheers, Sergey
I'm not sure how CXF keeps track of these providers now, but I assume
there's a registry of some kind.  Are the providers tied to specific jax-rs
resources, or are they "global"?  If it's a global registry, it should be
trivial to add a service tracker that watches for new services that are
registered with the osgi container under the MessageBodyReader,
MessageBodyWriter, or ExceptionMapper interfaces.  The service tracker would
add or remove the providers from the internal CXF provider registry.  That's
what I did with the resteasy spi, but I am not as familiar with how CXF
keeps track of providers.

Oh, and sorry to hijack the thread, but I've been using the jax-rs frontend
for DOSGi and I'm very happy with it... thanks for all of your work in this
area.  Job well done!


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message