1 22 package test.asynchronous; 23 24 import org.jboss.aspects.asynchronous.AsynchronousTask; 25 import org.jboss.aspects.asynchronous.aspects.AsynchronousFacade; 26 27 36 37 public class BusinessThread implements Runnable { 38 39 private BusinessModel businessModel; 40 41 private long sleep; 42 43 private long parameter; 44 45 public Object result; 46 47 public BusinessThread( 48 49 BusinessModel aBusinessModel, 50 51 long parameter, 52 53 long sleep, 54 55 String txt) { 56 57 this.businessModel = aBusinessModel; 58 59 this.sleep = sleep; 60 61 this.parameter = parameter; 62 63 64 65 } 66 67 public void run() { 68 69 AsynchronousFacade asynchronousFacade = 70 71 (AsynchronousFacade)businessModel; 72 73 businessModel.processBusinessModel2(parameter); 74 75 BusinessModel.sleep(sleep); 76 77 AsynchronousTask asynchronousTask1 = 78 79 asynchronousFacade.getAsynchronousTask(); 80 81 if (!asynchronousFacade.isDone(asynchronousTask1)) 82 83 asynchronousFacade.waitForResponse(asynchronousTask1); 84 85 result =asynchronousFacade.getReturnValue(asynchronousTask1); 86 87 88 89 } 90 91 } | Popular Tags |