Results 1 to 3 of 3

Thread: GenericFilterBean and init params -> bean props

  1. #1
    Join Date
    Apr 2008
    Posts
    12

    Default 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. #2
    Join Date
    Apr 2008
    Posts
    12

    Default 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.

  3. #3

    Default

    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

Tags for this Thread

Posting Permissions

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