[ 
https://issues.apache.org/jira/browse/ARIES-1157?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Bosschaert resolved ARIES-1157.
-------------------------------------

    Resolution: Invalid

It actually *does* work. I added a demo to the spi-fly examples that shows it 
working: http://svn.apache.org/viewvc?view=revision&revision=1565220

The reason why it appeared to not work in the previously attached example, was 
because the example was invoking the SPI directly in the 
{{BundleActivator.start()}} method. As SPI providers are registered 
asynchronously by SPI Fly after the provider bundle is started, this process 
hasn't happened yet. So basically the attached demo was invoking the SPI before 
it had a chance to register itself properly.

I think this dynamism is acceptable and actually very much the way OSGi is 
designed, so it's not an error. It does impose a timing constraint on the user 
of the SPI if it's used via {{ServiceLoader.load()}}. This is a disadvantage of 
using this API. A better solution would be to use the SPI via the OSGi Service 
Registry at which point you can use ordinary OSGi service dependencies and your 
timing issue is resolved.

> SPI-Fly does not support bundles that are both providers and consumers of the 
> same API
> --------------------------------------------------------------------------------------
>
>                 Key: ARIES-1157
>                 URL: https://issues.apache.org/jira/browse/ARIES-1157
>             Project: Aries
>          Issue Type: Bug
>            Reporter: David Bosschaert
>            Assignee: David Bosschaert
>         Attachments: 
> org.apache.aries.spifly.examples.provider.consumer.bundle-1.0.1-SNAPSHOT.jar
>
>
> When creating a bundle that is both an SPI provider and an SPI consumer the 
> consumer does not find the provider. 
> This has been observed with a bundle that does not provide the SPI API, but 
> contains both the provider jar as well as the consumer jar, which is invoked 
> from the activator.
> The bundle contains both these headers:
> {code}SPI-Consumer: *
> SPI-Provider: *{code}
> Note that this problem can be observed in Felix but not in Equinox because 
> Equinox sets the TCCL to the current bundle by default.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to