【问题标题】:Executing HTTP Request from Tapestry code从 Tapestry 代码执行 HTTP 请求
【发布时间】:2014-06-10 07:42:12
【问题描述】:

我想知道从 Tapestry 代码执行 http 请求的最佳做法是什么。

这是一个更具体的案例:

从某种形式成功提交后,我想对某些 URL 执行一些 http get 请求。当然,一种方法是使用该方法 (onSubmitFromSomeForm()),但我并不想这样做。

我想知道最好的方法是尝试像这样实现它:http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread

我正在运行 Tapestry 5.3.7。

【问题讨论】:

    标签: java httprequest task tapestry


    【解决方案1】:

    我推荐一个使用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>() { ... });
    
        }
    }
    

    【讨论】:

    • Tyvm,我会试一试,如果可行的话,我会接受 :) 同时,这是一个赞成票 :)
    猜你喜欢
    • 1970-01-01
    • 2013-02-28
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    • 2019-02-05
    • 1970-01-01
    • 2021-06-07
    相关资源
    最近更新 更多