Announcement Announcement Module
Collapse
No announcement yet.
IoC (DI) Newbe quetion Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Re: IoC (DI) Newbe quetion

    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?

    Comment


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

      Comment


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

        Comment


        • #5
          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, 08:33 PM.

          Comment


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

            Comment


            • #7
              Re: IoC (DI) Newbe quetion

              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.

              Comment

              Working...
              X