プライマリ・コンテンツに移動
Oracle® Fusion Middleware Oracle Event Processingアプリケーションの開発
12c リリース1 (12.1.3)
E54312-04
目次へ移動
目次

前
前へ
次
次へ

11 パラメータ化されたアプリケーション

パラメータ化されたアプリケーションには、アプリケーションが起動する前に構成する必要がある特別なパラメータ(変数)が含まれます。通常、パラメータ化されたアプリケーションは、Oracle Event ProcessingのEPNシェルを使用してアプリケーションをデプロイするときに構成します。パラメータ化されたアプリケーションは、構成された後、通常のアプリケーションとして機能します。

この章の内容は次のとおりです。

11.1 アプリケーション・パラメータ

アプリケーション・パラメータは、ユーザーがアプリケーションを起動するときに設定できるプロパティ値を定義します。アダプタ、チャネル、イベントBean、Spring Bean、およびOracle CQLのパラメータ化された問合せ(ビューあり/なし)のプロパティをパラメータ化できます。

アプリケーション・パラメータ(属性)を定義するには、属性定義(AD)をオブジェクト・クラス定義(OCD)にグループ化します。パラメータ化するアプリケーション・コンポーネントごとに1つのOCDを作成します。OCDには、パラメータ化するコンポーネント・プロパティおよびプロンプト・テキストを指定するためのADが1つ以上含まれます。

OCDは、Oracle Event Processingアプリケーション内のOSGI-INF/metatypeディレクトリにあるXMLドキュメント(metatypeファイル)に配置します。このmetatypeファイルは、http://www.osgi.org/xmlns/metatype/v1.1.0/metatype.xsdにある仕様によって定義されるスキーマを使用し、これに準拠しています。

構成例は、metatypeファイルの例を参照してください。

Oracle Event Processingのパラメータ化されたアプリケーションは、http://www.osgi.orgにあるOSGi MetaTypeの仕様に準拠しています。http://felix.apache.org/documentation/subprojects/apache-felix-metatype-service.htmlにあるApache実装を参照してください。

11.2 オブジェクト・クラス定義

すべてのOCDに、name、idおよびdescriptionパラメータが必要です。次の例は、ADがないOCDを示します。

このOCDは、アプリケーション・メタデータを定義していますが、ADがないため、説明は表示されますが、ユーザーには入力が求められません。このタイプのOCDによってアプリケーションが記述されます。

<OCD name="HelloWorld Sample" id="com.oracle.cep.sample.helloworld"
  description="The helloworld OEP application is a sample application 
  for Oracle Event Processing.">    
</OCD>

11.3 属性の説明

すべてのADに、name、idおよびdescriptionパラメータが必要です。次の例は、2つのADがあるOCDを示します。

このOCDは、チャネル・コンポーネントの共通定義を提供しており、スレッドの最大数およびチャネルの最大バッファ・サイズに関するパラメータ化された属性(AD)を提供しています。

ユーザーによってアプリケーションが実行されると、指定した説明および他の情報が表示され、要求した情報がユーザーによって入力されて[Return]キーが押されるまで待機します。

<OCD name="Channel Configuration" id="com.oracle.cep.channel"
  description="The channel definition in the OCEP Application"
  ocep:binding="jmx:EventChannel">
  <AD name="Max Threads" id=".maxThreads" type="Integer" required="true"
    default="0" min="0" max="100" 
    description="Number of threads generating messages." 
    ocep:binding="MaxThreads" />
  <AD name="Max Size" id=".maxSize" type="Integer" required="true"
    default="0" min="0" max="100"
    description="The maximum size of the FIFO buffer for this channel."
    ocep:binding="MaxSize" />
</OCD>

注:

エラーを回避するために、常に、metatypeファイル内で最大サイズの前に最大スレッド数を定義してください。

12cリリースの場合、サポートされている唯一のバインディングはJava Management Extension (JMX)です。つまり、AD属性は対応するJMX属性にバインドする必要があります。ターゲットを参照してください。

11.4 ターゲット

OCDおよびアプリケーション・コンポーネントをDesignate要素に接続できます。その後、アプリケーション・クラス定義を複数の指定(同じタイプのコンポーネント)のターゲットにして、定義を再利用できます。

