Multiple OSGI Service instance [message #733762] |
Wed, 05 October 2011 11:09  |
Eclipse User |
|
|
|
Hi,
In VIRGO, I have a bundle which is performing some big and long tasks. All the possible tasks are defined via an Interface and the implementor is defined as an OSGI service. This service is now deployed on VIRGO.
The clients are an Eclipse RCP application and communicate to VIRGO via the Spring HttpInvoker feature.
I have a web bundle which accept the request from the Spring Http Invoker and to process the request, just redirect it to the OSGI service. For now, when more than one client is trying to perform the big task, I have a concurrency problem. What I would like is that each user session gets its own instance of the OSGI service.
Is there a way to get a different OSGI service for each user web session or this is out of the definition of an OSGI service?
Presently, we could defined a different OSGI service instance by specifying the scope="bundle" in the bean definition, but the service would be different for each client bundle! In my case, I have only one web client bundle which means the same service.
I'm trying to see if I could do something with VIRGO and Spring without having to code any pooling mechanism inside my service.
I'm still not too sure if versus using an OSGI service, I should just export the class that was providing the service, and then the web bundle will create itself a new instance of the service on demand?
Of course, the way my service is presently written and when I deployed it within my FAT eclipse RCP application, then the OSGI service is working as expected!
Thanks a lot if you have any comments or suggestions!
Benoit
|
|
|
|
|
|
Re: Multiple OSGI Service instance [message #734041 is a reply to message #733810] |
Thu, 06 October 2011 09:37  |
Eclipse User |
|
|
|
blaflec wrote on Wed, 05 October 2011 13:23
I have checked the ServiceFactory, but this is creating a new service per bundle callers.
Actually ServiceFactory will create/returned cached instance (based on your implementation of ServiceFactory) per bundleContext.getService() call. If you don't mind doing some manual service management and bypass SpringDM.
In you are using Spring web support - you might be able to use Spring request/session scope to create prototypes that are a bit longer lived than one call.
|
|
|
Powered by
FUDForum. Page generated in 0.04348 seconds