Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Unregistering listeners using CyServiceRegistrar
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Omar Wagih  
View profile  
 More options Sep 15 2012, 7:28 pm
From: Omar Wagih <omarwa...@gmail.com>
Date: Sat, 15 Sep 2012 16:28:37 -0700 (PDT)
Local: Sat, Sep 15 2012 7:28 pm
Subject: Unregistering listeners using CyServiceRegistrar

I have my custom event class which implements several listeners
The handleEvent methods of the class depends on a JTree which is created
after files are loaded through a custom JFrame. Thus, I can't register the
listeners in CyActivator.
I instantiated the class, and passed references of the class + a reference
of CyServiceRegistrar through to where my JFrame is being created.
After my files are loaded and my JTree is created, I set the JTree in my
custom event listener class like this: myListeners.setTree(myJTree) and
register the listeners.

However, I run into this issue:
In the case that someone loads JFrame file loader from the app menu to load
the the files a *second* time, the listeners are registered again and thus
my handleEvent methods are called more than once.

I tried unregistering all services when my custom file loader JFrame is
opened like this: serviceRegistrar.unregisterAllServices(myListeners);, but
it fails

Any idea what's going on?

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Montojo  
View profile  
 More options Sep 17 2012, 11:09 am
From: Jason Montojo <jrr...@gmail.com>
Date: Mon, 17 Sep 2012 11:09:42 -0400
Local: Mon, Sep 17 2012 11:09 am
Subject: Re: [Cytoscape-discuss] Unregistering listeners using CyServiceRegistrar

Hi Omar,

I usually get around that issue by reusing the JFrame instance.  For
example, your menu item could be a CyAction that lazily instantiates the
JFrame.  If the JFrame already exists, it just re-displays it.  That way,
your JFrame is created exactly once and the services are registered only
once.

Hope this helps,
Jason


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Omar Wagih  
View profile  
 More options Sep 17 2012, 2:15 pm
From: Omar Wagih <omarwa...@gmail.com>
Date: Mon, 17 Sep 2012 14:15:38 -0400
Local: Mon, Sep 17 2012 2:15 pm
Subject: Re: [Cytoscape-discuss] Unregistering listeners using CyServiceRegistrar

Hi Jason,

I dont think this will work in terms of debugging/developing my app.
Every time I rebuild my project and update my bundle in the cytoscape terminal, I want the old listeners to be removed/unregistered and the new one registered. Does this make sense?
I am constantly updating my listeners throughout the development of my app and would hate having to restart Cytoscape in order to see the effect of my new listeners without the redundancy of the old ones

Any alternatives?

Omar
On 2012-09-17, at 11:09 AM, Jason Montojo wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Montojo  
View profile  
 More options Sep 17 2012, 2:31 pm
From: Jason Montojo <jrr...@gmail.com>
Date: Mon, 17 Sep 2012 14:31:30 -0400
Local: Mon, Sep 17 2012 2:31 pm
Subject: Re: [Cytoscape-discuss] Unregistering listeners using CyServiceRegistrar

Hi Omar,

When you update your bundle, OSGi unloads the old one and loads the new one
(i.e. you end up with a new JFrame).  That causes all of the OSGi services
registered by your bundle to be forcefully unregistered.  You shouldn't
need to restart Cytoscape for your changes to take effect.  If Cytoscape is
holding onto references to your old class, then this will definitely not
work; for example, if you grab Cytoscape's JMenuBar and add things to that
directly.  However, if you're extending Cytoscape strictly using OSGi
services (e.g. CyAction, *TaskFactory), you won't run into this problem.

I use the approach I described in the GeneMANIA app and I haven't run into
instances where I've had to restart Cytoscape when updating my app.

Hope this helps,
Jason


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Omar Wagih  
View profile  
 More options Sep 18 2012, 12:24 am
From: Omar Wagih <omarwa...@gmail.com>
Date: Tue, 18 Sep 2012 00:24:18 -0400
Local: Tues, Sep 18 2012 12:24 am
Subject: Re: [Cytoscape-discuss] Unregistering listeners using CyServiceRegistrar

Hi Jason,

I took your exact same approach.
My JFrame class is instantiated in CyActivator and I have a class which extends AbstractCyAction and on actionPerformed it calls frame.setVisible(true)
This works fine.

Now, In my CyActivator class, I instantiate my listeners class and register my listeners:

myListeners = new AppListeners();
//Register listeners
registerService(bc, myListeners, NetworkViewAddedListener.class, new Properties());

My listeners class prints the following:
public void handleEvent(NetworkViewAddedEvent nvae) {
        System.out.println("Network view add: registering->"+nvae.getNetworkView().getModel().getSUID());

}

If I build my app, launch cytoscape, update and start, when my network is generated I see the output:

Network view add: registering->71

Which is great. Now, If I rebuild changing the print statement to include more arrows, update my bundle and launch my app again, on a network view added event I see

Cytoscape 3.0.0-M5> update 182
Network view add: registering->>>>71
Network view add: registering->71

Both the old and the new listeners are still there. i.e. the old listeners were not removed which causes the redundancy…

Am I missing something?

Omar
On 2012-09-17, at 2:31 PM, Jason Montojo <jrr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Omar Wagih  
View profile  
 More options Sep 18 2012, 1:42 am
From: Omar Wagih <omarwa...@gmail.com>
Date: Tue, 18 Sep 2012 01:42:37 -0400
Local: Tues, Sep 18 2012 1:42 am
Subject: Re: [Cytoscape-discuss] Unregistering listeners using CyServiceRegistrar

Nevermind, I got it to work!
Just needed one final clean of Cyoscape.
Thanks so much for all your help!! Greatly appreciated

Omar
On 2012-09-17, at 2:31 PM, Jason Montojo <jrr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »