Announcement Announcement Module
Collapse
No announcement yet.
GenericFilterBean and init params -> bean props Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • GenericFilterBean and init params -> bean props

    I have a filter specified in the web.xml with init param as

    <init-param>
    <param-name>excludePatterns</param-name>
    <param-value>/index.jsp,/ping,/login</param-value>
    </init-param>


    In my Filter's constructor i call

    addRequiredProperty("excludePatterns");

    and have added methods:

    public void setExcludePatterns(String patterns) {
    m_excludePatterns = patterns;
    }

    public String getExcludePatterns() {
    return m_excludePatterns;
    }


    Yet, this bean setter methods are never called.

    I see that the addRequiredProperty method is called, but for some reason i can't debug into this code when launched from web logic (perhaps the debugger hasn't attached yet).

    What am i doing wrong that these bean property calls are not working?

    (The filter is working correctly otherwise)

    Using Spring 3.0.5.RELEASE

    thanks,
    dave

  • #2
    How to get init-params read thru bean properties

    In order for the bean property setters to be called for <init-param> the following built-in param needs to be defined, so that the target Filter's init method is called. (which does all the bean reflection).

    <init-param>
    <param-name>targetFilterLifecycle</param-name>
    <param-value>true</param-value>
    </init-param>


    This is ridiculously brain-dead on springs part. Why would i define initial parameters but not want them read.

    Anyway, any poor shlub who follows after, might find this helpful.

    Comment


    • #3
      Thanks for the post! Definitely a time saver! After reading your post, took a quick look at the source code and see why they did it that way; Spring figures that the filter configuration should all be done via bean definition, and not via the web-xml. Interesting choice.

      But I agree - it should be smart enough to see that if there are params defined that it reads them.

      Tx again!

      Eric

      Comment

      Working...
      X