Hi,
I recently posted a question, and noticed, that I seem to have replied
to an old thread instead of creating a new one (simply clicking reply to
an earlier email I got).
So I'm reposting it (all three initial posts into one though), since it
might allow some people to notice it, who otherwise would not see it
(and maybe someone has an idea).
I have some code that relies on other apps. Now, I would like it to work
regardless on whether someone installs/disables the other app.
So what I'm currently ding is:
a: on activation check whether the appropriate Classes are available
(and if they are set the corresponding service object in my class).
b: When the respective service gets unregistered, I remove the reference
from my own class setting the corresponding object to null
Now I have the following issue:
-> I start up cytoscape, my app gets loaded before the other app.
No problem so far as my servicelistener catches the start of the other
app and sets the appropriate object. The same is true, when the other
app gets loaded before my app, in which instance I can simply use the
service that app registered.
-> I disable the other app
Still Fine, my listener properly sets the object to 0 and I can keep on
working with this setting.
-> I reactivate the other app
For some reason my servicelistener does not get a service event for the
class I need any more.
In fact, there is no service event at all being fired that would
indicate that this service is now available.
I would have expected something like I find the class but get a class
cast exception (which would require some unget for the service to get it
out of my classloader, which I'm actually not sure how to do with
cytoscape). But not getting any event leaves me puzzled as I don't get
any other error neither.
Does anyone know what could cause this issue?
A small update:
I tried to see, whether the event was no longer fired or whether my app
was just not informed about the event.
From what I can determine, it's the latter.
A different app thats just listening to the events does get the event,
it's only my app that is left "in the dark".
I think, what I need is to listen to a class, that is not yet available,
but I have no clue how to do this.
If I use registerServiceListener, I get a NoClassDefFound Error (which
is to be expected) when the other app is not yet loaded.
If the other app was loaded previously, everything seems fine initially
and I have a listener for the class.
If after this initial integration the app is deactivated, it is
(manually) unregistered) from my app, i.e. the respective objects are
removed, but I have the impression, that e.g. classes used still remain
in my bundle.
This seems to interfere with any service listening, as I'm now listening
to a class that (while having the same name) has a different class
loader (in fact one, thats no longer existing).
From some googling I got the impression, that the only way to get the
old stuff (from the previous activation) out of my bundles scope is to
call a rewiring on the framework.
However this seems to be something that will probably result in a
complete reset of my app (whih is not really what I would like).
Anyone with an idea how this could be solved without completely
restarting the app every time an optional dependency is activated?
Second update:
From all I could figure out, the issue is, that the framework for some
obscure reason is not propagating the Servicechanged event to my app
once the other app got disabled.
The event is still fired, and can be logged with a different app, its
just hidden from my app.
I currently assume that this happens due to some imports my app uses
from the other app, but I'm not sure, how to solve this.
Best
Thomas
--
Université du Luxembourg
Faculté des Sciences, de la Technologie et de la Communication
Campus Belval, Biotech II 423
6 avenue du Swing
L-4367 Belvaux
Tel:
(+352) 46 66 44 5309
Email:
thoma...@uni.lu