The SPi-Fly never consumes OSGi services on the SPI consumer side of the equation.
It only makes OSGi services available from the provider side for non-SPI consumers (like DS, OSGiCDI, Blueprint, and so on.) - Ray On Wed, Sep 18, 2019 at 11:56 AM Cyrille Duret <cdu...@gmail.com> wrote: > OK I will stick with setting > <SPI-Provider>*</SPI-Provider> > <SPI-Consumer>*</SPI-Consumer> > in bundle A and it works > > I don't need any > <SPI-Consumer>*</SPI-Consumer> > in bundle B since all calls are done in neo4j API in bundle A. > > I thought that spi-fly would supersede the ServiceLoader and use the OSGI > services exported to retrieve the service instance > > g! inspect capability service 20 > org.hug.simed.rdf.neo4j-api [20] provides: > ------------------------------------------ > .. > service; org.neo4j.configuration.LoadableConfig with properties: > .org.apache.aries.spifly.provider.implclass = > org.neo4j.graphdb.factory.GraphDatabaseSettings > service.bundleid = 20 > service.id = 59 > service.scope = bundle > serviceloader.mediator = 4 > service; org.neo4j.configuration.LoadableConfig with properties: > .org.apache.aries.spifly.provider.implclass = > org.neo4j.kernel.configuration.ssl.LegacySslPolicyConfig > service.bundleid = 20 > service.id = 60 > service.scope = bundle > serviceloader.mediator = 4 > service; org.neo4j.configuration.LoadableConfig with properties: > .org.apache.aries.spifly.provider.implclass = > org.neo4j.kernel.configuration.ssl.SslPolicyConfig > service.bundleid = 20 > service.id = 61 > service.scope = bundle > serviceloader.mediator = 4 > service; org.neo4j.configuration.LoadableConfig with properties: > .org.apache.aries.spifly.provider.implclass = > org.neo4j.kernel.impl.index.schema.config.SpatialIndexSettings > service.bundleid = 20 > service.id = 62 > service.scope = bundle > serviceloader.mediator = 4 > service; org.neo4j.configuration.LoadableConfig with properties: > .org.apache.aries.spifly.provider.implclass = > org.neo4j.kernel.configuration.ssl.SslSystemSettings > service.bundleid = 20 > service.id = 63 > service.scope = bundle > serviceloader.mediator = 4 > .. > > Still confused how the mediator works internally > > thanks > > On Wed, Sep 18, 2019 at 5:02 PM David Bosschaert < > david.bosscha...@gmail.com> wrote: > >> Hi Cyrille, >> >> Does the loadAllConfigClasses() method work properly if the the neo4j jar >> is not embedded but rather in a bundle by itself? >> >> Best regards, >> >> David >> >> On Wed, 18 Sep 2019 at 12:59, Cyrille Duret <cdu...@gmail.com> wrote: >> >>> Hello, >>> I want to embedd neo4j in a bundle A, and create an graph database in a >>> bundle B. >>> >>> Neo4j kernel artifact relies heavily on SPI mechanism for exposing >>> config properties so I use SPI Fly to mediate the java ServiceLoader : >>> <dependency> >>> <groupId>org.apache.aries.spifly</groupId> >>> <artifactId>org.apache.aries.spifly.dynamic.bundle</artifactId> >>> <version>1.2.3</version> >>> </dependency> >>> >>> >>> My bundle A config : >>> >>> <Embedd-Dependency> >>> .. >>> *;groupId=org.neo4j;artifactId=neo4j-kernel;inline=META-INF/services/*, >>> .. >>> </Embedd-Dependency> >>> <SPI-Provider>*</SPI-Provider> >>> <Export-Package> >>> ..org.neo4j.configuration;version=${neo4j-version}, >>> ..</Export-Package> >>> >>> >>> My bundle B config : >>> >>> <Import-Package> >>> .. >>> org.neo4j.configuration;version=${neo4j-version}, >>> .. >>> </Import-Package> >>> <SPI-Consumer>*</SPI-Consumer> >>> >>> >>> In my B activator start method : >>> import org.neo4j.configuration.LoadableConfig; >>> .. >>> ServiceLoader<LoadableConfig> serviceLoader = >>> ServiceLoader.load(LoadableConfig.class); >>> Iterator<LoadableConfig> it = serviceLoader.iterator(); >>> // I can see all exposed config from bundle A >>> while( it.hasNext() ) { >>> final LoadableConfig config = it.next(); >>> System.out.println("-> "+config); >>> } >>> >>> // The call from this static method does not return any config >>> List<LoadableConfig> configs = LoadableConfig.allConfigClasses(); >>> System.out.println("configs from LoadableConfig => "+configs.size()); >>> >>> >>> the org.neo4j.configuration.LoadableConfig.allConfigClasses method which >>> is embedded in A has the following implementation : >>> static List<LoadableConfig> allConfigClasses() >>> { >>> return Iterators.stream( ServiceLoader.load( LoadableConfig.class >>> ).iterator() ).collect( Collectors.toList() ); >>> } >>> >>> I do not understand why the allConfigClasses() method does not see the >>> exposed SPI services and why my ServiceLoader.load snippet code does. >>> I have noticed that if I added <SPI-Consumer>*</SPI-Consumer> to A, the >>> LoadableConfig.allConfigClasses does indeed work. >>> >>> Anyone can explain me why the static method does not work in the first >>> place and why it does when adding <SPI-Consumer>*</SPI-Consumer> to A ?? >>> >>> thank you >>> Cyrille >>> >>> -- *Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile> (@rotty3000) Senior Software Architect *Liferay, Inc.* <http://www.liferay.com> (@Liferay)