Announcement Announcement Module
Collapse
No announcement yet.
relation between application context and context files Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • relation between application context and context files

    I am doing a Spring web application. I have two context files:
    applicationContext.xml and applicationContext-hibernate.xml.
    They are loaded into the system as follows:

    web.xml:
    ...
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/applicationContext.xml
    /WEB-INF/applicationContext-hibernate.xml
    </param-value>
    </context-param>
    ...

    After contexts are loaded and initialized, does Spring have
    two different parallel contexts, one related to each file,
    or a single context based on the two files?

    Thanks,
    Pete

  • #2
    My understanding is that normally you only have a single "context" that contains the objects defined in one or many xml configuration files. You can create a nested hierarchy of contexts by creating them individually and supplying one as a "parent" to another, but you still work with the "master" context. The reference docs contain more information on this.

    The use of multiple config files (e.g. applicationContext.xml, dataAccess-jdbc.xml, ejbContext.xml, etc.) provides a way to make configuration maintenance easier in larger projects, where beans could run into the hundreds (thousands?), and it appears the most common division is by application tier.

    HTH

    Comment


    • #3
      Thanks for your input. The reason I am asking this is related to
      the following threads:


      http://forum.springframework.org/viewtopic.php?t=4790


      http://forum.springframework.org/viewtopic.php?t=4791


      Regards, Pete

      Comment


      • #4
        Originally posted by pjydc
        Thanks for your input. The reason I am asking this is related to
        the following threads:


        http://forum.springframework.org/viewtopic.php?t=4790


        http://forum.springframework.org/viewtopic.php?t=4791


        Regards, Pete
        <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        /WEB-INF/applicationContext.xml
        /WEB-INF/applicationContext-hibernate.xml
        </param-value>
        </context-param>

        loads 2 files into one context. If something works when you declare it in one file but not in the other it's a bug.

        Comment

        Working...
        X