FWIW, in ServiceMix, we have enhanced version of some specifications
(Stax included) which allows existing code to run seamlessly in OSGi:
i.e. code using XMLInputFactory.newInstance() will work as long as one
implementation bundle has been deployed.  You can find some
explanations at
http://gnodet.blogspot.com/2008/05/jee-specs-in-osgi.html and some
released artifacts are available from the public repositories in
http://repo1.maven.org/maven2/org/apache/servicemix/specs/.
This works roughly as Pierre explained: i.e. when a new bundle is
resolved, we look inside for META-INF/services and those informations
are used by the spec jar when a factory is about to be created.
The benefit (and it was the main goal) is to allow existing code to
run without any modification.

On Wed, Sep 24, 2008 at 12:08 PM, Kevin Lohmann
<[EMAIL PROTECTED]> wrote:
>
> Hi *,
>
> I guess, I have a misunderstanding about classloaders in OSGi and i
> appreciate, if someone can engross those thoughts.
>
> Here's a specific situation:
>
> Bundle A exports exports stax-api and implementation WoodStox. Bundle B
> has an import on just the stax-api (javax.xml.stream). Bundle B calls
> 'XMLInputFactory.newInstance();'.
>
> Now whats going on? According to
> 'http://java.sun.com/webservices/docs/2.0/tutorial/doc/StAX4.html' it is
> looking for file 'META-INF/services/javax.xml.stream.XMLInputFactory'
> "in jars available to the JRE". Bundle B finds this file and because
> bundle A exports the WoodStox-classes, everything works fine.
>
> But why? Remember: Bundle A has no exporting advice for META-INF (if
> thats ever possible) and bundle B has no importing on that.
>
> I try to split bundle A in two bundles: Bundle A1 contains the stax-api,
> bundle A2 the implementation (WoodStox). But now, when I call
> 'XMLInputFactory.newInstance();' in bundle B the file
> 'META-INF/services/javax.xml.stream.XMLInputFactory' is NOT found.
>
> I don't get the point and hope, someone can bring light into my/the
> darkness.
>
> Cheers,
>  Kevin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://open.iona.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to