http://martinfowler.com/articles/injection.html
1.
Components and Services
I use component to mean a glob of software that's intended to be used, without change, by application that is out of the control of the writers of the component. By 'without change' I mean that the using application doesn't change the source code of the components, although they may alter the component's behavior by extending it in ways allowed by the component writers.
A service is similar to a component in that it's used by foreign applications. The main difference is that I expect a component to be used locally (think jar file, assembly, dll, or a source import). A service will be used remotely through some remote interface, either synchronous or asynchronous (eg web service, messaging system, RPC, or socket.)
2.Beans are defined to be deployed in one of two modes: singleton or non-singleton. (The latter is also called a
prototype, although the term is used loosely as it doesn't quite fit). When a bean is a singleton, only one shared
instance of the bean will be managed and all requests for beans with an id or ids matching that bean definition
will result in that one specific bean instance being returned.
The non-singleton, prototype mode of a bean deployment results in the creation of a new bean instance every
time a request for that specific bean is done. This is ideal for situations where for example each user needs an
independent user object or something similar.
Beans are deployed in singleton mode by default, unless you specify otherwise.
本文探讨了软件组件和服务的概念,区分了两者的使用场景:组件通常在本地应用中使用且不允许源代码更改;而服务则通过远程接口供外部调用。此外还介绍了Bean的部署模式,包括默认的Singleton模式和Prototype模式。
5678

被折叠的 条评论
为什么被折叠?



