Hi Scott,

You should be able to control at least some of these factories through the
Apache Aries SPI-Fly component.
SPI-Fly implements the OSGi ServiceLoader mediator specification but what
you are looking for is actually a proprietary extension to SPI-Fly. To get
an idea how to do this, see the documentation [1] and the example test case
at [2].
The test case shows how to pick up a different JAXP implementation by
controlling the TCCL. For example you can set the following header in your
consumer bundle:
  SPI-Consumer:
javax.xml.parsers.DocumentBuilderFactory#newInstance();bundle=my.alt.provider.bundle
This ensures that the TCCL is set have visibility of my.alt.provider.bundle
for the duration of the DocumentBuilderFactory.newInstance() call. You can
also add more than 1 bundle (bundle=b1|b2|b3).

It's not guaranteed that it can currently work with all the APIs you're
mentioning, but if the mechanics can be controlled via the TCCL it should
be possible to get it to work. Otherwise it might be worth expanding
SPI-Fly to cover those extra cases...

BTW I'm not advocating use of the TCCL here, Service Registry is obviously
much, much better. But in cases where you have no choice the above might
help...

Cheers,

David

[1] http://aries.apache.org/modules/spi-fly.html
[2] Test method testJAXPClientWantsAltImplementation2() in
http://svn.apache.org/repos/asf/aries/trunk/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java


On 26 February 2013 02:03, Scott Lewis <[email protected]> wrote:

>  On 2/25/2013 10:34 AM, BJ Hargrave wrote:
>
> > I have a case where I would like to substitute own providers for the jre
> > default TransformerFactory, SchemaFactory, JAXBContext and other
> factories.
> >
> > I see from the OSGi 5.0 enterprise XML Parser service spec that it's
> > possible to register DocumentBuilderFactorys and SAXParserFactorys...but
> > these two seem to be the only factories listed in the spec, and I don't
> > see anything in the spec about TransformerFactory, SchemaFactory,
> > JAXBContext, etc.
> >
> > Is there some part of spec...or other resources..that deals with these
> > other xml factories?
>
> No. But you can still register them yourself as services.
>
>
> Is there any plan or effort to incorporate these factories into
> spec...similar to the way that DocumentBuilderFactory and SAXParserFactory
> have been incorporated?
>
> Scott
>
>
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to