One thing you can do is to throw a bean together, whose sole purpose is to run things asynchronously and pass work to it inside the method. This may not make the API as pretty if you want to host @Async on your interfaces or something else, but it does the job.
public interface AsyncExecutor { void runAsynchronously(Runnable r); } public class SpringAOPAsyncExecutor implements AsyncExecutor { @Async @Override public void runAsynchronously(Runnable r) { r.run(); } } public MyService implements SomeInterface { @Autowired private AsyncExecutor springAOPAsyncExecutor; public ObjectHolder calculateAsychronously() { final ObjectHolder resultHolder = new ObjectHolder(); springAOPAsyncExecutor.runAsynchronously ( new Runnable() { public void run() {
source share