however, if you have an expensive-to-create dependency, you may want to share an instance among several clients. in listing 19, heromodule binds the heavywaterrefinery as a singleton
但是,如果有一个创建开销很大的依赖项,就可能需要在几台客户机之间共享实例。
instead you can define some as an object (instead of a class) and it becomes a singleton instance of the class.
相反您可以定义一个对象(而不是类)并且它将成为类的一个单例实例。
you will design the object as a singleton (this design pattern will limit this object to a single instance) and have the appropriate retrieve and store methods to manipulate the cache.
您将把对象设计为一个单子实例 (singleton)(这个设计模式将把这个对象限制在一个单个实例中)并使用合适的检索和存储方法对高速缓存进行操作。
a @session annotation can be injected into a pojo, but i see no annotation for a singleton version of a stateless session.
pojo 中可以注入 @session注释,但是我没有见到过用于无状态会话单独版本的任何注释。
an instance of the object is created on the fly and destroyed following the completion of the operation, or a singleton instance is used (and reused for each request).
对象的一个实例将被动态创建,并将在操作完成后被销毁,或者使用独立实例(并重用于每个请求)。
singleton: a singleton is active on exactly one server in the cluster at a time and processes requests from multiple clients.
独立的:一个独立的对象在一个时间内只活跃在集群中的一台服务器上,处理来自多客户端的请求。
for example, an expression could not refer to an instance field that will be computed inside the class or object body, but it could invoke a method on a singleton object.
比如说,一个表达式不能引用类或者对象主体内才被计算的实例字段,但是它可以引用一个方法或者一个单例对象。
all operations are generally backed by a singleton object instance.
所有操作通常都是由一个单独的对象实例提供支持。
only a set of identifiers is encoded in the binary string, and those identifiers are used to find the correct information via a singleton object.
二进制串中只保存了一组标识,有了这些标识,就可以通过单件对象找到真正的值。
since there is only one singleton instance, any instance fields of a singleton will occur only once per class, just like static fields.
由于只有一个单实例,单例对象的域只会在一个类中出现一次,就像静态域一样。
since it is thread safe by design, you might cache it in a public static final variable, or wrap it in a singleton pattern after creation for later access.
因为根据设计它是线程安全的,创建它之后可以把它缓存在一个公共静态最终变量中,或者包装在单实例模式中以供以后访问。
a singleton connection factory is provided to ensure that each thread in the pool is connected only once.
提供了独立连接工厂来确保池中的每个线程仅连接一次。
this is demonstrated using the exceptionhandler class, which again adopts a singleton design pattern.
使用exceptionhandler类可以展示这一点,该类也采用了singleton设计模式。
upon failure, a singleton must be restarted on the same server or migrated to a new server.
当失败的时候,独立对象必须在同一个服务器上重起或者移植到另一台服务器上。
servicelocator is a singleton class that caches the jndi.
servicelocator是一个单独(singleton)类,用于缓存jndi。