ChinaUnix.net
相关文章推荐:

Ioc模式

1引言 面向对象的思想已经深入人心,但是要利用面向对象的思想开发出优秀的应用程序却不是一件容易的事情。正是基于面向对象的思想,人们对各种应用程序进行了大量的分析、总结、归纳出了设计模式。Alexanders给出模式的经典定义是:每个模式都描述了一个在我们的环境中不断出现的问题,然后描述了该问题的解决方案的核心。通过这种方式,你可以无数次地使用那些已有的解决方案,无需再重复相同的工作[2]。设计模式技术在Go...

by 紫冰 - Java文档中心 - 2007-03-21 18:37:02 阅读(607) 回复(0)

相关讨论

[color="#0000ff"]动态服务定位器 [color="#000000"] 上面是一个静态定位器的例子——对于你所需要的每项服务,ServiceLocator类都有对应的方法。这并不是实现服务定位器的唯一方式,你也可以创建一个动态服务定位器,你可以在其中注册需要的任何服务,并在运行期决定获得哪一项服务。 在本例中,ServiceLocator使用一个map来保存服务信息,而不再是将这些信息保存在字段中。此外,ServiceLocator还提供了一个通用的方法,用于...

by arieleric - Java文档中心 - 2008-12-18 00:07:04 阅读(932) 回复(0)

[color="#0000ff"]接口注入 [color="#000000"] 除了前面两种注入技术,还可以在接口中定义需要注入的信息,并通过接口完成注入。Avalon框架就使用了类似的技术。在这里,我首先用简单的范例代码说明它的用法,后面还会有更深入的讨论。 首先,我需要定义一个接口,组件的注入将通过这个接口进行。在本例中,这个接口的用途是将一个MovieFinder实例注入继承了该接口的对象。 public interface InjectFinder { void...

by arieleric - Java文档中心 - 2008-12-17 23:52:09 阅读(1045) 回复(0)

在企业级Java 的世界里存在一个有趣的现象:有很多人投入很多精力来研究主流J2EE 技术的替代品——自然,这大多发生在open source 社群。在很大程度上,这可以看作是开发者对主流J2EE 技术的笨重和复杂作出的回应,但其中的确有很多极富创意的想法,的确提供了一些可供选择的方案。J2EE 开发者常遇到的一个问题就是如何组装不同的程序元素:如果web 控制器体系结构和数据库接口是由不同的团队所开发的,彼此几乎一无所知...

by arieleric - Java文档中心 - 2008-12-17 22:51:50 阅读(1048) 回复(0)

呵呵,在网上转载的。。。很不错的比喻。 ----------------------------------------------------------------------------- 首先想说说ioc(Inversion of Control,控制倒转)。这是spring的核心,贯穿始终。所谓ioc,对于spring框架来说,就是由spring来负责控制对象的生命周期和对象间的关系。这是什么意思呢,举个简单的例子,我们是如何找女朋友的?常见的情况是,我们到处去看哪里有长得漂亮身材又好的mm,然后打听她...

by every_best - Java文档中心 - 2008-09-30 22:48:53 阅读(972) 回复(0)

3.5. Customizing the nature of a bean3.5.1. Lifecycle interfaces The Spring Framework provides several marker interfaces to change the behavior of your bean in the container; they include InitializingBeanDisposableBean. Implementing these interfaces will result in the container calling afterPropertiesSet() for the former and destroy() and...

by jim153 - Java文档中心 - 2007-06-19 16:15:26 阅读(891) 回复(0)

3.3.4. Using depends-on For most situations, the fact that a bean is a dependency of another is expressed by the fact that one bean is set as a property of another. This is typically accomplished with the element in XML-based configuration metadata. For the relatively infrequent situations where dependencies between beans are less direct (for example, when...

by jim153 - Java文档中心 - 2007-06-19 16:14:40 阅读(700) 回复(0)

3.3. Dependencies Your typical enterprise application is not made up of a single object (or bean in the Spring parlance). Even the simplest of applications will no doubt have at least a handful of objects that work together to present what the end-user sees as a coherent application. This next section explains how you go from defining a number of bean definitions th...

by jim153 - Java文档中心 - 2007-06-19 16:13:31 阅读(633) 回复(0)

3.1. Introduction This chapter covers the Spring Framework's implementation of the Inversion of Control (ioc) [ 1 ] principle. BeanFactory or ApplicationContext? Users are sometimes unsure whether a BeanFactory or an ApplicationContext is best suited for use in a particular situation. A BeanFactory pretty much just instantiates and configures beans. An ApplicationContext also ...

by jim153 - Java文档中心 - 2007-06-19 16:12:32 阅读(609) 回复(0)

哎,看了好几天 Spring 的东东了,最开始是看朋友推荐的《精通Spring》,没太看明白,也就看了前两章,感觉里面的很多概念讲得不明白,可能是因为它是我看的第一本Spring的书吧?! 接下来下载了 夏昕的 SpringGuide.pdf ,虽然该开源书是未完成版,但里面的内容却是讲得非常的明白,当然可能与已经看过第一本一些内容有关吧;里面将ioc和AOP的东西使用实际的代码进行模拟实现,自己也照着敲了一遍,基本上对概念是了解了。 根据我...

by lvjinhua - Java文档中心 - 2009-04-04 22:38:05 阅读(1266) 回复(0)