You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Daniel McGreal <da...@redbite.com> on 2014/02/13 12:27:59 UTC
Component tied to garbage collection
Hi Felix users,
An application, for which I use Felix, has some functionality which I would like to only be active if the JVM has enough memory to support it. I wonder, can anyone think of a way of tying component (or bundle) lifecycle to some kind of SoftReference, so that the relevant lifecycle ((de)activate/start/stop) methods can be called when objects are GCd, and that the bundle/component can be relaunched when there is enough memory again?
Many thanks, Dan.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Component tied to garbage collection
Posted by Marcel Offermans <ma...@luminis.eu>.
On 13 Feb 2014, at 12:27 pm, Daniel McGreal <da...@redbite.com> wrote:
> An application, for which I use Felix, has some functionality which I would like to only be active if the JVM has enough memory to support it. I wonder, can anyone think of a way of tying component (or bundle) lifecycle to some kind of SoftReference, so that the relevant lifecycle ((de)activate/start/stop) methods can be called when objects are GCd, and that the bundle/component can be relaunched when there is enough memory again?
The Dependency Manager [1] allows you to define "custom" dependencies, so you could create a component that way that has a dependency is only available if you have enough memory. There is a test case that shows a simple custom dependency [2], probably a good starting point to start writing.
Greetings, Marcel
[1] http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager.html
[2] https://svn.apache.org/repos/asf/felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/api/CustomDependencyTest.java