/*

 * Asynchronous Engine .

 * 

 * Copyright (C) 2004 Claude Hussenet

 * Contact : chussenet@yahoo.com

 * 

 * Distributable under LGPL license.

 * See terms of license at gnu.org.

 */

package test.asynchronous;

import org.jboss.aspects.asynchronous.AsynchronousTask;
import org.jboss.aspects.asynchronous.aspects.AsynchronousFacade;

/**

 *

 * @version <tt>$Revision: 1.3.4.3 $</tt>

 * @author  <a href="mailto:chussenet@yahoo.com">{Claude Hussenet Independent Consultant}</a>.

 */

public class BusinessThread implements Runnable {

	private BusinessModel businessModel;

	private long sleep;

	private long parameter;

	public Object result;

	public BusinessThread(

		BusinessModel aBusinessModel,

		long parameter,

		long sleep,

		String txt) {

		this.businessModel = aBusinessModel;

		this.sleep = sleep;

		this.parameter = parameter;

		

	}

	public void run() {

		AsynchronousFacade asynchronousFacade =

			(AsynchronousFacade)businessModel;

		businessModel.processBusinessModel2(parameter);

		BusinessModel.sleep(sleep);

		AsynchronousTask asynchronousTask1 =

			asynchronousFacade.getAsynchronousTask();

		if (!asynchronousFacade.isDone(asynchronousTask1))

			asynchronousFacade.waitForResponse(asynchronousTask1);

			result =asynchronousFacade.getReturnValue(asynchronousTask1);

 

	}

}