Scheduling Asynchronous Work
Work can be scheduled for asynchronous execution by submitting it to the runtime ExecutorService thread pool. To obtain a reference to the service, use the Fabric3 @Resource annotation:
public class SomeComponent ... { @Resource protected ExecutorService executorService; @Reference protected TargetService targetService; public void doSomething() { executorService.submit(new Runnable() { public void run() { // invoke the service targetService.invoke(); } } } }
The executing thread will inherit the current component work context during the time the submitted Runnable is invoked.
Note that in most cases one-way operations (@OneWay) should be used instead of manually submitting asynchronous work as less code is required.