Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Platform 4.5+ が必要

Configuring Data Services

...


データ サービスの構成

データ サービスは、主として nexaweb-data.xml

...

ファイルで構成します。

...


また、nexaweb-sql.xml

...

ファイルで statementHandlerDefinitions を定義することによって、SQL データ サービスを構成することもできます。

nexaweb-data.xml

...

ファイルの構成

...


nexaweb-data.xml

...

Configuration SectionDescription
requestProcessorDefinitionsDefines the pre- and post-processors that you can use: globally for all services requests; per data service type; in dataRequestDefinitions.
globalProcessorsLists pre- and post-processors that the data service applies to all service requests of any data service type.
dataServiceDefinitionsDefines 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.
dataRequestDefinitionsDefines 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:

ElementDescription
preProcessorDefinitionsLists pre-processors definitions.
postProcessorDefinitionsLists 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:

AttributesDescription
ClassSpecifies the implementing class for the processor.
IDSpecifies 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 TypeImplementing ClassDescription
Pre-processorsDataRequestPreProcessorInterface to modify data request information. The data service calls pre-processors prior to making the data service request to the associated data service.
Post-processorsDataRequestPostProcessorInterface 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:

ElementDescription
preProcessorsReferences pre-processors to use as global processors.
postProcessorsReferences 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.

...

ファイルとnexaweb-webservices.xml

...

ファイルで statementHandlerDefinitionsを指定すると、これらのファイルで定義されている SQL 文、REST リクエスト、または SOAP リクエストのデータをフォーマット設定することができます。

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 TypeDescription
SQLProvides a means for Nexaweb applications to obtain and update data from external databases through Java Database Connectivity (JDBC).
Web servicesProvides 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:

ElementDescription
processorsLists all processors for all requests using this data service type.
preProcessorsReferences pre-processors to use for all requests using this data service type.
postProcessorsReferences 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

...

ファイルの dataServiceDefinitions セクションには、外部データソースにアクセスするために使用可能なデータサービスタイプごとに 1 つのエントリが含まれています。

現在、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:

EelementsDescriptionRequired
IDSpecifies ID to uniquely identify this dataRequestDefinition to reference it in a serviceRequest.Yes
serviceResourceDefinitionSpecifies the sql statement, REST or SOAP request to execute using the associated data service.A dataRequestDefinition must specify either a serviceResourceDefinition or a serviceResourceReference.
serviceResourceReferenceSpecifies 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.
parameterMapSpecifies a named parameter map for this definition.No
processorsSpecifies IDs of any pre- or post-processors required to format data for this definition.No

The dataRequestDefinitions section includes the following elements:

ElementDescription
processorsLists all processors for this dataRequestDefinition.
preProcessorsReferences pre-processors to use for this dataRequestDefinition.
postProcessorsReferences 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

...

ファイルには、nexweb-webservice.xml

...

ファイルで定義された WebService タイプのデータサービスリクエストsearchFlickrParamを参照するdataRequestDefinitionFlickrSearchRestが定義されています。

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>

 


この例では、dataRequestDefinitiongetDepartmentsに、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としてdataRequestDefinitiongetDepartmentsを参照します。パラメータ deptId を指定し、このパラメータが受け取ったユーザー指定の値を getDepartments dataRequestDefinition で定義された deptID パラメータマッピングに渡します。