InitialContext ctx = new InitialContext();
Echo echo = (Echo)ctx.lookup("EchoBean/remote");
System.out.println("-------- Synchronous call");
String ret = echo.echo("normal call");
System.out.println(ret);
Echo asynchEcho = (Echo) Asynch.getAsynchronousProxy(echo);
System.out.println("-------- Asynchronous call");
ret = asynchEcho.echo("asynchronous call");
System.out.println("Direct return of async invocation is: " + ret);
System.out.println("-------- Synchronous call");
ret = echo.echo("normal call 2");
System.out.println(ret);
System.out.println("-------- Result of Asynchronous call");
Future future = Asynch.getFutureResult(asynchEcho);
System.out.println("Waiting for asynbch invocation to complete");
while (!future.isDone())
{
Thread.sleep(100);
}
ret = (String)future.get();
System.out.println(ret);