Results 1 to 5 of 5

Thread: Are constructor/setter arguments initialized beans?

  1. #1
    Join Date
    Aug 2005
    Location
    Hungary
    Posts
    16

    Default Are constructor/setter arguments initialized beans?

    Is it guaranteed that when the Spring container calls the property setters or the constructor, then the objects passed in as arguments are already initialized? For example, if I have setFoo(Bar foo), then can setFoo be sure that foo is an initialized object, i.e. its afterPropertiesSet or custom init-method was already called? (The documentation only says that "the dependency is properly initialized before the dependent bean".)

  2. #2
    Join Date
    Oct 2004
    Location
    Fareham, England
    Posts
    313

    Default

    I can absolutely, 100% satisfaction guaranteed, indubitably confirm that the answer to your question is in the affirmative.

    Evidently, replies have to be at least 10 characters in length; I originally just typed 'Yes'

    Cheers
    Rick

  3. #3
    Join Date
    Aug 2005
    Location
    Hungary
    Posts
    16

    Default

    Thanks for the answer, I believe it to you without further proofs, still, I would like to ask if this rule is documented somewhere, or even is a consequence of anything in the documenation? If it isn't, it definitelly should be documented.

  4. #4
    Join Date
    Dec 2005
    Posts
    269

    Default

    Nice answer Rick !
    Daniel, if you read the ref-doc carefully, then you would find an answer somewhere in the beginning of the chapter 3

  5. #5
    Join Date
    Oct 2004
    Location
    Fareham, England
    Posts
    313

    Default

    Hi

    I have added an additional paragraph to the reference documentation (Chapter 3, in the section entitled 'Setting bean properties and collaborators') that clarifies the issue.

    Said update will be included in the next release; thanks for spotting this.

    Cheers
    Rick

Posting Permissions

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