Hi

On Mon, May 17, 2010 at 8:50 PM, kdog <[email protected]> wrote:

>
> To use the XSLTJaxbProvider, you must specify some custom properties like
> outMediaTemplates (etc). However, I am confused how you would use this as a
> provider for DOSGI. It is my understanding that to use providers where you
> set properties with DOSGI, you have to register the provider as an OSGI
> service.


At the moment providers with custom properties can only be set from the code
in DOSGi.
One approach is indeed registering them as OSGI Services


> However, I am confused how you would do this with XSLTJaxbProvider.
> First, how do you define the provider as an OSGI service? Then how do you
> use the provider as the OSGI service as opposed to instantiating a new
> instance via the raw class (using "org.apache.cxf.rs.provider")?
>

it is just an OSGI service registration call from a custom bundle activator
[1] where the first parameter will specify a JAXRS MessageBodyWriter, while
the 2nd one will be an explicitly created XSLTJaxbProvider with some custom
properties set. This can be done from a bundle dedicated to registering
providers are services but can also be done from the activator of the
application bundle. Example :

Object provider = new CustomMessageBodyReaderWriter();
bundleContext.registerService(
  new String[]{"javax.ws.rs.ext.MessageBodyReader",
"javax.ws.rs.ext.MessageBodyReader"}, provider);



There's also another (though similar) approach. You can register a provider
as a property of the main application service, see a Registering custom
providers subsection at [2]

hope it helps, Sergey

[1]
http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html#registerService%28java.lang.String,%20java.lang.Object,%20java.util.Dictionary%29
[2]
http://cxf.apache.org/distributed-osgi-reference.html#DistributedOSGiReference-ServiceProviderpropertiesForConfiguringRESTfulJAXRSbasedendpointsandconsumers

--
> View this message in context:
> http://old.nabble.com/DOSGI-and-XSLTJaxbProvider-tp28587925p28587925.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Reply via email to