Skip to main content


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 12:44 Go to next message
Wok Show is currently offline Wok ShowFriend
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 13:03 Go to previous message
John Steele is currently offline John SteeleFriend
Messages: 50
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 13:02 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
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:what's the mean of class parameter in handle
Next Topic:Dragging Editor Disposes it
Goto Forum:
  


Current Time: Fri Apr 19 23:05:07 GMT 2024

Powered by FUDForum. Page generated in 0.03053 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top