Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current Restore this Version View Page History

« Previous Version 7 Current »

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 SCA one-way operations (@OneWay) should be used instead of manually submitting asynchronous work as less code is required.