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
Message from discussion Custom event listeners
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
 
Scooter Morris  
View profile  
 More options Sep 11 2012, 10:57 am
From: Scooter Morris <scoo...@cgl.ucsf.edu>
Date: Tue, 11 Sep 2012 07:57:36 -0700
Local: Tues, Sep 11 2012 10:57 am
Subject: Re: [Cytoscape-discuss] Custom event listeners

Hi Omar,
     The other question is why don't you hand your custom object to the
listener in CyActivator?

    MyClass myObject = new MyClass();
    MyListenerClass listener = new MyListenerClass(myObject);
    registerService(bc, listener, NetworkAddedListener.class, new
    Properties());

That way, all of your services are in the CyActivator, which makes them
easier to find, and you can still pass around your status object.  In
your listener class, you could call methods to update your object.  
Another option is just to have MyClass implement NetworkAddedListener
and advertise that service...

Of course, you can, as Jason suggested also pass the CyServiceRegistrar
object down and register your services from there, but I don't really
see how that helps.  You still need to instantiate your object and the
CyActivator is the easiest place to do that...

-- scooter

On 09/11/2012 07:24 AM, Jason Montojo wrote:

> Hi Omar,

> You can (un)register OSGi services dynamically using a
> CyServiceRegistrar.  It's available as an OSGi service so you can
> fetch it in CyActivator.  Just hold on to a reference so you can use
> it later.

> Hope this helps,
> Jason

> On Tue, Sep 11, 2012 at 12:40 AM, Omar Wagih <omarwa...@gmail.com
> <mailto:omarwa...@gmail.com>> wrote:

>     From the 3.0 cookbook, its states that if you want to create a
>     custom event listener you do the following:

>     // Define a class, which implements a listener interface
>     public  class  MyListenerClass  implements  NetworkAddedListener  {
>     ....
>       public  void  handleEvent(NetworkAddedEvent  e){
>       // do something here
>       }
>     }
>     and

>     // Register the listener in the CyActivator class
>     registerService(bc,myListenerClass,NetworkAddedListener.class,new  Properties());

>     However, I have a custom object I would like to update when a network is added. How do I do that if my listener class has to be instantiated inside my CyActivator class..?

>     In other words, is there a way to register a listener class outside the CyActivator class?

>     Thanks,
>     Omar

>     --
>     You received this message because you are subscribed to the Google
>     Groups "cytoscape-discuss" group.
>     To view this discussion on the web visit
>     https://groups.google.com/d/msg/cytoscape-discuss/-/GktsG6btVRAJ.
>     To post to this group, send email to
>     cytoscape-discuss@googlegroups.com
>     <mailto:cytoscape-discuss@googlegroups.com>.
>     To unsubscribe from this group, send email to
>     cytoscape-discuss+unsubscribe@googlegroups.com
>     <mailto:cytoscape-discuss%2Bunsubscribe@googlegroups.com>.
>     For more options, visit this group at
>     http://groups.google.com/group/cytoscape-discuss?hl=en.

> --
> You received this message because you are subscribed to the Google
> Groups "cytoscape-discuss" group.
> To post to this group, send email to cytoscape-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> cytoscape-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cytoscape-discuss?hl=en.


 
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.