2010年12月16日木曜日

5.2.5 サービスプロパティー (Service Properties)

プロパティーは (キー, 値) の組として情報を保持する. キーは String オブジェクトでなければならず, 値は Filter オブジェクトが認識できる型 (133 ページの「フィルター」を参照のこと) とすべきである. 同一のキーに対する複数の値は, 配列 ([]) および Collection オブジェクトによりサポートされる.

Properties hold information as key/value pairs. The key must be a String object and the value should be a type recognized by Filter objects (see Filters on page 133 for a list). Multiple values for the same key are supported with arrays ([]) and Collection objects.

バンドル間に不要な依存関係を生じさせないよう, プロパティーの値は, プリミティブもしくは Java の標準の型に限定すべきである. フレームワークは, サービスプロパティーを介してバンドル間でやりとりされるオブジェクトによって生成される依存関係を検出することはできない.

The values of properties should be limited to primitive or standard Java types to prevent unwanted inter bundle dependencies. The Framework cannot detect dependencies that are created by the exchange of objects between bundles via the service properties.

プロパティーのキーは大文字小文字を区別しない. ObjectClass, OBJECTCLASS, objectclass は全て同じプロパティーキーである. フレームワークが ServiceReference.getPropertyKeys で返すキーは, 大文字小文字の別において, 最後に設定されたものと正確に一致しなければならない. Dictionary オブジェクトが, 大文字小文字の違いしかないキーを含んでいた場合, フレームワークは例外を上げなければならない.

The key of a property is not case sensitive. ObjectClass, OBJECTCLASS and objectclass all are the same property key. A Framework must return the key in ServiceReference.getPropertyKeys in exactly the same case as it was last set. When a Dictionary object that contains keys that only differ in case is passed, the Framework must raise an exception.

サービスプロパティーの目的は, サービスオブジェクトに関する情報を提供することである. プロパティーは, サービスの実際の機能に関与する形で使用されるべきではない. サービス登録後のプロパティー変更は潜在的に高価な操作となる. 例えばフレームワークは, 後からおこなう検索のスピードを上げるため, 登録処理中にプロパティーを前処理してインデックス化するかもしれない.

The service properties are intended to provide information about the service object. The properties should not be used to participate in the actual function of the service. Modifying the properties for the service registration is a potentially expensive operation. For example, a Framework may pre-process the properties into an index during registration to speed up later lookups.

Filter インターフェースは複雑なフィルタリングをサポートし, 適合するサービスオブジェクトを探し出すために使用することができる. そのため, 全てのプロパティーはフレームワークサービスレジストリー内の単一の名前空間を共有している. この結果, 衝突を避けるため, 説明的名称や公式に定義された簡潔名称を使用することが重要となる. 幾つかの OSGi 仕様でこの名前空間の一部を予約している. service. で始まる全てのプロパティーおよび objectClass は, OSGi 仕様により予約されている.

The Filter interface supports complex filtering; it can be used to find matching service objects. Therefore, all properties share a single name space in the Framework service registry. As a result, it is important to use descriptive names or formal definitions of shorter names to prevent conflicts. Several OSGi specifications reserve parts of this name space. All properties starting with the prefix service. and the property objectClass are reserved for use by OSGi specifications.

「表 5.2 標準サービスプロパティー (+ はスカラー, 配列, もしくはコレクション, を示す)」は, 事前定義されたプロパティーのリストである.

Table 5.2 Standard Service Properties (+ indicates scalar, array of, or collection of) contains a list of pre-defined properties.

[表 5.2 標準サービスプロパティー (+ はスカラー, 配列, もしくはコレクション, を示す)]

[Table 5.2 Standard Service Properties (+ indicates scalar, array of, or collection of)]

プロパティーキー = objectClass
= String[]
定数 = OBJECTCLASS
プロパティーの説明 =
objectClass プロパティーは, サービスオブジェクトがフレームワークに登録された際のインターフェース名のセットを含んでいる. フレームワークはこのプロパティーを自動的に設定しなければならない. フレームワークは, サービスオブジェクトが BundleContext.getService(ServiceReference) で取り出されたときに, そのオブジェクトが当該インターフェース名のいずれにもキャスト可能であることを保証しなければならない.

Property Key = objectClass
Type = String[]
Constant = OBJECTCLASS
Property Description =
The objectClass property contains the set of interface names under which a service object is registered with the Framework. The Framework must set this property automatically. The Framework must guarantee that when a service object is retrieved with BundleContext.getService(ServiceReference), it can be cast to any of the interface names.

プロパティーキー = service.description
= String
定数 = SERVICE_DESCRIPTION
プロパティーの説明 =
service.description プロパティーは, ドキュメントとして使用されることを意図しており, 設定は任意である. フレームワークとバンドルは, 登録されたサービスオブジェクトの概要説明を提供するためにこのプロパティーを使用することができる. ローカリゼーションはサポートされないので, 主な使用目的はデバッグ支援にある.

Property Key = service.description
Type = String
Constant = SERVICE_DESCRIPTION
Property Description =
The service.description property is intended to be used as documentation and is optional. Frameworks and bundles can use this property to provide a short description of a registered service object. The purpose is mainly for debugging because there is no support for localization.

プロパティーキー = service.id
= Long
定数 = SERVICE_ID
プロパティーの説明 =
登録されたサービスオブジェクトには, フレームワークにより一意な service.id が割り当てられる. この番号はサービスオブジェクトのプロパティーに追加される. フレームワークは, それまでに登録された全てのサービスオブジェクトに割り当てられたどの値よりも大きく, 一意な値を, 登録されたサービスオブジェクトに割り当てる.

Property Key = service.id
Type = Long
Constant = SERVICE_ID
Property Description =
Every registered service object is assigned a unique service.id by the Framework. This number is added to the service object's properties. The Framework assigns a unique value to every registered service object that is larger than values provided to all previously registered service objects.

プロパティーキー = service.pid
= String+
定数 = SERVICE_PID
プロパティーの説明 =
service.pid プロパティーは, サービスオブジェクトの永続的で一意な識別子を任意識別する. 129 ページの「永続識別子」を参照のこと.

Property Key = service.pid
Type = String+
Constant = SERVICE_PID
Property Description =
The service.pid property optionally identifies a persistent, unique identifier for the service object. See Persistent Identifier (PID) on page 129.

プロパティーキー = service.ranking
= Integer
定数 = SERVICE_RANKING
プロパティーの説明 =
サービスオブジェクトを登録するとき, バンドルは, そのサービスオブジェクトのプロパティーの一つとして, service.ranking 番号を任意で指定してもよい. 条件を満たすサービスインターフェースが複数存在するとき, フレームワークがどのサービスオブジェクトを返すかを決定するのは, 最も高い SERVICE_RANKING 番号を持つサービス (番号が等しいときはそれらの中で最も低い SERVICE_ID を持つサービス) である.

Property Key = service.ranking
Type = Integer
Constant = SERVICE_RANKING
Property Description =
When registering a service object, a bundle may optionally specify a service.ranking number as one of the service object's properties. If multiple qualifying service interfaces exist, a service with the highest SERVICE_RANKING number, or when equal to the lowest SERVICE_ID, determines which service object is returned by the Framework.

プロパティーキー = service.vendor
= String
定数 = SERVICE_VENDOR
プロパティーの説明 =
この任意指定のプロパティーは, ベンダーを示すためにサービスオブジェクトを登録するバンドルが使用することができる.

Property Key = service.vendor
Type = String
Constant = SERVICE_VENDOR
Property Description =
This optional property can be used by the bundle registering the service object to indicate the vendor.