博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Process-Display-Process (PDP) pattern (转)
阅读量:2511 次
发布时间:2019-05-11

本文共 4060 字,大约阅读时间需要 13 分钟。

Process-Display-Process (PDP) pattern (转)[@more@]Solution :- Process-Display-Process Desgin.
In this we adopt a approach which will process a small set of data first and then display the results to the user. While the user is having a look at the given results we can process the remaining results in the background and store them for further use.
Suppose we have a requirement, where we need to query on a table having a million records and fetch ten thound of them to display it to the user. But we sure can not display ten thousand records at a time, so we dev the records into the batches of 100 records each and the user can then scrole through the batches.
The Normal design would implement a and stateless session bean. The Session Bean queries the database based on the query criteria and then passes on the result set bound in PBV (pass-by-value) s to the servlet. The servlet then Displays first batch and subsequent batches to the user based on this query data.
In this design (PDP pattern) we will make use of Servlets and Stateful session beans. The stateful session bean will have two methods, one for ing the first batch, and another for selecting the remaining of the records. When the client enters some query criteria, these are passed to the first method of the stateful session bean (typically getFirstBatchResults() ). This method will then process the first batch results and send them back to the Servlet. The servlet displays the results to user making use of ( Response.flushBuffer() ). The query to database for selecting first batch can be made faster by using database features which allow you to select the "top n" records from the results.
After this, the control is still in the servlet. So we can call the second method of the Statefull session bean. This method ( typically getAllResults() ) will fetch all the records from the database and store them in the stateful session bean's privatte variable (arraylist). When the user wants to scroll through the records, we simply try to get that perticular batch from the stateful session bean. The getAllrecords() method needs to ommit the first batch results from subsequently adding to the arraylist.
Advantages :-
1. This gives the user a feeling that the response is quite fast.
2. Since the most of the data is stored in the Stateful Session Bean, It reduces the size of HttpSession.
Disadvantages / limitations :-
1. It can not be used where in the user is required to show the summery of all the results. In that case we need to process all the records before we can show anything to the user.
2. It results into two work calls for the same query criteria.
3. Thread safe ness of the methods needs to be checked, as we are operating on a private variable of the Stateful Session Bean.
4. If the user needs to sort the records based on some perticular columns, then this can not be implemented.
1 replies in this thread ?message_id=31286">
Reply
Read more Process-Display-Process (PDP) pattern.
threadcorner.gif Posted By: Bob Lee on October 17, 2001 in response to . First, for an argument as to why a stateful session bean should absolutely not be used in this situation, I'll point you here: http://www.on .com/pub/a/onjava/2001/10/02/ .html.
Second, this is just a page-by-page iterator, and you can find it in the Sun blueprints.
The way you should set this up is with a stateless session bean with a single method, getRows(int startIndex, int pageSize,...).
If you're lucky enough to have j c 2.0, you can query the entire set and return only the window of rows requested using ResultSet.setFetchSize(pageSize) and ResultSet.absolute(startIndex). You can also use prepared statements here to make things more efficient. If you want to sort by a particular column, just pass it as a parameter to your session bean and generate it on the fly.
If you’re stuck with older s, you can use database-specific parameters to retrieve the results a page at a time.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10748419/viewspace-998684/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10748419/viewspace-998684/

你可能感兴趣的文章
期货市场技术分析03_主要反转形态
查看>>
期货市场技术分析04_持续形态
查看>>
期货市场技术分析05_交易量和持仓兴趣
查看>>
TB交易开拓者入门教程
查看>>
TB创建公式应用dll失败 请检查用户权限,终极解决方案
查看>>
python绘制k线图(蜡烛图)报错 No module named 'matplotlib.finance
查看>>
talib均线大全
查看>>
期货市场技术分析06_长期图表和商品指数
查看>>
期货市场技术分析07_摆动指数和相反意见理论
查看>>
满屏的指标?删了吧,手把手教你裸 K 交易!
查看>>
不吹不黑 | 聊聊为什么要用99%精度的数据回测
查看>>
高频交易的几种策略
查看>>
量化策略回测TRIXKDJ
查看>>
量化策略回测唐安奇通道
查看>>
CTA策略如何过滤部分震荡行情?
查看>>
量化策略回测DualThrust
查看>>
量化策略回测BoolC
查看>>
量化策略回测DCCV2
查看>>
mongodb查询优化
查看>>
五步git操作搞定Github中fork的项目与原作者同步
查看>>