You seem to be implementing the work that the framework already does for
ServiceFactory registrations.  The framework will only call your factory
once as long as the use count of the service is greater than zero for a
particular bundle.  The framework will then cache that service instance and
keep returning it directly to the bundle without calling the ServiceFactory
again.

Am I understanding your observation correctly?  You are stating that your
factory is not called multiple times for the same consuming bundle?

Tom





From:   Raymond Auge <[email protected]>
To:     Equinox development mailing list <[email protected]>
Date:   04/28/2014 03:24 PM
Subject:        [equinox-dev] bug or not
Sent by:        [email protected]



Hey all,

I have to write code as follows in a ServiceFactory impl in order for my
factory to always return the same instance per bundle running on
equinox 3.8.0.v20120529-1548

===============================================
public HttpService getService(
Bundle bundle, ServiceRegistration<HttpService> registration) {

HttpServiceImpl httpServiceImpl = serviceMap.get(bundle);

if (httpServiceImpl != null) {
return httpServiceImpl;
}

httpServiceImpl = new HttpServiceImpl(
bundle, contextController, legacyServiceIdGenerator);

serviceMap.putIfAbsent(bundle, httpServiceImpl);

return httpServiceImpl;
}
===============================================

This seems clearly wrong as per the spec.

It's certainly calling the getService method of the ServiceFactory which
I'm guessing means it's not incorrectly registered.

What could I be doing wrong? Was this ever a bug in equinox that was later
resolved?

--
Raymond Augé (@rotty3000)
Senior Software Architect
Liferay, Inc. (@Liferay)
_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Reply via email to