Announcement Announcement Module
Collapse
No announcement yet.
how to reference a context from other context? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to reference a context from other context?

    Hi, I have a multitiered application and wish to create multiple application context to separate the different layers.
    How do you reference from an applicationContext.xml file in the web tier, the applicationContext.xml file in my business logic tier?
    Thanks!

  • #2
    Typically the services + persistence layer ("business tier") are located in applicationContext-xxx.xml files, with your web layer located in framework-specific files (for Spring MVC typically servlet-xxx.xml, where xxx reflects your DispatcherServlet name). Your web.xml in such an application has a directive such as follows, which loads the shared business tier application contexts:

    Code:
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath&#58;applicationContext-common.xml classpath&#58;applicationContext-security.xml classpath&#58;applicationContext-services.xml classpath&#58;applicationContext-sitemesh.xml</param-value>
    	</context-param>
    
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>

    Comment


    • #3
      The samples included in the Spring distribution are an excellent guide, and demonstrate what Ben has illustrated.

      To separate other layers, there is the import feature for the context - see the spring-beans.dtd.

      Comment


      • #4
        How does the import feature work?
        I haven't found information about how to use it.

        Comment


        • #5
          Take a look at this developer thread

          The first post pretty much explains it's usage.

          Comment

          Working...
          X