Results 1 to 6 of 6

Thread: Examples of viable <import ..../> tag usage ?

  1. #1
    Join Date
    Aug 2006
    Posts
    113

    Default 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:

    <import resource="/foobar.xml"/>

    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.

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by dlmiles View Post
    Can any one point me to the documentation covering the <import/> tag ?
    Yes. See here.

    Hope that helps,
    Andreas

  3. #3
    Join Date
    Mar 2007
    Posts
    515

  4. #4
    Join Date
    Aug 2006
    Posts
    113

    Default

    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.

  5. #5
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    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.

  6. #6
    Join Date
    Aug 2006
    Posts
    113

    Default

    AH HA! This works for me.

    <import resource="classpath:/com/myenterprise/dao.xml"/>

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •