Virgo overcomes this problem with its notion of a scoped application. A scoped application consists of either a PAR archive file containing the application artefacts (bundles, property files, plans, etc.) or a scoped plan referring to the application artefacts. The scope limits the visibility of application packages and services so that scoped applications do not interfere with each another. But Virgo also creates an additional synthetic context bundle for each scope and it's this bundle's class loader which is used for thread context class loading when the application calls out to libraries.
The synthetic context bundle is very simple. It's a bundle which uses Virgo's import-bundle manifest header to import each of the bundles in the scope. Thus all the packages exported by the application are available for thread context class loading by libraries. There is a minor restriction implied by this approach: no two bundles in a scoped application may export the same package, which would be pretty unusual.
The following example should help make things clear:
An Example Scoped Application |
This simple solution enables a variety of existing open source libraries, once converted to OSGi bundles, to function correctly in their use of thread context class loading.
Interesting approach.
ReplyDeleteDoesn't this require that both A and B are aware of this synthesized bundle and have the code logic to set the TTCL before making any calls.
Or is Virgo making this somehow transparent to the client?
Thanks, Tim.
Virgo makes this transparent to the application by setting the TCCL before each bundle is started and ensuring that the TCCL is propagated appropriately to other threads.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi Glyn, does this approach rely on the use of proxying by Spring or Blueprint in order to add the TCCL, or will a programmatic service lookup and call also have the TCCL set?
ReplyDeleteThanks, Graham.
Hi Graham. It relies on Blueprint. Regards,
ReplyDeleteGlyn
PS. Sorry for the very late response - I stopped getting comment moderation emails for some reason.