Javaコード・アクション
Javaコードアクションにより、oracle.integration.platform.faultpolicy.IFaultRecoveryJavaClassインタフェースを実装するカスタマイズJavaクラスをコールできます。このアクションは、パラレルと順次の両方のルーティング・ルールに適用できます。次の例は、Javaコード・アクションの実装方法を示しています。
ノート:
実装済Javaクラスは、文字列を戻すメソッドを実装している必要があります。ポリシーは、戻された文字列に基づいて新しいアクションにチェーンできます。
Javaコード・アクションは、最初に、ドメイン・クラス・ライブラリ内の実装済クラスを検索します。そこでクラスが見つからない場合は、コンポジット・アプリケーションのクラス・ライブラリが検索されます。
<Action id="ora-java">
<javaAction className="mypackage.myClass" defaultAction="ora-terminate">
<returnValue value="ABORT" ref="ora-terminate"/>
<returnValue value="RETRY" ref="ora-retry"/>
<returnValue value="MANUAL" ref="ora-human-intervention"/>
</javaAction>
</Action>
順次ルーティング・ルール・フォルト・ポリシーの場合、returnValueアクションは、中断、再スロー、またはJavaアクションの1つである必要があります。returnValueが、これらの有効な値以外である場合、defaultActionがチェックされます。defaultActionも有効なアクション(中断、再スロー、またはJavaアクション)でない場合、デフォルトではアクションは実行されず、元のフォルトがコール元にスローされます。
oracle.integration.platform.faultpolicy.IFaultRecoveryJavaClass {
public void handleRetrySuccess(IFaultRecoveryContext ctx);
public String handleFault(IFaultRecoveryContext ctx);
}public interface IFaultRecoveryContext {
/**
* Gets implementation type of the fault.
* @return
*/
public String getType();
/**
* @return Get property set of the fault policy action being executed.
*/
public Map getProperties();
/**
* @return Get fault policy id of the fault policy being executed.
*/
public String getPolicyId();
/**
* @return Name of the faulted reference.
*/
public String getReferenceName();
/**
* @return Port type of the faulted reference link.
*/
public QName getPortType();
}メディエータ・サービス・エンジンの実装
次の例は、IFaultRecoveryContextインタフェースのOracle Mediatorサービス・エンジンの実装を示しています。
package oracle.tip.mediator.common.error.recovery;
public class MediatorRecoveryContext implements IFaultRecoveryContext{
...
}
次の例に示すメソッドを使用すると、MediatorRecoveryContextクラスで使用可能なメディエータ固有の追加データを取得できます。
public CommonFault getACommonFault() public CalloutMediatorMessage getMediatorMessage()
次の例は、CalloutMediatorMessageインタフェースを使用したデータの取得方法を示しています。
/**
* Accessing Mediator Message properties by providing the property name
* @param propertyName
* @return
* @throws MediatorException
*/
public Object getProperty(String propertyName);
/**
* Accessing Mediator Message properties
* @return
* @throws MediatorException
*/
public Map getProperties();
/**
* Accessing instance id of the mediator message
* This will be the mediator instance id created for that particular message
* object
* @return
* @throws MediatorException
*/
public String getId() throws MediatorException;
/**
* Accessing payload of the mediator message
* object
* @return
* @throws MediatorException
*/
public Map getPayload();
/**
* Accessing header of the mediator message
* object
* @return
* @throws MediatorException
*/
public List<Element> getHeaders();
/**
* Accessing componentDN for mediator component
* @return
* @throws MediatorException
*/
public String getComponentDN(
/**
* Setting payload to the mediator message
* @return
* @throws MediatorCalloutException
*/
public void addPayload(String partName,Object payload) throws MediatorCalloutException;
/**
* Adding property to the mediator message
* @return
* @throws MediatorCalloutException
*/
public void addProperty(String name,Object value) throws MediatorCalloutException;
/**
* Adding header to the mediator message
* @return
* @throws MediatorCalloutException
*/
public void addHeader(Object header) throws MediatorCalloutException;