2 Replies Latest reply on Nov 21, 2007 2:16 PM by toby451

    Accessing bean in @Filter

    toby451

      This is probably simple, but I am really stuck.

      I have a filter. I also have an application scoped
      component containing "global settings" for the
      application.

      Here's the problem: I need to retrieve a field from
      the component in the filter.

      How do I do that?

      Any ideas much appreciated!
      Tobias

        • 1. Re: Accessing bean in @Filter
          shane.bryzak

          Look at SeamFilter.init() for an example, it creates an application context.

          • 2. Re: Accessing bean in @Filter
            toby451

            Thanks for your quick response! Works fine.

            I'll post it here as well (for anyone in the same situation):

             public void init(FilterConfig config) throws ServletException {
             Lifecycle.mockApplication();
             try {
             ApplicationSettings settings = (ApplicationSettings) Component.getInstance("applicationSettings");
             foo = settings.getFoo();
             } finally {
             Lifecycle.unmockApplication();
             }
             }