Results 1 to 7 of 7

Thread: IoC (DI) Newbe quetion

  1. #1

    Default IoC (DI) Newbe quetion

    Please correct me if I am wrong but if I am trying to summerise the functionlity of IoC (DI specific), then it is some clever mechanisim to pass configuration data into my newly created objects.

    If this it true what if I want to use some precreated objects to intialise my objects (What seems to me a much more general case then to create newly initialized object)

  2. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default Re: IoC (DI) Newbe quetion

    Quote Originally Posted by litterat
    Please correct me if I am wrong but if I am trying to summerise the functionlity of IoC (DI specific), then it is some clever mechanisim to pass configuration data into my newly created objects.

    If this it true what if I want to use some precreated objects to intialise my objects (What seems to me a much more general case then to create newly initialized object)
    Most of my objects are created in Spring and I don`t have to retrieve them from somewhere else. But there are ways to pull beans outside of Spring into Spring. Check the FieldRetrievingFactoryBean for example.

    What are you trying to do? What objects do you want to pull into Spring?

  3. #3
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Please correct me if I am wrong but if I am trying to summerise the functionlity of IoC (DI specific), then it is some clever mechanisim to pass configuration data into my newly created objects.
    DI-wise it's a bit more - it also allows you to define linkage between objects, not just configuration data. See http://martinfowler.com/articles/injection.html

    If this it true what if I want to use some precreated objects to intialise my objects
    But what does pre-created mean? At startup time? Spring can insert beans created at startup time into newly created objects.

  4. #4

    Default Re: IoC (DI) Newbe quetion

    What are you trying to do? What objects do you want to pull into Spring?
    I will give a simple example.
    Lets say I have a report object that print a message,
    the message is created from user input

    I see no way for Spring to help me in intaiting the message object nor the report object

    The problem is that the dependenicies of an object usually are not decided in creation time but might allready exist in the system

  5. #5
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    You can possibly use a factory method. See this thread: http://forum.springframework.org/showthread.php?t=17634
    Last edited by robyn; May 14th, 2006 at 07:33 PM.

  6. #6

    Default Re: IoC (DI) Newbe quetion

    I will give a simple example.
    Lets say I have a report object that print a message,
    the message is created from user input
    Anybody can outline to me the way you would do this in Spring

  7. #7
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default Re: IoC (DI) Newbe quetion

    Quote Originally Posted by litterat
    What are you trying to do? What objects do you want to pull into Spring?
    I will give a simple example.
    Lets say I have a report object that print a message,
    the message is created from user input

    I see no way for Spring to help me in intaiting the message object nor the report object
    Could you give a more detailed example? And remember: Spring is not responsible for creating all objects (else Spring would be a nightmare to use).

    The problem is that the dependenicies of an object usually are not decided in creation time but might allready exist in the system
    Try to make this clear in your example.

Similar Threads

  1. Replies: 3
    Last Post: Apr 29th, 2005, 06:09 AM
  2. Newbe dao question
    By Gabor Beres in forum Data
    Replies: 6
    Last Post: Jan 24th, 2005, 05:13 PM
  3. newbe questions
    By jboring in forum Swing
    Replies: 2
    Last Post: Dec 21st, 2004, 11:28 AM

Posting Permissions

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