Tapestry钩子:渲染开始和渲染结束
我正在尝试使用 jamon 来收集使用 Tapestry 的网站的统计信息(渲染网页的时间)。
如何继续
- 当服务器收到请求(即渲染开始)时,
- 执行方法?当响应全部发送时执行的方法,即渲染结束?
我正在尝试使用 @OnEvent
注释,但我不会走得太远。
I am trying to use jamon to collect statistics (time to render a web page) of a website using tapestry.
How can I proceed to have
- a method executed when the request is received by the server, i.e. the start of the rendering ?
- a method executed when the response is all sent, i.e. the end of the rendering ?
I am trying to use the @OnEvent
annotation but I'm not going very far with that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以创建一个
RequestFilter
来包装对您自己的代码的调用之间的实际渲染:您需要通过应用程序模块将过滤器贡献给渲染管道:
You could create a
RequestFilter
to wrap the actual rendering between calls to your own code:You'd need to contribute your filter to the rendering pipeline via your application module:
Tapestry 具有可扩展的管道,可以组织任何特定类型请求的逻辑。我不确定您是否正在尝试测量总体请求处理时间,或者只是测量渲染所花费的时间(并且,在 Tapestry 中,实际上是渲染 DOM,然后将 DOM 流式传输到客户端)。 HttpServletRequestHandler 管道是放置过滤器的好地方,该过滤器可以测量所有请求的所有响应时间(但没有提供仅选择页面渲染请求的好方法),PageRenderRequestHandler 管道适合测量渲染和流式传输的时间页。
Tapestry has extensible pipelines that organize the logic for any particular type of request. I'm not sure if you are trying to measure over-all request processing time, or just the time spent rendering (and, in Tapestry, there's actually rendering the DOM, and then streaming the DOM to the client). The HttpServletRequestHandler pipeline is a good place to put a filter that can measure over all response time for all requests (but does not provide a good way to select only page render requests), the PageRenderRequestHandler pipeline is good for measuring time to render and stream the page.