Pool ServiceプールサービスThe Pool Service extends the functionality of the Factory Service by adding support for pooling objects intantiated from the given class name or Class object reference. Pooling of objects stabilizes memory consumption and reduces garbage collection making response times in server applications more predictable. プールサービスはクラス名やClassオブジェクトの参照からインスタンス化されたオブジェクトのプーリングのサポートを追加した、ファクトリサービスの機能を拡張したものです。 オブジェクトのプーリングはメモリの消費を安定させ、ガベージコレクションを減らし、サーバアプリケーションの応答時間を向上させることができます。 When a new instance is requested from the service, it first checks its pool if one is available. If the the pool is empty, a new object will be instantiated from the given class. If the class is specified by its name, the request to create an instance will be forwarded to the Factory Service. 新しいインスタンスがサービスから要求されるとき、まず最初にプールのインスタンスが利用かどうかをチェックします。 プールが空の場合、与えられたクラスから新しいオブジェクトをインスタンス化します。 クラスが名称として指定されている場合、インスタンス作成のリクエストはファクトリサービスへとフォワードされます。 For pooled objects implementing the Recyclable interface, a recycle method will be called, when they are taken from the pool, and a dispose method, when they are returned to the pool. Implementations of the methods should clear and initialize the pooled instances correspondingly. Objects that do not implement the interface can also be pooled, if they do not need to perform any specific actions during pooling. A RecyclableSupport class can be extended to get a minimal implementation of the interface. Recyclableインターフェースをインプリメントしているプールされたオブジェクトは、プールから取り出されるときにrycycleメソッドが呼び出され、プールに返却されるときにdisposeメソッドが呼び出されます。 これらのメソッドの実装はプールされたインスタンスに対してのクリアと初期化を行うべきです。 このインターフェースをインプリメントしていないオブジェクトもプール可能であり、それらはプールされている間に特定のアクションを実行する必要のないものです。 RecyclableSupportクラスはこのインタフェースを最小限の実装で拡張することができます。 An ArrayCtorRecyclable interface extends the Recyclable interface providing a more efficient recycle method with less reflection for recycling frequently used objects having constuctors with parameters. Recyclableインターフェースを拡張したArrayCtorRecyclableインターフェースは、引数をとるコンストラクタを持ち、頻繁に使用されるオブジェクトの再利用のための、リフレクション回数を抑える、より能率的なリサイクルメソッドを提供します。 Configuration設定# ------------------------------------------------------------------- # # S E R V I C E S # # ------------------------------------------------------------------- # Classes for Turbine Services should be defined here. # Format: services.[name].classname=[implementing class] # # To specify properties of a service use the following syntax: # service.[name].[property]=[value] # Turbineのサービスのためのクラス群はここに定義します。 # フォーマット: services.[name].classname=[implementing class] # # サービスのプロパティを設定するには、以下の書式を使用します: # service.[name].[property]=[value] services.PoolService.classname=org.apache.fulcrum.pool.TurbinePoolService . . . # ------------------------------------------------------------------- # # P O O L S E R V I C E # # ------------------------------------------------------------------- # Default capacity of pools of the Object pooling service. # # Default: 128 # オブジェクトプーリングサービスのプールのデフォルトの容量。 # # デフォルト: 128 services.PoolService.pool.capacity = 128 # Class specific capacities used instead of the default if specified. # # クラスを指定した容量(デフォルトの指定のかわりに使用されます)。 # #services.PoolService.pool.capacity.org.apache.turbine.services.rundata.DefaultTurbineRunData=512 Usage使用方法The Pool Service can be called instead of the Factory Service, when instantiating objects that are needed repeatedly e.g. for processing client requests. Intances of RunData implementations, ParameterParser and CookieParser implementations, Pull Service tools, etc, are typical examples of pooled objects. Used objects must be returned to the Pool Service for recycling. The TurbinePool class is a static accessor for common methods of the Pool Service: プールサービスはファクトリサービスのかわりとして、繰り返し必要となるオブジェクトのインスタンス化時、例えば、クライアントのリクエストの処理などで呼び出すことができます。 RunDataのインスタンスや、ParameterParserとCookieParser、プルサービスのツール等が、プールされるオブジェクトの典型的な例です。 使用済みのオブジェクトは再利用のため、プールサービスへ返却しなければなりません。 TurbinePoolクラスはプールサービスの一般的なメソッド群への静的なアクセッサです。
// Get a pooled DOM parser.
// プールされているDOMパーサを取得します。
DocumentBuilder parser =
TurbinePool.getInstance("javax.xml.parsers.DocumentBuilder");
// Parse an XML document.
// XMLドキュメントをパースします。
Document doc = parser.parse(myfile);
// Return the parser to the pool.
// パーサをプールへ返却します。
TurbinePool.putInstance(parser);
|