Closed mathieuancelin closed 12 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 ?
I don't know, what's te best option ?
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.
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 ?
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 :
Then, that particular extension will be used for each new OSGi/CDI bundle that will start.
Other related issues (merging tickets) :