Results 1 to 6 of 6

Thread: Loading Application context

  1. #1

    Default Loading Application context

    Hi ,
    I had a question that if I load applicationcontext.xml through struts-config.xml and then again in some part of the application I load application context again with command
    Code:
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
    						APPLICATION_CONTEXT_PATH);
    will there be two spring context in the memory or there will only one and the code will load from the same applicationContext loaded by struts-config.xml.

    Thanks ,
    Amol

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

    Default

    If you are using Spring and Struts I would have a look at this article.
    http://www-128.ibm.com/developerwork...ary/j-sr2.html

    If you've got a ServletContext instance, then you can use WebApplicationContextUtils. Otherwise there are quite a few options e.g. ApplicationContextAware, WebApplictionContextUtils, SingletonBeanFactoryLocator, ContextSingletonBeanFactoryLocator. Basically you shouldn't be creating another ApplicationContext.

  3. #3

    Default

    Hi karldmoore ,
    Actually I wanted to know that will this load two spring context in memory or will it use the same.

    Thanks
    Amol

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

    Default

    Quote Originally Posted by aamol View Post
    Actually I wanted to know that will this load two spring context in memory or will it use the same.
    Yes you will load another ApplicationContext. Hence the discussion of ways to get hold of the exist one rather than creating a new one.

  5. #5

    Default

    Thanks that answers my doubt.

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

    Default

    Quote Originally Posted by aamol View Post
    Thanks that answers my doubt.
    Not a problem, glad the information was useful. The reference manual does has some information on this if you are interested, along with details of the techniques I talked about earlier.

Posting Permissions

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