Apr 13th, 2007, 02:50 AM
Examples of viable <import ..../> tag usage ?
I am trying to manage my spring project configuration and utilizing the <import ../> tag feels like a good way to do that.
But it appears to _ONLY_ accept relative paths (even if a leading "/" character exists in the file reference).
It appears to prepend the current working directory to the front of the path it tries to open and then ask the class loader resource manager for it. In the case of configuring something from /WEB-INF/springtest-servlet.xml this means that:
Becomes an error for java.io.FileNotFoundException on "/WEB-INF/foobar.xml". From what I can see both of these things together are fatally wrong.
So what is the visable <import/> tag usage ?
What would others people think to making this feature more useful with an enchancement proposal to:
* use relative paths (as now) when there is no leading slash in the given path to use.
* use absolute paths when a leading slash is given in the path to use.
* keep <import resource=""/> for loading from the classloader.
* allow other forms like <import file="path/filename.xml"/> this would attempt to load the file from the current working directory (relating to where the config file that contains the <import../> is).
* allow other forms like <import file="/path/filename.xml"/> this would attempt to load the file from the root directory of the web-app.
Can any one point me to the documentation covering the <import/> tag ? Unfortunately a search on "spring import" yeilds too much noise also the spring manual is not available to be loaded as one huge HTML page to allow me to use the search facility within my browser. The search on the spring websites is a "news / press release search" not a "documentation search" .
Last edited by dlmiles; Apr 13th, 2007 at 03:01 AM.
Apr 13th, 2007, 02:56 AM
Yes. See here.
Originally Posted by dlmiles
Hope that helps,
Apr 13th, 2007, 03:00 AM
Apr 13th, 2007, 03:14 AM
Thanks for the prompt reply, the documentation confirms I'm not missing any trick to ease my configuration woes I'll leave this thread for others to contribute over the good and bad points of <import/> tag and start another to gather ideas on how to achieve what I want to achieve.
Last edited by dlmiles; Apr 13th, 2007 at 05:40 AM.
Apr 13th, 2007, 07:02 AM
IMHO, I don't really like the import tag. I prefer to load the list the configuration files I want to load, when I want to load them. Therefore I split them up and then name them when all when constructing the ApplicationContext.
Apr 13th, 2007, 08:15 AM
AH HA! This works for me.
Now I just need to lookup in the documentation on exactly what specification can be used in the resource attribute value. The documentation for the <import/> tag doesn't lend itself to finding out this little nugget. Its a good job I am a persistant bugger!