FileDocCategorySizeDatePackage
Client.javaAPI DocJBoss 4.2.12282Fri Jul 13 20:55:06 BST 2007org.jboss.tutorial.asynch.client

Client

public class Client extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

      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);