The singleton pattern is shown in figure 5 singleton模式如图5所示。
Class an implementation of the singleton pattern, as only one instance of the 类成为单体模式的实现,因为在应用程序中只存在
We do this by applying the singleton pattern and creating a new class, commandfactory, as the singleton 既然我们已经访问了业务层,就需要建立commandfactory类。我们通过应用singleton模式,创造一个新类commandfactory。
To facilitate this, the plug-in class implements the singleton pattern : it stores a reference to itself in a private class variable 为了使这一点更方便,插件类实现单模式(singletonpattern):它在私有类变量中存储一个自身的引用。
Classes definitions can now include static members ( properties ), accessible via the class . common usage of static members is in the singleton pattern 类定义现在包含了静态成员(属性)的定义,并通过类访问它们。通常静态成员用于单独的部分。
Typical examples include a cached dao, cache of jndi references, or any sort of common factory or other component that needs to use the singleton pattern 典型的例子有:缓存的dao,jndi引用的缓存,或者任何类型的公共工厂或者其他需要使用singleton模式的组件。
Using the singleton pattern we guarantee that no matter how many times the businesslayerproxy tries to create a commandfactory, only one instance will exist 使用singleton模式,我们可以保证无论businesslayerproxy多少次尝试建立commandfactory,也只存在一个实例。
Unless the settings wrapper class is designed using the singleton pattern, there can be multiple instances of the same application settings class in a single application 除非使用单一实例模式来设计设置包装类,否则单个应用程序中可能存在同一个应用程序设置类的多个实例。
Since there can be only one un-caught handler per process active at a time, the constructor should be invoked only once; hence, the reason for the singleton pattern 因为每次只能有一个未捕获的处理程序处理一个活动进程,构造函数应该只被调用一次,因此要采用singleton模式。
The framework we ll create is a simple 3-tier framework that processes business logic using three patterns : the 3-layer architecture pattern, the singleton pattern, and the command pattern 我们将要建立的是一个简单的3-tier框架,它使用了三种模式处理业务逻辑:3-layer体系结构模式、singleton模式和command模式。