Java Reference
In-Depth Information
an invocation of the executeTask Web service method at line 5. Follow-
ing the specifications presented in Chapter 11, if the argument pro-
vided to the Web service executeTask is the task name (instead of the
task itself), the execution is run asynchronously. We could have
obtained the ExecuteTaskResponse to get the first execution status, but
we preferred to show the use of the getExecutionStatus Web service.
Invocation of this service returns an ExecutionState that can be
accessed through GetExecutionStatusResponse , as shown at lines 9
and 10. As usual, the state can be monitored through a while loop, as
shown by lines 11 to 18. If the task ends with an error, the descrip-
tion of this error is reported at line 21.
1. protected void askToExecuteTask(IDataMining iServices, Task iTask)
2.
throws RemoteException, InterruptedException {
ExecuteTask lExecuteTask new ExecuteTask();
3.
4.
lExecuteTask.setTaskName(iTask.getName());
5.
iServices.executeTask(lExecuteTask);
GetExecutionStatus lExecutionStatus new GetExecutionStatus();
6.
7.
lExecutionStatus.setTaskName(lExecuteTask.getTaskName());
8.
GetExecutionStatusResponse lExecutionStatusResponse
iServices.getExecutionStatus(lExecutionStatus);
9.
ExecutionState lState lExecutionStatusResponse.getStatus().getState();
10.
11.
while (lState.equals(ExecutionState.executing)
12.
|| lState.equals(ExecutionState.terminating)
13.
|| lState.equals(ExecutionState.submitted)) {
14.
Thread.sleep(1000);
lExecutionStatusResponse
15.
16.
iServices.getExecutionStatus(lExecutionStatus);
lState lExecutionStatusResponse.getStatus().getState();
17.
18.
}
19.
if (lState.equals(ExecutionState.error)) {
System.out.println("Error executing task: ["
20.
lExecutionStatusResponse.getStatus().getDescription() "]");
21.
22.
return;
23.
} else {
24.
System.out.println ("Last state of execution: ["
lState.getValue() "]");
25.
26.
}
27. }
At this point, if the five methods described above are executed in
sequence, a valid classification model will be accessible through the
connection. This model, if given a name beginning with Product , can
be used by the product recommendation Web browser front end
shown in the PHP client application.
 
Search WWH ::




Custom Search