Results 1 to 5 of 5
  1. #1
    Takashy is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default Re: Injection (why/how/where)

    Hi,

    I never have worked with Injections before, but I have a task where I'm supposed to use them. The problem is that I have no idea how they work or where I should use them.. or why.

    What exactly happens when you inject something and what benefits and problems come with it? And how can I know where to actually use it?

    Right now I have DAO/Serivice and Bean classes and I have no idea where to use the injections.

    Also, I'm supposed to use Google Guice.. not sure if there is a big difference, but I thought that I should mention it.

    So could someone please enlighten me or point me into the right direction? I have checked out a bunch of examples, but none of them answer my questions. :|

    Thanks in advance! :)

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Injection (why/how/where)

    Never seen any thing about any of the topics you mention in your post. How is this a New to Java topic?

  3. #3
    Takashy is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default Re: Injection (why/how/where)

    Quote Originally Posted by Norm View Post
    Never seen any thing about any of the topics you mention in your post. How is this a New to Java topic?
    Well, I wasn't really sure where to post this and if this actually counts as Advanced Java.. :|

    Perhaps someone could move it if its in the wrong section?

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,354
    Blog Entries
    7
    Rep Power
    20

    Default Re: Injection (why/how/where)

    If you mean Dependency Injection (DI) a.k.a. Inversion of Control (IoC), it is heavily overrated imho. Instead of implementing, say, factories that deliver the implementations of interfaces, the description of what implementation of the interfaces to use is lifted from the code (into that horrible XML stuff, normally) and code is needed to deliver the implementation. No matter how you look at it, some form of factory is still needed.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Takashy is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default Re: Injection (why/how/where)

    Quote Originally Posted by JosAH View Post
    If you mean Dependency Injection (DI) a.k.a. Inversion of Control (IoC),....
    kind regards,

    Jos
    Yup.. thats the one. But whats the idea behind it? So by factories you simply mean classes that let you create a instance of a specific object? If so.. do you basically have to write just an interface and the injection uses that to build it or do you end up having to specify which interface (or implementation?) to use to create that instance?

    For example, I know that you can specify which class implements the interface with the @ImplementedBy... annotation, so do you simply specify which implementations can be creating that way? And what is the module good for? Or or do you have to build the module to specify which classes can be used? (read a little bit about something like that)

    I thought that the whole idea behind injections was to be able to inject classes into other classes without having to edit/recompile a class, or did I mix up things?

Similar Threads

  1. Replies: 0
    Last Post: 03-29-2008, 12:38 PM
  2. Replies: 0
    Last Post: 03-29-2008, 12:38 PM
  3. Replies: 0
    Last Post: 09-26-2007, 08:29 PM
  4. Replies: 0
    Last Post: 09-26-2007, 08:28 PM

Posting Permissions

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