Skip to main content



      Home
Home » Eclipse Projects » Gemini » Gemini Blueprint OSGi empty service list with listener(invoked custom unbind method with null service reference)
Gemini Blueprint OSGi empty service list with listener [message #1008451] Tue, 12 February 2013 09:46
Eclipse UserFriend
Hi all,
My bundle declares an OSGi list, with a listener as follows
<osgi:list id="serviceList" cardinality="0..N" interface="com.foo.bar.MyService">
    <osgi:listener ref="listener" 
      bind-method="registerService"
      unbind-method="unregisterService" />
  </osgi:list>

When this bundle is started with no existing instance of service of type com.foo.bar.MyService, the method unregisterService is called on my listener with null value for the service.

I have checked at gemini blueprint source code, and I have found that OsgiServiceCollection is calling listeners with null service reference in afterPropertiesSet method :
	public void afterPropertiesSet() {
		// create service proxies collection
		this.services = createInternalDynamicStorage();

		dependency = new DefaultOsgiServiceDependency(sourceName, filter, serviceRequiredAtStartup);

		if (log.isTraceEnabled())
			log.trace("Adding osgi listener for services matching [" + filter + "]");
		OsgiListenerUtils.addServiceListener(context, listener, filter);

		synchronized (lock) {
			if (services.isEmpty()) {
				OsgiServiceBindingUtils.callListenersUnbind(null, null, listeners);
			}
		}
	}


I don't understand why this is done this way.
My problem is that in my bind and unbind method start with Preconditions on the service reference which should not be null... What is a listener supposed to do when unbinding a null reference?

Any help will be appreciated.
Best Regards.
Previous Topic:Gemini DBAccess Maven Artifacts
Next Topic:Gemini Blueprint 2.0.0.M01
Goto Forum:
  


Current Time: Fri May 23 01:49:56 EDT 2025

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

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

Back to the top