I am wondering what is the best practice for executing a http request from Tapestry code.
Here's a more concrete case:
On successful submit from some form, I'd like to execute a few http get requests to some URLs. Of course, one way to do it is in that method (onSubmitFromSomeForm()), but I don't really want to do that.
I was wondering if the good approach would be to try and implement it like this: http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread
I'm running Tapestry 5.3.7.
I'd recommend a simple service that spawns a new thread using ParallelExecutor.
public class CrawlerImpl implements Crawler {
private final ParallelExecutor executor;
public CrawlerImpl(final ParallelExecutor executor) {
this.executor = executor;
}
@Override
public void crawl(final String url) {
Future<String> future = executor.invoke(new Invokable<String>() { ... });
}
}