Announcement Announcement Module
Collapse
No announcement yet.
Are constructor/setter arguments initialized beans? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          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

          Comment

          Working...
          X