Results 1 to 3 of 3

Thread: How to get beans from ContextLoaderPlugIn in a Filter?

  1. #1

    Default How to get beans from ContextLoaderPlugIn in a Filter?

    Hi I'm using the ContextLoaderPlugin to hold my AppContext.. its being initialized as a struts plugin. Is there an easy way for me to get some beans from that context from a Filter?
    Thanks,
    David

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    ContextLoaderPlugin registers a WebApplicationContext into ServletContext under attribute ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX. You can use the following code to fetch WebApplicationContext from the ServletContext into your filter:
    Code:
      ServletContext sc = filterConfig.getServletContext();
      WebApplicationContext wac = (WebApplicationContext)
    				sc.getAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX);
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    In Acegi Security we use filters all over the place that require collaborators defined in the application context. We also need to check they're wired up correctly. You might like to check the net.sf.acegisecurity.util.FilterToBeanProxy class, which lets you filter actually live within the application context. It's a general-purpose class (used by other people as well) which I think would be a good addition to Spring Core.

Similar Threads

  1. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  2. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  3. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  4. DefaultAdvisorAutoProxyCreator skipping beans
    By youngm in forum Container
    Replies: 6
    Last Post: Apr 12th, 2005, 04:29 PM
  5. Replies: 5
    Last Post: Mar 18th, 2005, 04:01 AM

Posting Permissions

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