Process-Display-Process (PDP) pattern

原创 2001年10月18日 10:25:00
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 devide the records into the batches of 100 records each and the user can then scrole through the batches.

The Normal design would implement a Servlet 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) objects 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 selecting 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 network 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 Reply
Read more Process-Display-Process (PDP) pattern.
Posted By: Bob Lee on October 17, 2001 in response to this message.
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.onjava.com/pub/a/onjava/2001/10/02/ejb.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 jdbc 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 drivers, you can use database-specific parameters to retrieve the results a page at a time.

PDP分组数据协议

PDP 详解 PDP(packet data protocol)分组数据协议,是外部PDN(PLMN外部包数据)网与GPRS接口所用的网络协议。它是GPRS连接的软硬件环境,指定GPRS连接的接入点...
  • lenk2010
  • lenk2010
  • 2013年03月20日 11:36
  • 2132

PDP上下文和PDP地址

http://www.mscbsc.com/10037062/viewspace-61117.html S要接入外部PDN,MS还应具有与该PDN相应的地址,称为PDP地址,PDP地址是用于...
  • larryliuqing
  • larryliuqing
  • 2014年10月23日 11:49
  • 705

pdp激活大致流程

移动终端开机连接到运营商后,访问3G网络外部IPv6业务,主要包括以下三个过程: | 国内领先的通信技术论坛!i)i*t8S)p   (1)附着(ATTACH)。附着过程的目的是系统根据移动终端的...
  • jljerryliu
  • jljerryliu
  • 2013年03月13日 11:56
  • 2231

GPRS-PDP上下文的激活过程

GPRS无线数据传输终端利用网络实现与上位机的全双工数据通信。终端需附着GPRS网络,登陆Internet与连接其上的任意一台普通PC机建立数据链路并随时进行数据传输。欲完成这一过程必须实现GPRS的...
  • jackli8431
  • jackli8431
  • 2016年05月23日 14:38
  • 989

PDP上下文和PDP地址

MS要接入外部PDN,MS还应具有与该PDN相应的地址,称为PDP地址,PDP地址是用于外部分组数据网识别MS的PDP上下文时使用的地址。如用手机上GPRS时,就会给你分配PDP报文,可以理解成由PD...
  • qq_21717607
  • qq_21717607
  • 2016年10月12日 11:16
  • 111

GPRS串口调试注意细节

通过串口发送数据到远程服务器上面 串口调试: AT+CIPHEAD=1  //1----GPRS 接收方式       ok AT+CIPSTART="TCP","60.186.20.162","50...
  • robinson_911
  • robinson_911
  • 2013年10月12日 17:13
  • 1602

GPRS附着,PDP激活失败

通常我们认为,网络拒绝用户attach的原因分为两种,一种归结为网络原因,比如网络中断、系统失败等导致的attach失败,另外一种归结为用户原因,比如用户没有签约GPRS功能导致网络的拒绝、用户没有签...
  • u011615963
  • u011615963
  • 2013年11月27日 10:29
  • 1680

中兴4g模块me3760拨号

拨号脚本打印的信息 AT> AT+ZEACT=2//LTE 接入技术 LTE-TDD Pref AT AT AT AT AT AT> AT+ZNCARD=1//1:切换为 Lin...
  • jinchengzhou
  • jinchengzhou
  • 2017年05月26日 14:17
  • 730

Pattern用法(正则表达式)

1. 正则表达式的应用        在给用户发送消息时通常情况会有相同的消息模板,但其中部分信息跟用户相关,因此需要对消息模板中的变量部分进行替换。而对于一个系统而言可能有很多套完全不同的模板。因...
  • woniu317
  • woniu317
  • 2016年08月11日 21:21
  • 9634

Pattern(概述)

1 简介  Pattern的下载地址为:http://www.clips.ua.ac.be/pattern   Pattern是Python编程语言的一个Web挖掘模块。它具有数据挖掘工具(谷歌,...
  • qq280929090
  • qq280929090
  • 2017年04月27日 10:13
  • 565
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Process-Display-Process (PDP) pattern
举报原因:
原因补充:

(最多只允许输入30个字)