Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » RCP EventBus?(Using EventBus in RCP 3.x?)
RCP EventBus? [message #1005970] Tue, 29 January 2013 07:44 Go to next message
Wok Show is currently offline Wok Show
Messages: 40
Registered: July 2009
Member
Hello everybody,

I implement a RCP in Eclipse Indigo und want to reuse the EventAdmin of Eclipse Juno RCP. Are there any possibilities to do this? If yes, what should I do or importing?

Thanks!

Greez d.chau

Re: RCP EventBus? [message #1005974 is a reply to message #1005970] Tue, 29 January 2013 08:03 Go to previous message
John Steele is currently offline John Steele
Messages: 49
Registered: January 2010
Member
Lars did an article on the e4 way: http://www.vogella.com/articles/Eclipse4EventSystem/article.html

If you're tying to do it the 3.x way you do something similar to the following:

  private void doPostEvent (String topic, Dictionary<String, Object> props) {
    Event event = new Event (topic, props);
    BundleContext ctx = FrameworkUtil.getBundle(SomeClass.class).getBundleContext();
    ServiceReference ref = ctx.getServiceReference(EventAdmin.class.getName());
    if( ref != null){
        EventAdmin admin = (EventAdmin) ctx.getService(ref);
        admin.sendEvent(event);
        ctx.ungetService(ref);
    }
  }


To register an event handler do something similar to the following:

  public void registerEventHandler(String topic, IMyEventHandler handler) {
    BundleContext ctx = FrameworkUtil.getBundle(SomeClass.class).getBundleContext();
    Dictionary<String, String> props = new Hashtable<String, String>();
    props.put(EventConstants.EVENT_TOPIC, topic);
    ServiceRegistration reg = ctx.registerService(EventHandler.class.getName(), handler, props);
  }


I don't see an incentive on bringing the old way into e4. It's way too verbose. If you're trying to bring the e4 annotation driven method into a 3.x RCP application I don't think it's possible, but I could be wrong on that. Either way, they both accomplish the same thing, internal communication.
Re: RCP EventBus? [message #1005976 is a reply to message #1005970] Tue, 29 January 2013 08:02 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5292
Registered: July 2009
Senior Member
EventAdmin is nothing specific to Juno it is part of (Equinox)-OSGi
since some releases already.

Tom

Am 29.01.13 13:44, schrieb Chau Mising name:
> Hello everybody,
>
> I implement a RCP in Eclipse Indigo und want to reuse the EventAdmin of
> Eclipse Juno RCP. Are there any possibilities to do this? If yes, what
> should I do or importing?
>
> Thanks!
>
> Greez d.chau
>
>
Previous Topic:Toggle command with state for every editor instance
Next Topic:Dragging Editor Disposes it
Goto Forum:
  


Current Time: Wed Aug 27 23:28:09 EDT 2014

Powered by FUDForum. Page generated in 0.01727 seconds