// Call the service and print out result!
System.out.println("Current time is: " + timeService.getCurrentTime());
// Then invoke asynchronously
if (timeService instanceof ITimeServiceAsync) {
ITimeServiceAsync asyncTimeService = (ITimeServiceAsync) timeService;
System.out.println("Discovered ITimeServiceAsync via DS");
// Call the asynchronous remote service. Unlike the synchronous getTimeService(),
// this method will not block
Future<Long> currentTimeFuture = asyncTimeService.getCurrentTimeAsync();
// potentially do other operations here...
try {
System.out.println("Current time via future.get is: " + currentTimeFuture.get());
} catch (InterruptedException e) {
e.printStackTrace();