Announcement Announcement Module
Collapse
No announcement yet.
How ApplicationContextAware works? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How ApplicationContextAware works?

    Hi, I just want to ask how does implimentation of ApplicationContextAware works? In my application, I want to configure my beans in applicationcontext.xml to be 'request' scoped. But it seems that my current beanfactory which is ClassPathXmlApplicationContext does not support this type of bean scoping. XmlWebApplicationContext does. I read many articles about this issue and found out that my applicationcontext should be 'web-aware'. And then i came to this post - http://blog.imaginea.com/making-a-sp...context-aware/ . My question is, does the implimentation of ApplicationContextAware returns a XmlWebApplicationContext? Thank you for your help..

  • #2
    I think I am on the wrong forum. Can anybody help me where to post this? Thank you!

    Comment


    • #3
      First, let me tell you that you're in the right forum. The request scope is available only inside a web application context. So if you're inside a web application and using the Spring DispatcherServlet, the chances are that you may declare any of your beans in request scope. It seems that you've got a lot of confusion going through your mind regarding the context(s) implementations and listener(s) configuration. I would recommend going through the reference documentation especially the chapter on Resource(s) along with the core IoC container chapter.

      Comment


      • #4
        Thank you for your reply objectamit but I still don't get it. How can I know that I have a web application context? I guess I am not using that because I can't use 'request' for bean scoping. But when I make a class that implements ApplicationContextAware to give the application context, it worked.

        Comment


        • #5
          To use the scope request, please add the following to your web.xml

          <listener> <listener-class> org.springframework.web.context.request.RequestCon textListener </listener-class> </listener>
          For greater details, also read this

          Comment


          • #6
            I already have that in my web.xml. Still don't work unless I have a class that implements ApplicationContextAware . Now I can use request scope. I just want to know how it works. But thanks anyway!

            Comment

            Working...
            X