You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by David Lindelöf <da...@adhoco.com> on 2007/10/22 11:01:38 UTC

Services registered by foreign bundle

Hi all,

What exactly happens when bundle A registers services with objects from
bundle B and B subsequently stops? Who is considered as having
registered the service? Do these services become unregistered?

Kind regards,
-- 
--------------------------------------------------
David Lindelöf
Product Developer
Adhoco AG
Technopark
Jagerstrasse 2
8406 Winterthur
tel +41-52-264.5070
mob +41-79-415.6641
fax +41-52-264.5099
e-mail david.lindelof@adhoco.com
url http://www.adhoco.com
weblog http://www.visnet.ch/smartbuildings/
--------------------------------------------------

Trying to define yourself is like trying to bite your own teeth.
		-- Alan Watts

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Services registered by foreign bundle

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

The question is which BundleContext you are using. If your are using the
BundleContext of Bundle A, it is Bundle A registering the service, if
the BundeContext is the one of Bundle B, it is Bundle B registering the
service.

I would strongly suggest to actually use Bundle B's BundleContext, such
that the OSGi service registry may unregister the services when Bundle B
is stopped.

BTW: Have you consider using Declarative Services ?

Regards
Felix

Am Montag, den 22.10.2007, 11:36 +0200 schrieb David Lindelöf:
> Hi Karl,
> 
> On Mon, 2007-10-22 at 11:08 +0200, Karl Pauls wrote:
> > > What exactly happens when bundle A registers services with objects from
> > > bundle B and B subsequently stops?
> > 
> > Are you talking about instance of classes that A imports from B?
> 
> I'm trying to implement the whiteboard pattern in a transparent manner
> for bundle B:
> 
> Bundle A defines a Subscriber interface. Bundle B has objects that
> implement Subscriber.
> 
> Bundle A also defines a Subscribable interface, that looks like
> 
> public interface Subscribable {
>  public void subscribe(Subscriber subscriber);
> }
> 
> Bundle A implements this interface with something like:
> 
> public class SubscribableImpl {
>  public void subscribe(Subscriber subscriber) {
>   context.registerService(Subscriber.class.getName(), subscriber);
>  }
> }
> 
> The subscribers are then notified of events by looking them up in the
> service registry.
> 
> Now what happens if bundle B calls something like:
> 
> Subscribable subscribable = new SubscribableImpl();
> subscribable.subscribe(new Subscriber() {
>  ...});
> 
> And what happens when bundle B subsequently stops?
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Services registered by foreign bundle

Posted by David Lindelöf <da...@adhoco.com>.
Hi Karl,

On Mon, 2007-10-22 at 11:08 +0200, Karl Pauls wrote:
> > What exactly happens when bundle A registers services with objects from
> > bundle B and B subsequently stops?
> 
> Are you talking about instance of classes that A imports from B?

I'm trying to implement the whiteboard pattern in a transparent manner
for bundle B:

Bundle A defines a Subscriber interface. Bundle B has objects that
implement Subscriber.

Bundle A also defines a Subscribable interface, that looks like

public interface Subscribable {
 public void subscribe(Subscriber subscriber);
}

Bundle A implements this interface with something like:

public class SubscribableImpl {
 public void subscribe(Subscriber subscriber) {
  context.registerService(Subscriber.class.getName(), subscriber);
 }
}

The subscribers are then notified of events by looking them up in the
service registry.

Now what happens if bundle B calls something like:

Subscribable subscribable = new SubscribableImpl();
subscribable.subscribe(new Subscriber() {
 ...});

And what happens when bundle B subsequently stops?


-- 
--------------------------------------------------
David Lindelöf
Product Developer
Adhoco AG
Technopark
Jagerstrasse 2
8406 Winterthur
tel +41-52-264.5070
mob +41-79-415.6641
fax +41-52-264.5099
e-mail david.lindelof@adhoco.com
url http://www.adhoco.com
weblog http://www.visnet.ch/smartbuildings/
--------------------------------------------------

Fools rush in -- and get the best seats in the house.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Services registered by foreign bundle

Posted by Karl Pauls <ka...@gmail.com>.
Hi David,

> What exactly happens when bundle A registers services with objects from
> bundle B and B subsequently stops?

Are you talking about instance of classes that A imports from B?

> Who is considered as having registered the service? Do these services become
> unregistered?

In case you are, then the answer is bundle A and no the services will
not be unregistered but bundle A will be refreshed (i.e., stopped and
started again) on the next call to PackageAdmin.refresh(null) or
PackageAdmin.refresh(new Bundle[]{..., A, ...}).

regards,

Karl

> Kind regards,
> --
> --------------------------------------------------
> David Lindelöf
> Product Developer
> Adhoco AG
> Technopark
> Jagerstrasse 2
> 8406 Winterthur
> tel +41-52-264.5070
> mob +41-79-415.6641
> fax +41-52-264.5099
> e-mail david.lindelof@adhoco.com
> url http://www.adhoco.com
> weblog http://www.visnet.ch/smartbuildings/
> --------------------------------------------------
>
> Trying to define yourself is like trying to bite your own teeth.
>                 -- Alan Watts
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org