On Thu, Jun 25, 2009 at 8:46 AM, Sergey Beryozkin <sbery...@progress.com>wrote:
> Hi Josh > > > I'd like to ask your opinion about providing JAXRS providers through this >>> pattern. >>> >> <snip/> > >> >>> > 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. >> > > CXF JAX-RS has a global registry which provides providers supporting > formats/features as requested by the spec (for ex JAXB support, etc). These > providers are shared. In addition, every endpoint gets the opportunity to > register per-endpoint unique providers. Some endpoints may or may not share > the same instances but it's up to the app developer. So say the same JAXB > provider may be configured to suit a particular endpoint's needs > > Thus, given that the endpoint or client is created by DOSGI, I was thinking > about the user bundles providing a list of additional providers using a > service property : > > Dictionary props = ... > props.put("org.apache.cxf.rs.providers", new Object[]{provider1, > provider2}); > > and then publish or attempt to bind... > > and DOSGI will use them at the point of creating the endpoint/client > > I'm wondering, would this approach work for you ? > Yes, partially. Since there are multiple scopes, I think there should be multiple mechanisms for registering providers. A developer should be able to register a global provider by simply publishing it as an OSGi service, and should be able to register per-endpoint providers in the manner you describe above. If global provider registration is not a priority for others, I'd be happy to work on a patch. Just let me know when things settle down in this area, so we don't wind up with a difficult-to-merge patch :) Thanks, Josh