...
Configuring Data Services
...
データ サービスの構成
データ サービスは、主として nexaweb-data.xml
...
...
また、nexaweb-sql.xml
...
nexaweb-data.xml
...
ファイルの構成
...
nexaweb-data.xml
...
Configuration Section | Description |
requestProcessorDefinitions | Defines the pre- and post-processors that you can use: globally for all services requests; per data service type; in dataRequestDefinitions. |
globalProcessors | Lists pre- and post-processors that the data service applies to all service requests of any data service type. |
dataServiceDefinitions | Defines the types of data services available through the data services plug-in. Also specifies data service type pre- and post-processors for each service request using that data service type. |
dataRequestDefinitions | Defines information on the server to obtain data from external SQL or web services type data services. |
requestProcessorDefinitions
Processors format data requests or results into the appropriate structures.
...
The requestProcessorDefinitions section includes the following elements:
Element | Description |
preProcessorDefinitions | Lists pre-processors definitions. |
postProcessorDefinitions | Lists post-processors definitions. |
Use the processorDefinition tag to define a processor in either the preProcessorDefinition or postProcessorDefinition elements.
The following table describes the processorDefinition tag attributes:
Attributes | Description |
Class | Specifies the implementing class for the processor. |
ID | Specifies an ID by which to uniquely identify the processor so that you can reference it when using it as a global or data service type-specific processor, or in a dataRequestDefinition. |
Processors use the following implementing classes:
Processor Type | Implementing Class | Description |
Pre-processors | DataRequestPreProcessor | Interface to modify data request information. The data service calls pre-processors prior to making the data service request to the associated data service. |
Post-processors | DataRequestPostProcessor | Interface to modify raw data on its way to the client. The data service calls post-processors prior to sending the data service result back to the originating client |
...
コンフィギュレーション セクション | 説明 |
requestProcessorDefinitions | すべてのサービス リクエストでグローバルに使用できる、データ サービス タイプごとに使用できる、あるいは dataRequestDefinitions で使用できるプリプロセッサおよびポストプロセッサを定義します。 |
globalProcessors | 任意のデータ サービス タイプの全サービス リクエストにデータ サービスが適用される、プリプロセッサおよびポストプロセッサを示します。 |
dataServiceDefinitions | データ サービス プラグインを通じて使用可能なデータ サービス タイプを定義します。また、そのデータ サービス タイプを使用して、サービス リクエストごとにデータ サービス タイプのプリプロセッサおよびポストプロセッサを指定します。 |
dataRequestDefinitions | 外部SQL または Web サービスタイプのデータサービスからデータを取得するための情報をサーバー上で定義します。 |
requestProcessorDefinitions
プロセッサは、データ リクエストまたはデータ結果を適切な構造にフォーマット設定します。
requestProcessorDefinitionsセクションで、グローバルプロセッサまたはデータサービスタイププロセッサとして、あるいは dataRequestDefinitions で割り当て可能なプリプロセッサおよびポストプロセッサを定義します。
requestProcessorDefinitionsセクションには次の要素が含まれています。
要素 | 説明 |
preProcessorDefinitions | プリプロセッサの定義を示します。 |
postProcessorDefinitions | ポストプロセッサの定義を示します。 |
processorDefinitionタグを使用して、preProcessorDefinition要素または postProcessorDefinition要素でプロセッサを定義します。
次の表に、processorDefinitionタグの属性についての説明を示します。
属性 | 説明 |
Class | プロセッサの実装クラスを指定します。 |
ID | プロセッサをグローバル プロセッサまたはデータ サービス タイプ固有のプロセッサとして、あるいは dataRequestDefinition で使用しているときに参照するために、プロセッサを一意に識別するための ID を指定します。 |
プロセッサでは次の実装クラスが使用されます。
プロセッサ タイプ | 実装クラス | 説明 |
プリプロセッサ | DataRequestPreProcessor | データ リクエスト情報を変更するためのインターフェイス。データ サービスは、関連付けられているデータ サービスへのデータ サービス リクエストを行う前にプリプロセッサを呼び出します。 |
ポストプロセッサ | DataRequestPostProcessor | クライアントに送信する途中に生データを変更するためのインターフェイス。データ サービスは、データ サービス結果をリクエスト元のクライアントに戻す前にポストプロセッサを呼び出します。 |
例:
Code Block |
---|
<requestProcessorDefinitions>
<preProcessorDefinitions>
<processorDefinition id="a" class="DataRequestPreProcessor"/>
<processorDefinition id="b" class="DataRequestPreProcessor"/>
</preProcessorDefinitions>
<postProcessorDefinitions>
<processorDefinition id="1" class="DataRequestPostProcessor"/>
<processorDefinition id="2" class="DataRequestPostProcessor"/>
</postProcessorDefinitions>
</requestProcessorDefinitions> |
...
さらに、nexaweb-sql.xml
...
globalProcessors
This section lists the pre- and post-processors required to format all data accessed through all data service types into the appropriate structures.
The globalProcessors section includes the following elements:
Element | Description |
preProcessors | References pre-processors to use as global processors. |
postProcessors | References post-processors to use as global processors. |
Use the processor tag to specify the ID of a processor defined in the requestProcessorDefinitions element as a pre- or post-processor to use globally.
...
...
globalProcessors
このセクションでは、全データ サービスタイプによってアクセスされる全データを適切な構造にフォーマット設定するために必要なプリプロセッサとポストプロセッサを示します。
globalProcessorsセクションには次の要素が含まれています。
要素 | 説明 |
preProcessors | グローバル プロセッサとして使用されるプリプロセッサを参照します。 |
postProcessors | グローバル プロセッサとして使用されるポストプロセッサを参照します。 |
processorタグを使用して、requestProcessorDefinitions 要素でグローバルに使用するプリプロセッサまたはポストプロセッサとして定義されているプロセッサの ID を指定します。
例:
Code Block |
---|
<globalProcessors>
<preProcessors>
<processor="a"> </processor>
</preProcessor>
<postProcessors>
<processor="1"> </processors>
</postProcessors>
</globalProcessors> |
dataServiceDefinitions
...
Currently, Nexaweb supports the following data service types:
Data Service Type | Description |
SQL | Provides a means for Nexaweb applications to obtain and update data from external databases through Java Database Connectivity (JDBC). |
Web services | Provides means for Nexaweb applications to obtain and update data from web services through REST and SOAP. |
In addition, you can specify pre- and post-processors per data service type to format data for all serviceRequests using that data service type.
The dataServiceDefinitions section includes the following elements:
Element | Description |
processors | Lists all processors for all requests using this data service type. |
preProcessors | References pre-processors to use for all requests using this data service type. |
postProcessors | References post-processors to use for all requests using this data service type. |
Use the processor tag to specify the ID of a processor defined in the requestProcessorDefinitions section as a pre- or post-processor for all serviceRequests using the SQL or web services type data service.
...
nexaweb-data.xml
...
現在、Nexaweb では次のデータサービスタイプをサポートしています。
データ サービス タイプ | 説明 |
SQL | Nexaweb アプリケーションが JDBC (Java Database Connectivity) を通じて外部データベースからデータを取得および更新する方法を提供します。 |
Web サービス | Nexaweb アプリケーションが REST と SOAP を使用して Web サービスからデータを取得および更新する方法を提供します。 |
また、データ サービス タイプごとにプリプロセッサとポストプロセッサを指定して、そのデータサービス タイプを使用するすべての serviceRequestのデータをフォーマット設定できます。
dataServiceDefinitionsセクションには次の要素が含まれています。
要素 | 説明 |
processors | このデータ サービス タイプを使用する全リクエストの全プロセッサを示します。 |
preProcessors | このデータ サービス タイプを使用する全リクエストに使用されるプリプロセッサを参照します。 |
postProcessors | このデータ サービス タイプを使用する全リクエストに使用されるポストプロセッサを参照します。 |
processor タグを使用して、requestProcessorDefinitionsセクションで SQL またはWeb サービスタイプのデータサービスを使用する全 serviceRequest のプリプロセッサまたはポストプロセッサとして定義されているプロセッサの ID を指定します。
例:
Code Block |
---|
<dataServiceDefinitions>
<dataService id="sql" |
...
class="com.nexaweb.server.data.services.sqlDataService">
<processors>
<preProcessors>
<processor="b"> </processor>
</preProcessor>
<postProcessors>
<processor="2"> </processors>
</postProcessors>
</processors>
</dataService>
</dataServiceDefinitions> |
dataRequestDefinitions
In this section you define any dataRequestDefinitions to use to access data sources from the server.
A dataRequestDefintion defines on the server the primary components of a serviceRequest, the information required to access external data, so that you do not need to specify all of this information in the client UI file. In addition, use a dataRequestDefinition to define the primary components of a serviceRequest in order to create a serviceRequest that uses arguments.
The following table describes the elements of a dataRequestDefinition:
Eelements | Description | Required |
ID | Specifies ID to uniquely identify this dataRequestDefinition to reference it in a serviceRequest. | Yes |
serviceResourceDefinition | Specifies the sql statement, REST or SOAP request to execute using the associated data service. | A dataRequestDefinition must specify either a serviceResourceDefinition or a serviceResourceReference. |
serviceResourceReference | Specifies the ID of the sql statement, REST or SOAP request defined in the nexaweb-sql.xml or nexaweb-webservices.xml file to execute. | A dataRequestDefinition must specify either a serviceResourceDefinition or a serviceResourceReference. |
parameterMap | Specifies a named parameter map for this definition. | No |
processors | Specifies IDs of any pre- or post-processors required to format data for this definition. | No |
The dataRequestDefinitions section includes the following elements:
Element | Description |
processors | Lists all processors for this dataRequestDefinition. |
preProcessors | References pre-processors to use for this dataRequestDefinition. |
postProcessors | References post-processors to use for this dataRequestDefinition. |
Use the processor tag to specify the ID of a processor defined in the requestProcessorDefinitions section as a pre- or post-processor for this dataRequestDefinition.
serviceResourceReference Example
...
dataRequestDefintion では、サーバー上で、serviceRequest の主要コンポーネントである、外部データへのアクセスに必要な情報を定義します。したがって、この情報はすべてクライアント UI ファイルで指定する必要はありません。また、引数を使用する serviceRequest を作成するために、dataRequestDefinitionを使用して dataRequestDefinition の主要コンポーネントを定義します。
次の表に、dataRequestDefinition の要素についての説明を示します。
要素 | 説明 | 必須 |
ID | この dataRequestDefinition を、serviceRequest での参照用に一意に識別するための ID を指定します。 | 必須 |
serviceResourceDefinition | 関連付けられているデータ サービスを使用して実行する SQL 文、REST リクエスト、または SOAP リクエストを指定します。 | dataRequestDefinition で serviceResourceDefinition または serviceResourceReferenceを指定する必要があります。 |
serviceResourceReference | nexaweb-sql.xmlまたは nexaweb-webservices.xml ファイルで定義済みの、実行する SQL 文、REST リクエスト、または SOAP リクエストの ID を指定します。 | dataRequestDefinition でserviceResourceDefinitionまたはserviceResourceReferenceを指定する必要があります。 |
parameterMap | この接続の名前付きパラメータ マップを指定します。 | 省略可能 |
processors | この定義のデータのフォーマット設定に必要なプリプロセッサまたはポストプロセッサの ID を指定します。 | 省略可能 |
dataRequestDefinitions セクションには次の要素が含まれています。
要素 | 説明 |
processors | この dataRequestDefinitionのすべてのプロセッサを示します。 |
preProcessors | この dataRequestDefinition に使用されるプリプロセッサを参照します。 |
postProcessors | この dataRequestDefinition に使用されるポストプロセッサを参照します。 |
processor タグを使用して、requestProcessorDefinitions要素でこの dataRequestDefinition のプリプロセッサまたはポストプロセッサとして定義されているプロセッサの ID を指定します。
serviceResourceReference の例
次のようにserviceResourceDefinition を使用して dataRequestDefinition を指定します。
Code Block |
---|
<dataRequestDefinition id="FlickrSearchRest">
<serviceResourceReference dataServiceId="WebService" serviceResourceId="searchFlickrParam" /> |
...
nexaweb-data.xml
...
...
serviceResourceDefinition
...
Specify a dataRequestDefinition using a serviceResourceDefinition similar to the following:
...
次のようにserviceResourceDefinition を使用してdataRequestDefinitionを指定します。
Code Block |
---|
<dataRequestDefinition id= |
...
”getDepartments”> <serviceResourceDefinition> <sqlStatement connectionId="engineering" |
...
xmlns= |
...
”http://nexaweb.com/service/data/ |
...
sql”> |
...
<statement>SELECT * FROM department where dept= |
...
’’{0} |
...
’’</statement> </sqlStatement> </serviceResourceDefinition> <parameterMap> <parameterMapping name= |
...
”deptId”> <default>engineering</default> </parameterMapping> </parameterMap> </ |
...
In this example, the dataRequestDefinition, getDepartments, inlcudes a serviceResourceDefinition that accesses an external data source though an SQL statement. The SQL statement selects from deptartment where dept is a variable. The parameterMap provides a means to pass a user-specified value for the dept variable, deptID, or thedefault value of engineering, if a user does not supply a value.
...
dataRequestDefinition> |
この例では、dataRequestDefinition、getDepartmentsに、SQL 文を使用して外部データソースにアクセスする serviceResourceDefinition が含まれています。SQL 文によって、dept 変数の値と一致する部門を選択します。ユーザーが値を指定しない場合は、parameterMapによって dept 変数のユーザー指定の値、deptID、または "engineering" のデフォルト値を渡すことができます。
サーバー上の nexaweb-data.xml ファイルで定義された dataRequestDefinition を、クライアント UI ファイルで定義済みの serviceRequest で使用します。この dataRequestDefinition を使用するには、次のようにクライアント UI ファイルで serviceRequest を作成します。
Code Block |
---|
<serviceRequest id= |
...
” |
...
getDepartmentRequest” dataRequestId= |
...
” getDepartments” xmlns= |
...
”http://nexaweb.com/service/ |
...
data”> <parameters> <parameter name= |
...
”deptId”>{0}</parameter> </parameters> </serviceRequest> |
The serviceRequest, 、getDepartmentRequest, references as the dataRequestID, the dataRequestDefinition, getDepartments. It specifies the parameter, deptId, which accepts user-specified values to pass to the deptID parameter mapping defined in the getDepartments dataRequestDefinition.で、dataRequestIDとしてdataRequestDefinition、getDepartmentsを参照します。パラメータ deptId を指定し、このパラメータが受け取ったユーザー指定の値を getDepartments dataRequestDefinition で定義された deptID パラメータマッピングに渡します。