Results 1 to 6 of 6

Thread: How ApplicationContextAware works?

  1. #1
    Join Date
    Dec 2012
    Posts
    11

    Default 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. #2
    Join Date
    Dec 2012
    Posts
    11

    Default

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

  3. #3
    Join Date
    Dec 2009
    Location
    India
    Posts
    108

    Default

    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.

  4. #4
    Join Date
    Dec 2012
    Posts
    11

    Default

    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.

  5. #5
    Join Date
    Dec 2009
    Location
    India
    Posts
    108

    Default

    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

  6. #6
    Join Date
    Dec 2012
    Posts
    11

    Default

    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!

Posting Permissions

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