About Question enthuware.ocejws.v6.2.278 :

Moderators: Site Manager, fjwalraven

Post Reply
witek_m
Posts: 16
Joined: Sat Jun 09, 2018 12:09 pm
Contact:

About Question enthuware.ocejws.v6.2.278 :

Post by witek_m » Thu Jun 14, 2018 9:09 am

Hello, I have questions about answer:

Code: Select all

Future<GetResultKmPerHourResponse> result = port.getResultKmPerHourAsync(r); 
while (!result.isDone()) {    
System.out.println("."); 
} 
GetResultKmPerHourResponse km = (GetResultKmPerHourResponse) result.get();
and comment:
This gives a compile error which can be fixed like this: Future<GetResultKmPerHourResponse> asyncResult = (Future<GetResultKmPerHourResponse>) port.getResultKmPerHourAsync(r, callbackHandler);

I think it is correct, because Response implements Future

and about first (correct) answer:

Code: Select all

MyCallBackHandler<GetResultKmPerHourResponse> callbackHandler = new MyCallBackHandler<GetResultKmPerHourResponse>();
Future<?> asyncResult = port.getResultKmPerHourAsync(r, callbackHandler); 
GetResultKmPerHourResponse res = callbackHandler.getOutput();
callbackHandler don`t have to have getOutput() method so this code could be incorrect?

fjwalraven
Posts: 423
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.278 :

Post by fjwalraven » Thu Jun 14, 2018 2:16 pm

I think it is correct, because Response implements Future
Yes, you are right the question setup was wrong, it should be:

Code: Select all

Future<GetResultKmPerHourResponse> asyncResult = port.getResultKmPerHourAsync(r, callbackHandler);
Now the cast is needed because the getResultKmPerHourAsync() returns a Future<?>
callbackHandler don`t have to have getOutput() method so this code could be incorrect?
The code is only correct if you see my implementation sample which has a getOutput() method. I agree this is not clear and I will rename it to get().

Thanks for your feedback!
Frits

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests