Announcement Announcement Module
Collapse
No announcement yet.
Multiple instances of ApplicationContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple instances of ApplicationContext

    I'm sure this is a faq, but I can't find a concise answer.

    Our application is providing backend services to a web application. We run in a jar that will be accessed by the webapp. If the webapp uses Spring with an ApplicationContext defined by the contextLoader in web.xml, can we still programmatically instantiate our ApplicationContext in our jar file?

    It would seem to me that we'd be running to separate Spring containers, which would be ok, because the UI doesn't need to access our Spring beans directly, and we don't need theirs.

    Thanks for any help.

  • #2
    Any thoughts, anyone??

    Comment


    • #3
      While you probably could, i think there is a better way. You should be able to just load the beans from your jar context file into your webapp application context. For example, you can load multiple bean context files into your context loader listener. It's very easy to load context files out of a jar if you use the "classpath:" prefix. In fact, this is a very powerful technique to cut down on over-sized context files.

      Code:
         <listener>
              <listener-class>
                  org.springframework.web.context.ContextLoaderListener
              </listener-class>
          </listener>
      
          <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>
                /WEB-INF/my-context.xml,
                classpath:com/mycompany/my-other-context.xml,
                classpath:com/mycompany/my-jar-context.xml
             </param-value>
          </context-param>

      Comment

      Working...
      X