あいまいさを避けるために、各指定を1つのオブジェクト・クラス定義のみに関連付けることができます。

Oracle Event Processingでは、次の指定をサポートします。

  • アダプタ、Oracle CQLプロセッサ、イベントBeanまたはSpring Bean。

  • 問合せやビューなどのOracle CQLプロセッサ・ルール。ルールの場合、指定IDにより、親コンポーネントとそれに続くサブコンポーネントを識別する必要があります。たとえば、helloworldProcessor:q1です。

Oracle Event Processingでは、afterPropertiesSetライフサイクル・メソッドをコールした後、ただし、afterConfigurationActiveライフサイクル・メソッドをコールする前に、アプリケーション・コンポーネントにパラメータが割り当てられます。このタイミングにより、アプリケーションがアプリケーション・パラメータを適切なアプリケーション構成として処理し、アプリケーション・パラメータをBeanプロパティと区別できるようになります。

ocep:binding属性により、Oracle Event Processingがパラメータをアプリケーションに割り当てる方法が決定されます。ocep:binding属性をOCDまたはAD内に配置します。これをOCDに配置すると、メタオブジェクトはJMX ObjectInstanceなどの実装オブジェクトにバインドされます。OCDをADに配置すると、メタ属性は、JMX MBean属性などの実装オブジェクトに範囲が設定された実装属性にバインドされます。

11.5 metatypeファイルの例

次のコードは、metatypeファイルの全体を示します。

<MetaData xmlns="http://www.osgi.org/xmlns/metatype/v1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation=
    "http://www.osgi.org/xmlns/metatype/v1.1.0;
    http://www.osgi.org/xmlns/metatype/v1.1.0/metatype.xsd"> 
 
  <OCD name="HelloWorld Sample" id="com.oracle.cep.sample.helloworld"
    description="The helloworld OEP application is a sample application 
    for Oracle Event Processing.">    
  </OCD>
 
  <OCD name="HelloWorld Channel" id="com.oracle.cep.sample.helloworld.channel" >
    <AD name="Max Threads" id="EventChannel.MaxThreads" type="Integer"
        required="true" default="0" min="0" max="100"
        description="Number of threads generating helloworld messages." />

    <AD name="Max Size"     id=".maxSize"     type="Integer"  required="true"
        default="0"  min="0" max="100"  description="The maximum size of the FIFO
        buffer for this channel." ocep:binding="MaxSize" />
  </OCD> 
 
  <OCD name="HelloWorld Message Filtering"
    id="com.oracle.cep.sample.helloworld.filter" >    
    <AD name="Filter" id="CQLProcessor.parameters" type="String"
      description="Message filter." />
  </OCD>

  <Designate pid="helloworld"  >
    <Object ocdref="com.oracle.cep.sample.helloworld" /> 
  </Designate>

  <Designate pid="helloworldInputChannel"  >
    <Object ocdref="com.oracle.cep.sample.helloworld.channel" />
  </Designate> 
 
  <Designate pid="helloworldProcessor.helloworldRule" >
    <Object ocdref="com.oracle.cep.sample.helloworld.filter" />
  </Designate>
</MetaData>

11.6 パラメータ化されたアプリケーションを使用できる場合

パラメータ化されたアプリケーションは次の3つの方法で使用できます。

11.6.1 アプリケーションの文書化

次の例では、com.oracle.cep.parameterizedappアプリケーションを文書化しています。designate要素のpid属性は、MANIFEST.MFのBundle-SymbolicNameに対応します。

<OCD name="Parameterized App Testing" id="com.oracle.cep.parameterizedapp"
  description="The application is for parameterized app testing.">
</OCD>
 
<Designate pid="parameterizedapp">
  <Object ocdref="com.oracle.cep.parameterizedapp" />
</Designate>

11.6.2 チャネル構成

次の例は、ADとOCDを使用してチャネルを構成する方法を示します。designate要素のpid属性は、EPNファイルのチャネル・コンポーネントに対応します。

