Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:46
Lorie Pisicchio is currently offline Lorie PisicchioFriend
Messages: 44
Registered: October 2010
Member
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: Sat Nov 09 02:28:47 GMT 2024

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

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

Back to the top