Reputation: 283
Situation: I'm facing a component with old code that still uses Spring 1.2.6. The component is critical and cannot be altered. This old Spring version contains a query() method that is edited in Spring 2.x.x. In the rest of my code I want to use a more recent version of Spring (e.g. Spring 2.5.6).
Goal: I would like to specify that I this old query() method can only be used in the component, so the other code isn't bothered by this. It is possible to specifiy the classes/module where a dependency can be used?
Thanks in advance!
Upvotes: 0
Views: 36
Reputation: 140
As far as I'm aware it's not possible, since you're loading the Libraries into the same Class-Loader, so all Objects will be overloaded when the Object already exist.
For example you (or the Component) load Spring 1.2.6 so the Component can use it, and you actually try to load 2.5.6 it'd overload it, which means that the 1.2.6 get's unloaded and the 2.5.6 instead.
A way to solve this is to either load the Spring-Versions in two Class-Loaders (See this Question) or when Spring does support it (which is unusual and prob. not the case - Sorry, not familiar with Spring), is it to have different Packages for both Versions. Because they are in different Packages, the Class-Loader won't overload the Objects since they have a different "Path" (Full-Package + Object-Name + .java).
Upvotes: 1