User Tools

Site Tools


osgi_component_handling_e4_events

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

====== OSGi component handling e4 Events ====== Eclipse e4 has its own event broker for handling events. Under the hood it uses the OSGi event handling components like EventHandler. ===== Receiving e4 events ===== Internally Eclipse e4 wraps every object send via the map into a Map (if it is not by itself a Map). The passed object is added to the map with the key IEventBroker.DATA which resolves to the String "data". The OSGi component needs to set the topic which it should listen to in the component definition as the property ''event.topics'' and should implement the ''EventHandler'' interface from the OSGi runtime. <sxh java> @Override public void handleEvent(Event event) { Object data = event.getProperty(IEventBroker.DATA); ... } </sxh> ===== Sending e4 events ===== To send e4 events you just need to wrap your object into a map with the key "data". <sxh java> private void postEvent(String topic, Object value) { Map<String, Object> map = new HashMap<String, Object>(); map.put(IEventBroker.DATA, value); Event event = new Event(topic, map); eventAdmin.postEvent(event); } </sxh> ===== Links ===== * [[http://www.vogella.com/articles/Eclipse4EventSystem/article.html | Eclipse Event System Tutorial]] * [[osgi_component_handling_e4_events|OSGi component handling e4 Events]] {{tag>e4}}

osgi_component_handling_e4_events.1386277468.txt.gz · Last modified: 2013/12/05 21:04 by mihael