Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 593

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/classes.php on line 710

Strict Standards: Redefining already defined constructor for class wpdb in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/wp-db.php on line 58

Deprecated: Assigning the return value of new by reference is deprecated in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/cache.php on line 99

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/cache.php on line 404

Deprecated: Assigning the return value of new by reference is deprecated in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/pacs/edv17/users/admin/doms/wuenschenswert.net/subs/www/wunschdenken/wp-includes/theme.php on line 576
Wunschdenken» Blogarchiv » Spring 2.0 Property Reloading

Spring 2.0 Property Reloading

Here’s an updated version of the net.wuenschenswert.spring property reloading package that works with Spring 2.0.x. The last version I posted was developed for Spring 1.2.8, and as it turns out, spring 2.0 has an incompatible change to the PropertyPlaceholderConfigurer super class. So now this code runs with spring 2.0 only. sigh.

Download!

8 Antworten zu “Spring 2.0 Property Reloading”

  1. Reloadable properties in Spring « Phill’s J2EE Blog sagt:

    [...] I was going to try and come up with a solution for this, but fortunately it seems that  <a href=”http://www.wuenschenswert.net/wunschdenken/archives/138″>someone already has</a>. I haven’t tested it yet, but it looks like it will do the job rather nicely. [...]

  2. Adrian Woodhead sagt:

    This is fantastic stuff, I’m amazed that Spring haven’t incorporated something like this into the framework, it seems like a no-brainer to me as this is something I’ve wanted for ages, and by reading their forums I am not alone. The “default values for properties” that you implemented is excellent too. Have you tried submitting this to them?

    I am using this on Spring 2.5.4 and it works a treat, thanks so much!

  3. Dave sagt:

    This is exactly what I needed. We have an application in production and needed to go through a massive change control process to fix one typo because we need to bounce the box. Now we will never need to!

    Works really well with no code changes as you say. Nice work. I have given you full credit in the code.

    Have you had any word from the Spring folks about getting this in the Spring distribution? It would be very valuable for the community

    Thanks again,
    Dave

  4. Amokrane sagt:

    Great job,
    Works perfectly for simple use cases, but you quickly hit the limits.
    In fact we’re trying to use reloadable properties in lists and maps (doesn’t work) Doesn’t work also in nested bean definitions. And maybe other cases spring namespaces for instance (haven’t tested that).

    Have you thought about those cases? Do you have some work done for it?
    Thanks,
    Amokrane

  5. Chris Gilbert sagt:

    Thanks for this code, which does just what we need.

    In Spring 3 this no longer works as it stands because the createInstance hook has been removed from PropertiesFactoryBean - instead mergeProperties is called directly. You can get it working again by updating ReloadablePropertiesFactoryBean - declare a boolean initialised flag and change the createInstance method to:

    protected Properties mergeProperties() throws IOException {
    if (!initialised) {
    initialised = true;
    // would like to uninherit from AbstractFactoryBean (but it’s final!)
    if (!isSingleton())
    throw new RuntimeException(”ReloadablePropertiesFactoryBean only works as singleton”);
    reloadableProperties = new ReloadablePropertiesImpl();
    if (preListeners != null)
    reloadableProperties.setListeners(preListeners);
    reload(true);
    return reloadableProperties;
    } else {
    return super.mergeProperties();
    }

    I am just testing this at the moment, so will let you know if I hit problems

  6. Ken Krueger sagt:

    Thanks for posting this solution. I agree with the other comments, sure would be handy to have this built into Spring itself. Sure there are lots of little issues to solve (Collections, potential inconsistent state of beans, etc.), but there is big upside too.

    I’m also in Spring 3 and I found Chris Gilbert’s comment above very helpful (thanks Chris!). But I was stumped on one part and I thought I would offer this clarification: REPLACE the ReloadablePropertiesFactoryBean.createInstance() method with Chris’s ReloadablePropertiesFactoryBean.mergeProperties() method.

    Another tip: the Task Scheduling in spring has changed quite a bit, and the entries in “dynamic.xml” are obsolete. You can simplify it with the following XML:

    …of course this presumes the task namespace is defined:

    thanks,
    K

  7. Ken Krueger sagt:

    OOoops! Can’t post XML. Let’s see if this works:

    <beans xmlns=”http://www.springframework.org/schema/beans”
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
    xmlns:task=”http://www.springframework.org/schema/task”
    xsi:schemaLocation=”
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/task
    http://www.springframework.org/schema/task/spring-task-3.0.xsd
    “>

    <!– Fire reloader every second. If no reloading needed, none will happen. –>
    <task:scheduled-tasks >
    <task:scheduled ref=”reloader” method=”run” fixed-delay=”1000″/>
    </task:scheduled-tasks>

  8. axel sagt:

    Hi, thanks for the feedback!
    I can’t tell whether I’ll find some time to incorporate your changes and update to Spring 3 any time soon, but:
    finally the code found its way to github. Do you feel like forking? Here’s the URL:
    https://github.com/axeolotl/SpringPropertiesReloaded
    I would feel honored to accept your pull request :-)
    thanks,
    Axel

Hinterlasse eine Antwort

Du musst angemeldet sein, um einen Kommentar zu schreiben.