Dependency Injection = GoF Builder


http://www.martinfowler.com/articles/injection.html

Component = Software that is intended to be used, without component-source-code change, by client applications. Component and it's client are typically co-located, e.g. in same JVM or in same executable.
Service = Service and it's client are not co-located, or client accesses a remote service.

If you see
public interface Injector {
public void inject(Object target);
}
, it injects (or sets) target to act on for a component. Basically, a setter on a component that implements Injector-interface.

Tester class or Assembler (actor) is nothing but a GoF-Builder-participant-Director that knows how to construct a GoF-Builder-participant-Product (MovieLister) that has GoF-Builder-BuildPart (MovieFinder).

Can we then say that Dependency Injection is nothing but configuring a GoF-Strategy (or algorithm in general) using GoF-Builder pattern?
Or, in general, Dependency Injection is nothing but GoF-Builder?

Builder is supposed to separate the construction of complex object (data and procedures that operate on that data - a GoF-Builder-participant-Product, or MovieLister in Martin's link above) from its representation (MovieLister with certain implementation of MovieFinder in Martin's link above).


Dependency Injection (DI) is referred as specific case of the general pattern "Inversion of Control", i.e. how framework invokes call-backs from client source code. For example, how MovieLister (say part of framework source code) invokes MovieFinder (say part of client source code). Inversion is in terms of framework invoking client, rather than the most typical case of client invoking framework methods.


http://java.sun.com/developer/technicalArticles/J2EE/injection/

Java-EE 5 seems to be using such DI using Java-SE Annotations mechanism. The Java-EE 5 Web/Application Container is the Builder-Director that builds Java-EE-components like Servlets, EJBs. The Java-EE-components are the Builder-Products.

Java-EE 5 Annotations (examples at least) seem to promote hard-coding of such "dependency" names-or-identifiers, e.g.
@Resource(name="jms/demoTopic")
private javax.jms.Topic demoTopic;
Just wondering if it's possible to pass such names dynamically to the annotation!

<script type="text/javascript" language="javascript"> var sc_project=1731913; var sc_invisible=0; var sc_partition=16; var sc_security="2f7c65d8"; </script> <script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script>
Comments:

why?

Posted by SEO on June 03, 2007 at 01:58 AM IST #

花木租摆 礼仪公司 交通

Posted by 花卉租赁 on June 23, 2007 at 02:23 AM IST #

鲜花礼品 google搜索排名 鲜花礼品

Posted by 园林公司 on July 04, 2007 at 12:08 PM IST #

More informations about <a href="http://www.ajiththeactor.com"> Actor Ajith</a>

Posted by Actor Ajith on October 12, 2007 at 05:16 AM IST #

Thanks for your information, i have read it, very good!

Posted by tiffany & co Bracelet on November 13, 2009 at 04:18 AM IST #

with a elegant Chanel Watches on your wrist, you will immediately add up your current fashion quotient and help you obtain more confidence. There are different kinds of styles and designs of Replica Chanel Watches that are available in the market and you can always pick out one for any occasion. These Chanel Fake Watches would not add an excessive burden to your monthly bills since they are relatively very affordable.Chanel j12 Watch is obtaining more and more popularity in recent years. A wide range of fashionable styles and unique designs of these wonderful Chanel watch can be

Posted by chanel j12 watch on March 11, 2010 at 12:43 AM IST #

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

Posted by omega watches on March 11, 2010 at 11:25 PM IST #

A good footballer is counted from his charcter too. Many of them are very bad in controlling their emotion. That's so important for them.

Posted by billiards supplies on August 05, 2010 at 09:27 AM IST #

Tomorrow is Sarah's birthday,

Posted by thomas sabo on September 06, 2010 at 06:52 AM IST #

Tomorrow is Sarah's birthday?
I DONT THINK SO

Posted by 美文 on September 17, 2010 at 05:15 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

ajitsabnis

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today