Results 1 to 3 of 3

Thread: Configure a bean after creation

  1. #1
    Join Date
    Aug 2004
    Location
    Tucson, AZ
    Posts
    2

    Default Configure a bean after creation

    Hello Springers,

    I'm investigating whether I can use Spring to configure a bean after its creation. I'm using Tapestry, and the creation of my Page object is controlled by the framework. I'd like to be able to add a call to something like:

    beanFactory.populate(thisPage, idOfPageInFactory);

    during the pageBeginRender callback method. Then I'd like to "deconfigure" it during the pageEndRender method.

    I found something similar,
    AutowireCapableBeanFactory.autowireBeanProperties( )

    which is exactly what I want (I think). However, it only allows autowiring, not explicit wiring.

    Is this possible? If it isn't, is that because it's a bad idea? Would this be a good feature request?

    Cheers,
    Nick
    Nicholas Lesiecki

    Books:
    * Mastering AspectJ: http://tinyurl.com/66vf
    * Java Tools for Extreme Programming: http://tinyurl.com/66vt
    Articles on AspectJ:
    * http://tinyurl.com/66vu and http://tinyurl.com/66vv

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Nick,

    There's nothing that will work to populate an existing instance, but not use autowiring.

    The existing autowire method (of an existing bean) is easy to handle since by definition there is no bean definition required.

    Your use case, which I can't really recall having been requested by anybody, sounds fairly useful, and is not incredibly hard to do either, but the call would obviously have to provide some indication to the container as to which bean definition to use (which could be implicit if there is only one def for a class of that type). It's really just a version of the existing getBean() method, with the bean construction pre-handled. Implicit in this is I think the assumption that the bean is a prototype as far as the Spring container is concerned, i.e. it does not try to manage its lifecylce as it would for non-prototoype beans.

    The best thing to do is probably to file a feature request in JIRA. I don't think that Juergen, Rod or I would have a problem adding this for the 1.2 timeframe.

    Regards,
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  3. #3
    Join Date
    Aug 2004
    Location
    Tucson, AZ
    Posts
    2

    Default

    Thanks Colin for the prompt reply:

    http://opensource.atlassian.com/proj...browse/SPR-266

    Cheers,
    Nick
    Nicholas Lesiecki

    Books:
    * Mastering AspectJ: http://tinyurl.com/66vf
    * Java Tools for Extreme Programming: http://tinyurl.com/66vt
    Articles on AspectJ:
    * http://tinyurl.com/66vu and http://tinyurl.com/66vv

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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