Dependency Injection and AOP Brief (iv)--Introduction to the "Hollywood principles" and the dependency injection framework.

Source: Internet
Author: User
Tags gmail mail jboss

3.2. "Hollywood Principles"

Looking at the previous description of the dependency injection concept, we refine the core idea of dependency injection. If the traditional coupling between components, such as new, Factory mode, is a developer's initiative to build dependent objects, then the dependency injection mode is its reverse, that is, passively waiting for someone else to do a dependent object to provide to me.

In Hollywood, many movie factories in the United States often follow the principle of looking for actors: Don't look for me, I'll find you when I need to ("Don ' tcall us; We ' ll call you! " , applying the same ideas to our software engineering is often referred to as the "Hollywood Principle" (hollywoodprinciple), which tells developers not to take the initiative to build dependent objects, but rather to provide the objects by dependency injection containers when needed.

This idea is just the opposite of the previous new, factory-created ideas, so the idea at the very beginning would be called the "inversion of Control (IoC)". From this we can also see that the core idea of dependency injection is that the container provides the dependent objects that we need.

3.3. Introduction to the Dependency Injection framework

In this section we will briefly describe the dependency injection frameworks in the Java world, including the JBoss Seam, Spring framework, Google Guice, etc. that we have mentioned several times in section 3.1.

Since the idea of dependency injection has become popular, many kinds of dependency injection frameworks have been created in the Java world. Among them, Apacheavalon is considered to be the earliest emergence of the dependency injection framework, many of the Apache project is based on this framework, but because of its more limited function, now has gradually withdrawn from the historical stage. Since then, a number of dependency injection frameworks, such as Picocontainer, Nanocontainer, Apachehivemind, and so on, have been created, such as SMARTYPANTS-IOC, specifically for Adobe A dependency injection framework for flex and Flash application development.

But dependency injection is just a development idea in object-oriented language, which is the core of improving component coupling, and developing a complete IT system involves many areas of development, such as presentation layer development, Logic layer development, persistence layer development, etc. Therefore, the developer urgently needs a framework of covering the whole development area (Full-stack) based on the thought of dependency injection. The advent of the spring framework in 2003 proclaimed that the Full-stack development framework based on the idea of dependency injection began to dominate the mainstream.

Spring is undoubtedly a successful example of a dependency injection framework covering all areas of development, even when it was first invented as a synonym for dependency injection, and is still the most widely used and most community-based framework. However, with its complex XML configuration, the complexity of object lifecycle management, and the strong reliance on the framework during the development of the spring plug-in, the development team, which was the core of the famous Java engineer, founder of Hibernate, Gaving King, developed JBoss in 2005. Seam framework, which is also rapidly evolving into one of the mainstream dependency injection development frameworks. In 2007, Google's famous Java engineer, Bob Lee, developed a new dependency injection development framework based on JAVA5 annotations and Java EDSL configuration Google Guice, which addresses the most common type safety issues in the previous framework, There is also a place in today's dependency injection framework world. The familiar front-end service of the Gmail Mail system is a system developed entirely on the basis of Guice.

In recent years, with Spring, Seam, guice the three mainstream development framework of the competition and development, their respective, in their latest version of the release of many of the main features of the design patterns and use of the way has gradually converged. Therefore, JCP organization extracted the advantages of the parties, proposed the JSR-299 and JSR-330 two new standards, formally will be injected into the JavaEE6 standard, namely Contextualand Dependency injection. All future middleware vendors claiming to implement JAVAEE6 are expected to follow this standard to provide dependency injection implementations.

Dependency Injection and AOP Brief (iv)--Introduction to the "Hollywood principles" and the dependency injection framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.