Results 1 to 3 of 3

Thread: List Question

  1. #1
    Join Date
    Dec 2008
    Posts
    22

    Default List Question

    Given 2 classes -
    Object A, Object B

    How do you inject object B which happens to return a list into Object A so that Object A can use this list readily without having to worry about creating this list.

    Object B is return a list, that is needed by Object A. How to do this. I am not talking about hard coding this list into spring.xml i.e using <list></list>
    This list is coming from database that will be used by Object A.

  2. #2
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    242

    Default

    Hi,

    Object B is return a list, that is needed by Object A. How to do this. I am not talking about hard coding this list into spring.xml i.e using <list></list>
    This list is coming from database that will be used by Object A.
    you could try the following,

    Object A wants to use the list that is provided by Object B,

    Inject Object B into Object A from the constructor and use the list of Object B.


    now Object B wants to prepare the list from the DB,

    you could write a DAO if you want layered design, this dao does the job of reading from the DB and returning a list.

    inject the DAO into the object B and call the DAO's method in the object B's method.

    you could also use the init method provided by the spring framework that you can provide in the object B and object A to use to achieve this functionality.
    Sami

  3. #3
    Join Date
    Dec 2008
    Posts
    22

    Default

    Thanks Sami...I'll give it a whirl.

Posting Permissions

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