I dont think this is possible with OSGi services in general.
As far as I know a service can have a singleton or prototype scope. Prototype means the service is instantiated once per requesting bundle.

In tx control as well as in Aries JPA the entitymanager instance is bound to a thread. So if you use the same thread you get the same EntityManager through one call.
This might suit what you need but it is only working for the EntityManager.

Christian

On 19.10.2016 10:41, cniehues wrote:
I want to ensure that changes in the database/persistence-unit that have not
been committed are only visible to the instances handling the same request.
But the EntityManager is only an example, I am looking for something like a
context singleton scope for service instances. Think about a service that
will be used multiple times that has a longer running initiation process
depending on the request content.
Is there maybe a factory I can extend?



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Best-practice-for-context-specific-service-instances-tp4048410p4048427.html
Sent from the Karaf - User mailing list archive at Nabble.com.


--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply via email to