On 9/27/10 10:16, Sandra Krneta wrote:
But my service is inside some package that some bundle exports,
so if I stop bundle serice is gone and also package is gone,
I don't understand how service can go without package.
and how can I have two services with same name that don't come
from two different packages.

Packages and services have different life cycles. Imagine you have three bundles:

  1. Bundle A exports org.osgi.service.log.
  2. Bundle B imports org.osgi.service.log and provides a log service.
  3. Bundle C imports org.osgi.service.log and consumes a log service.

Bundles B and C end up importing from A. Both B and C need to be started so they can provide and consume services. Bundle A doesn't need to be started at all, but can still export its log package. If you stop bundle B, its service goes away which impacts bundle C, but has no impact whatsoever on A and its exported package.

Package life cycle is dictated by the RESOLVED status of a bundle, while service life cycle is dictated by the ACTIVE status of a bundle.

-> richard

Can you tell me if you know some good example for this on the web?

------------------------------------------------------------------------
**

  Services are more dynamic than packages; they can come and go at will,
package wiring cannot. Once a bundle is wired to a given package, it
will not wire to another provider until the framework is refreshed.
Performing an update is not sufficient. You must always refresh the
framework to cause any rewiring.

-> richard

On 9/27/10 2:33, Sandra Krneta wrote:
>
> I have component consuming MusicPlayer service, that service is
> declarative service and its component.xml
>
> Looks like this
>
> <implementation class="playercoreimpl.MusicPlayerServiceImpl"/>
>
> <service>
>
> <provide interface="playercore.MusicPlayerService"/>
>
> </service>
>
> Component that consumes it imports player core service
>
> *Import-Package*:
>
> org.osgi.framework;/version/="1.3.0",
>
> playercore;/version/="[1.0.0,2.0.3)",
>
> and has component.xml like this
>
> <implementation class="testbundle.Activator"/>
>
> <reference bind="setMusicPlayer" cardinality="1..1"
> interface="playercore.MusicPlayerService" name="MusicPlayerService"
> policy="dynamic" unbind="unsetMusicPlayer"/>
>
> And bind and unbind methods look like this
>
> * private* AtomicReference<MusicPlayerService> musicPlayerRef = *new*
> AtomicReference<MusicPlayerService>();
>
> * public* *void* setMusicPlayer(MusicPlayerService musicPlayer) {
>
> musicPlayerRef.set(musicPlayer);
>
> setMusicPlayerToPlayer(musicPlayer);
>
> }
>
> *public* *void* unsetMusicPlayer(MusicPlayerService musicPlayer) {
>
> musicPlayerRef.compareAndSet(musicPlayer, *null*);
>
> }
>
> The problem is, when I have two bundles that export playercore package
> (different versions)started in framework
>
> and I stop one of them, just unbind method is called and consuming
> bundle stops, it doesn’t start using other version
>
> of service. Update of consuming bundle doesn’t help.
>
> One more thing is confusing, if bundle that exports playercore with
> lower version is started and consumer bundle is started,
>
> But then I stop player corebundle, consuming bundle stops, then after
> installation and starting of playercore component
>
> with higher version and update of consuming component, component is
> started, but vice versa it is not case.
>
> I am using Equinox.
>
> If anyone has solution for this, please let me know it is urgent
>
>
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected] <mailto:[email protected]>
> https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected] <mailto:[email protected]>
https://mail.osgi.org/mailman/listinfo/osgi-dev


_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to