mathieuancelin / weld-osgi

This project aims to provide an OSGi integration for Weld. This project is no longer updated, see https://github.com/weld/core for updates
https://github.com/weld/core
12 stars 10 forks source link

CDI SPI management #37

Closed mathieuancelin closed 12 years ago

mathieuancelin commented 13 years ago

The SPI possibilities of CDI are fully supported in OSGi environment. To enable an extension inside a bundle, the META-INF/services/javax.enterprise.inject.spi.Extension file is required in that particular bundle. Then the sources of the extension can be bundled inside the bundle or in another visible bundle.

To enable automatically extensions on all OSGi bundles, it's possible to deploy CDI extension bundle with a special OSGi header such as :

CDI-Extension com.sample.foo.MyExtension;

Then, that particular extension will be used for each new OSGi/CDI bundle that will start.

Other related issues (merging tickets) :

arcane86 commented 13 years ago

In a regular bundle without CDI-Extension header: extension file is ignored In a regular bundle with CDI-Extension header: extension file is loaded (seems odd to me) In any bean bundle: extension file is loaded ?

mathieuancelin commented 13 years ago

I don't know, what's te best option ?

arcane86 commented 13 years ago

For me it should be like that: An META-INF/services/javax.enterprise.inject.spi.Extension file may be declared only in a bean bundle (i.e. next to a beans.xml file). Any other Extension file will be ignore. (and no need for a new header)

The implementation class may be in any visible bundle (not sure because of the dynamism, what if an extension is detected but no implementation class is not found ? We can't just activate the extension after the container was fully created).

The extension is applied for all new managed bundles (also not sure because if the implementation goes away, a bunch of managed bundles might have unknown behavior).

A brutal solution might be to restart all containers every time an extension come or leave (as when the CDI implementation come and go). But hey, there should not be thousands of coming and leaving extensions.

mathieuancelin commented 13 years ago

I think we only have 2 options here :

The dynamic part seems a little hard to do. The only way is to restart every bundle depending on it but that's a little hardcore.

WDYT ?

mathieuancelin commented 12 years ago

Closed with https://github.com/mathieuancelin/core/commit/10f4d4bc9ac0a7eb3b27b58ad2f423eb34cb9e96 and https://github.com/mathieuancelin/core/commit/fdc47866f9dccaa966da93e5b4175fb58e849941