... replies inline ...
----- Original Message -----
From: "David M. Lloyd" <david.lloyd(a)redhat.com>
To: jboss-as7-dev(a)lists.jboss.org
Sent: Wednesday, 1 June, 2011 9:51:04 PM
Subject: Re: [jboss-as7-dev] MSC service names in AS7
On 06/01/2011 03:08 PM, David Bosschaert wrote:
>
> One further question. Let's say my service performs some async
> action in start() and when that action is finished I'm not really
> interested in the service any more. Should I remove it somehow from
> the system then?
In other words, a one-time task which is triggered when all its
dependencies start? We don't have a generalized API for this. There
are subtle conceptual issues.
Yes, correct.
First, using a service will cause its dependencies to automatically
start if they are, say, ON_DEMAND. However if your service then
immediately stops or is removed, the dependency services will stop
again, which is not a useful semantic.
You can use listeners instead, however a listener can only presently
be
added to an installed service (i.e. you can't install a listener on a
name in anticipation of a future service).
So the real question is, what problem are you trying to solve here?
Ok, so let's look at an example. In the AutoInstallIntegration service in the OSGi
subsystem it first installs the bundles asynchronously and then, on line 140 it creates an
anonymous service that runs once the install of all bundles is finished to start them.
Is this correct service usage?
> Additionally, let's say I have a service that can run more
than
> once, should I give it a different name every time?
Services can be stopped and started repeatedly, and in fact it is part
of the contract of a service that it must be able to do so.
Hmmm, it looks like the services in [1] don't adhere to this contract, as the stop is
a no-op...
Cheers,
David
[1]
http://github.com/bosschaert/jboss-as/blob/master/osgi/service/src/main/j...