Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] OSGi 4.3 contract breach?

On 7/1/2011 5:28 AM, Wim Jongman wrote:
Hi,

I think many use this pattern:

Properties properties = new Properties();
context.registerService(
IGravityEventHandler.class.getName(),
new LoggingGravityEventHandler(), properties);

However, since my upgrade to 3.7 I get an error. Apparently the interface to the registerservice method has been changed:

from

registerService(java.lang.String clazz, java.lang.Object service, java.util.Dictionary properties) 

to

registerService(java.lang.Class<S> clazz, S service, java.util.Dictionary<java.lang.String,?> properties) 

Quite annoying right?

Yes, it is annoying, but it's the result of a change in the Equinox implementation's move to support OSGi 4.3...which uses generics in OSGi core API (as the second signature for bundleContext.registerService describes above).

Of course this isn't specific to ECF at all...it's rather the implied by OSGi 4.3 and the fact that Equinox 3.7 supports it.

FWIW, in the ECF code the easiest way to get around this is to change the registerService call to cast the Properties instance like this:

Properties properties = new Properties();
context.registerService(
IGravityEventHandler.class.getName(),
new LoggingGravityEventHandler(), (Dictionary) properties);

The (Dictionary) cast satisfies the compiler.

Scott



Back to the top