[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] Changes to org.osgi.service.event.Event class for RC1

If you use the org.osgi.service.event package then please read on, otherwise you can discard this message.

The org.eclipse.osgi.services bundle contains a number of API packages which are maintained by the OSGi Alliance. For the 3.5 (Galileo) release we have updated these packages to the upcoming OSGi R4 V4.2 specification APIs. One of the proposed additions to the org.osgi.service.event package was the addition of the Event(String, Map) and Event(String, Hashtable) constructor. It has been decided by the OSGi expert groups that adding the Event(String, Hashtable) constructor is a bad idea and the constructor will be removed for the Equinox Galileo RC1 contribution. The constructor was introduced to try and eliminate ambiguity with the existing Event(String, Dictionary) constructor and the new Event(String, Map) constructor when using a Hashtable. Unfortunately this introduces issues outlined in bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=276119

Actions you must take:

Most clients of the previous org.osgi.service.event package used something like the following code to construct an Event object:

String topic = "my/topic";
Hashtable properties = new Hashtable();
Event event = new Event(topic, properties);

With the removal of the Event(String, Hashtable) constructor the code above will now have an ambiguity with the Event(String, Dictionary) and Event(String, Map) constructors. To compile against the latest version of the org.osgi.service.event package clients should update their code to cast the properties instance to a Dictionary:

String topic = "my/topic";
Hashtable properties = new Hashtable();
Event event = new Event(topic, (Dictionary) properties);

We recommend casting to a Dictionary instead of a Map in case you want your code to be able to run on the old version of the org.osgi.service.event package from the Ganymede release. Please let me know if you have any questions.

Tom