ivaynberg / salve

Automatically exported from code.google.com/p/salve
0 stars 0 forks source link

Problems in injection when multiple copies of an application context loaded on a signle vm. #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
DependecyLibrary class is static.
If we have multiple copies of, say spring application context, there will be 
unpredictable behaviors.

In our case, we have multiple web applications from the same source code, each 
one connecting to a distinct database, running on the same vm. With the current 
release of salve, one web application may use the connections of the other web 
application, because of incorrect injections.

To fix the problem for now, I modify the DependencyLibrary to get the current 
application context from a ThreadLocal which was set previously. And the locate 
method use this application context to find the required bean.

Original issue reported on code.google.com by mosta...@gmail.com on 16 Jun 2010 at 6:00

GoogleCodeExporter commented 9 years ago
the proper way to fix it would be to create your own SalveConfigurator and 
SpringBeanLocator, and use those instead of the default ones. that way you can 
neatly wrap your threadlocal lookup inside those.

Original comment by igor.vay...@gmail.com on 16 Jun 2010 at 6:10

GoogleCodeExporter commented 9 years ago
I test your suggestion.
The problem now is in the cache of DependencyLibrary.
We have a thread pool, which provide all the required threads for all web 
applications.
So one thread may be used among multiple web applications.
Whenever a bean is set in the cache of a thread, it may be used wrongly for 
other web applications later.

Original comment by mosta...@gmail.com on 16 Jun 2010 at 7:35

GoogleCodeExporter commented 9 years ago
you can set your own cache impl on the DependencyLibrary iirc..

Original comment by igor.vay...@gmail.com on 16 Jun 2010 at 4:02