1 17 package org.apache.servicemix.beanflow; 18 19 import java.util.concurrent.Executor ; 20 21 27 public class AsynchronousActivity extends TimeoutActivity { 28 29 private final Executor executor; 30 private final Runnable runnable; 31 32 public AsynchronousActivity(Executor executor, Runnable runnable) { 33 this.executor = executor; 34 this.runnable = runnable; 35 } 36 37 @Override 38 protected void doStart() { 39 super.doStart(); 40 executor.execute(new Runnable () { 41 public void run() { 42 try { 43 runnable.run(); 44 stop(); 46 } 48 catch (Throwable e) { 49 fail("Failed to run task: " + runnable + ". Cause: " + e, e); 50 } 51 } 52 }); 53 } 54 } 55 | Popular Tags |