第一课 spring的一点理论 2006-04-05
来源:互联网 发布:linux网络编程 pdf 编辑:程序博客网 时间:2024/04/28 12:01
1.
优点.
.with a couple of lines of configuration instead of embedded code
.Spring is much simpler than traditional J2EE alternatives. With Spring, you code your applications as plain old Java objects (POJOs)
2.
做法:
1. A client uses another class that we'll call a service. The client has a property that accepts a service. The service is wrapped in an interface. The client can't see the implementation of the service. But this code is not yet loosely coupled: you still have to create the service somewhere. With dependency injection, a third-party, called the assembler or container, creates both the client and service, and then sets the value of aService (which is a reference to an instance of Service) to satisfy the dependency.
2. Wrap the service in an interface(ArrayListRentABike implements RentABike 后者就是接口)
3. Add a property to the client, to refer to the service.(class CommandLineView 里面包含RentABike对象 )
4. With a third party framework or custom code, build the service and populate the property.(RentABikeAssembler,里面的main方法里面完成,creates both the client and service, and then sets the value of aService ): CommandLineView clv = new CommandLineView( );
RentABike rentaBike = new ArrayListRentABike("Bruce's Bikes");
clv.setRentaBike(rentaBike);
RentABike rentaBike = new ArrayListRentABike("Bruce's Bikes");
clv.setRentaBike(rentaBike);
3.the ideas behind the movement are simple. Program using interfaces, and let a third party inject the dependency instead of setting it yourself.You're going to eventually replace the assembler with Spring....
Of course, dependency injection is not the only way to manage dependencies. In fact, it's not the only good way. J2EE users tend to use service locators
- 第一课 spring的一点理论 2006-04-05
- 驾照培训的第一堂理论课
- Spring框架的理论
- 宇宙起源理论的一点修正谭
- Spring的一点心得
- spring(理论)
- 关于六度分割理论的一点认识
- 关于Spring的一点思索.
- spring aop的一点解析
- spring的自我一点理解:
- spring的一点小小理解
- Spring AOP的一点理解
- Spring.No1 ----整理---Spring学习的第一课
- 第一部分 数理逻辑 第三章 命题逻辑的推理理论
- JAVA Spring 第一课
- Spring Boot第一课
- 光线跟踪理论&实践 第一课——介绍
- Spring的第一个程序
- 什么是运气?
- 破解WEP密钥过程全解 (下)
- 中国博士生数量增长太快将会导致博士就业难
- 博士教育的异化
- 如何让自定义控件的属性的说明文本出现在“属性”编辑器的下方?
- 第一课 spring的一点理论 2006-04-05
- 网关和DNS的区别
- Sql server2000开发中ISNULL的实际用处
- 中国白领必然破产
- 破解WEP密钥过程全解(上)
- 天蝎座人成长的过程
- 如何使ASSERT象在VB那样直接中断
- Hooking into NDIS and TDI, part 1
- NDIS and TDI Hooking, Part II