<OCD name="Channel Configuration" id="com.oracle.cep.channel"
 description="The channel definition in the OCEP Application"
 ocep:binding="jmx:EventChannel">
 <AD name="Max Threads" id=".maxThreads" type="Integer" required="true"
   default="0" min="0" max="100" 
   description="Number of threads generating messages."
   ocep:binding="MaxThreads" />
 <AD name="Max Size" id=".maxSize" type="Integer" required="true"
   default="0" min="0" max="100"
   description="The maximum size of the FIFO buffer for this channel."
   ocep:binding="MaxSize" />
 <AD name="HEARTBEAT" id=".heartbeat" type="Long" required="false"
   default="5000000000" min="0" max="100000000000"
   description="The value for the heartbeat timeout on this channel.
   The default time unit is nanoseconds."
   ocep:binding="HeartbeatTimeout" />
</OCD>
 
<Designate pid="helloworldInputChannel">
  <Object ocdref="com.oracle.cep.channel" />
</Designate> 
 
<Designate pid="helloworldOutputChannel">
  <Object ocdref="com.oracle.cep.channel" />
</Designate>

11.6.3 Oracle CQL Processorの問合せ

次の例は、Oracle CQLプロセッサの問合せを構成する方法を示します。AD定義は、シーケンスの問合せパラメータ1および2に対応します。

<OCD name="Product Filter" id="com.oracle.cep.solution.product.filter"
  ocep:binding="jmx:CQLProcessor" ocep:multi-valued="true">
  <AD name="range" id=".range" type="Integer" required="true" min="0"
    max="1000000000" default="10"
    description="The range scope"
    ocep:binding="Parameters" />
  <AD name="field" id=".field" type="String" required="true"
    default="'remainingQty'" 
    description="select one field you want to do range controlling"
    ocep:binding="Parameters">
    <Option label="remainingQty" value="remainingQty" />
    <Option label="totalQty" value="totalQty" />
    <Option label="price" value="price" />
  </AD>
</OCD>
 
<Designate pid="productProcessor.productRule">
  <Object ocdref="com.oracle.cep.solution.product.filter" />
</Designate>

次のとおり、productProcessorを定義するconfig.xmlファイルにprocessor要素を追加します。AD定義は、シーケンスの問合せパラメータ1および2に対応することに注意してください。

<processor>
  <name>productProcessor</name>
  <rules>
    <query id="productRule">
      <![CDATA[
       IStream (select FROM productInputChannel [RANGE :1 on :2) ]]
      >
    </query>
  </rules>
</processor>

11.7 HelloWorldアプリケーションのデプロイ

次の例では、EPNシェルとともにApache Felix Gogoを使用して、パラメータ化されたHellowWorldアプリケーションをデプロイしています。EPNシェルは、OSGi Bundle Repository (OBR)とのインタフェースを確立し、イントロスペクションを使用して使用可能なメタデータを特定し、ユーザーに適したプロンプトを構成します。

次の例は、EPNシェルを使用してデプロイされている場合のHelloWorldアプリケーションの出力を示します。

注:

パラメータ化されたアプリケーションは、クラスタ化されたドメインではサポートされません。また、デプロイはEPNシェルを介してのみ実行できます。このリリースでは、パラメータ化されたアプリケーション・デプロイメントはOracle JDeveloperまたはOracle Event Processing Visualizerでサポートされません。

	./startwleves.sh -shell
Oracle CEP Shell (using Apache Felix Gogo)
	shell> 
	shell> deployapp file:///Users/myuserid/helloworld.jar
	---- HelloWorld Sample ----
	The helloworld OEP application is a sample application for Oracle OEP.
	Enter Y/N [default is Y] if you would like to set the parameter "Max Threads" :
-- Application parameter "Max Threads" 
	--Description : Number of threads generating helloworld messages.
	Type: Integer
Default value: 2
Enter value for "Max Threads" or empty for default value :
	Using default value of "2".	
-- Application parameter "Filter" 
--Description : Message filter.
	Type: String
Options for parameter "Filter" are : 
(0) Select all messages starting with 'Hello' 
		(1) Select all messages starting with 'Hi'Select option by entering number [0,1] or empty for default value :
	<Jan 23, 2012 7:20:40 AM EST> <Notice> <Deployment> <BEA-2045000> 
	<The application bundle "helloworld" was deployed successfully>
	<Jan 23, 2012 7:20:41 AM EST> <Notice> <Spring> <BEA-2047000> 
	<The application context for "helloworld" was started successfully> 
	Message: HelloWorld - the current time is:7:20:41 AM
	Message: HelloWorld - the current time is:7:20:42 AM