executeBatch
executeBatch(String sessionID, CommandImpl[] commands)
executeBatch メソッドを使用して、ランタイム・サーバーへの 1 つの要求で、複数のメソッドを実行できます。
*
sessionID - セッション ID を識別する文字列。このセッション ID は、このメソッド呼び出しによって実行されるすべてのコマンドに使用されます。
*
commandImpl[] - CommandImpl オブジェクトの配列 (実行するコマンドごとに 1 つずつ)。
このメソッドの呼び出しの結果は、Command 配列内の各メソッドを明示的に呼び出す場合と同じです。 このメソッドは、ランタイム・サーバーへの実際の要求の数を最小限に抑えます。 ランタイム・サーバーは、各メソッドを連続して実行します。各呼び出しに対するエラーや警告は、そのメソッド呼び出しに対応するレスポンス・オブジェクトで取得されます。 エラーが発生した場合、executeBatch はバッチの残りの呼び出しを続行します。 メソッドの実行結果がエラーになった場合、BatchResponse オブジェクトの最上位のステータスがそのエラーを示します。 エラーがない場合、警告が出ている可能性があれば、最上位のステータスがそれを示します。 警告がない場合、最上位のステータスがバッチ実行の成功を示します。
戻り値
ランタイム・サーバーは、BatchResponse オブジェクトを使用して、executeBatch に応答します。
以下の例は、1 つの executeBatch 呼び出しで getOffer と postEvent のすべてのメソッドを呼び出す方法と、応答の処理に関する推奨方法を示します。
/** Define all variables for all members of the executeBatch*/
String sessionId="MySessionID-123";
String interactionPoint = "Overview Page Banner 1";
int numberRequested=1;
String eventName = "logOffer";

/** build the getOffers command */
Command getOffersCommand = new CommandImpl();
getOffersCommand.setMethodIdentifier(Command.COMMAND_GETOFFERS);
getOffersCommand.setInteractionPoint(interactionPoint);
getOffersCommand.setNumberRequested(numberRequested);

/** build the postEvent command */
Command postEventCommand = new CommandImpl();
postEventCommand.setMethodIdentifier(Command.COMMAND_POSTEVENT);
postEventCommand.setEventParameters(postEventParameters);
postEventCommand.setEvent(eventName);

/** Build command array */
Command[] commands =
{
getOffersCommand,
postEventCommand,
};

/** Make the call */
BatchResponse batchResponse = api.executeBatch(sessionId, commands);

/** Process the response appropriately */
// Top level status code is a short cut to determine if there
// are any non-successes in the array of Response objects
if(batchResponse.getBatchStatusCode() == Response.STATUS_SUCCESS)
{
System.out.println("ExecuteBatch ran perfectly!");
}
else if(batchResponse.getBatchStatusCode() == Response.STATUS_WARNING)
{
System.out.println("ExecuteBatch call processed with at least one warning");
}
else
{
System.out.println("ExecuteBatch call processed with at least one error");
}

// Iterate through the array, and print out the message for any non-successes
for(Response response : batchResponse.getResponses())
{
if(response.getStatusCode()!=Response.STATUS_SUCCESS)
{
printDetailMessageOfWarningOrError("executeBatchCommand",
response.getAdvisoryMessages());
}
}