services, take 1
Alan Bateman
Alan.Bateman at oracle.com
Mon Dec 19 03:54:43 PST 2011
On 19/12/2011 10:30, David Bosschaert wrote:
> I have been looking at using ServiceLoader inside OSGi and one of the
> biggest problems is (IMHO) that it's completely static. This means
> that once a service is handed out to a consumer this client has that
> reference forever (basically as long as that client exists). The
> consumer may not actually hold on to the reference, but ServiceLoader
> has no control over that.
>
> I think it would be really good to add a mechanism to ServiceLoader
> that could inform a consumer that a service is now removed. This would
> mean that in more dynamic environments, such as OSGi, where modules
> can be removed during the lifetime of the VM, it would be possible to
> create clients such that they won't hold on to handed out services
> forever...
>
Can you expand a bit on what you mean by "remove"? Do you mean that the
module loader for a module providing a service has been GC'ed, or do you
mean a module providing a service is removed from a module library? Or
maybe you looking to "disable" a module that a provides a service so
that ServiceLoader will not return any further references to instances
of that type?
-Alan.
More information about the jigsaw-dev
mailing list