`

表示层模式:Value List Handler—值列表处理器模式

阅读更多

Context
The client requires a list of items from the service for presentation. The number of
items in the list is unknown and can be quite large in many instances.
Problem
Most Java 2 Platform, Enterprise Edition (J2EE) applications have a search and query
requirement to search and list certain data. In some cases, such a search and query operation
could yield results that can be quite large. It is impractical to return the full result set when
the client's requirements are to traverse the results, rather than process the complete set.
Typically, a client uses the results of a query for read-only purposes, such as displaying the
result list. Often, the client views only the first few matching records, and then may discard
the remaining records and attempt a new query. The search activity often does not involve
an immediate transaction on the matching objects. The practice of getting a list of values
represented in entity beans by calling an ejbFind() method, which returns a collection of
remote objects, and then calling each entity bean to get the value, is very network expensive
and is considered a bad practice.
There are consequences associated with using Enterprise JavaBeans (EJB) finder
methods that result in large results sets. Every container implementation has a certain
amount of finder method overhead for creating a collection of EJBObject references. Finder
method behavior performance varies, depending on a vendor's container implementation.
According to the EJB specification, a container may invoke ejbActivate() methods on
entities found by a finder method. At a minimum, a finder method returns the primary keys
of the matching entities, which the container returns to the client as a collection of
EJBObject references. This behavior applies for all container implementations. Some
container implementations may introduce additional finder method overhead by associating
the entity bean instances to these EJBObject instances to give the client access to those
entity beans. However, this is a poor use of resources if the client is not interested in
accessing the bean or invoking its methods. This overhead can significantly impede
application performance if the application includes queries that produce many matching
results.
Forces
The application client needs an efficient query facility to avoid having to call the
entity bean's ejbFind() method and invoking each remote object returned.
A server-tier caching mechanism is needed to serve clients that cannot receive and
process the entire results set.
A query that is repeatedly executed on reasonably static data can be optimized to
provide faster results. This depends on the application and on the implementation of this
pattern.
EJB finder methods are not suitable for browsing entire tables in the database or for
searching large result sets from a table.
Finder methods may have considerable overhead when used to find large numbers of
result objects. The container may create a large number of infrastructure objects to facilitate
the finders.
EJB finder methods are not suitable for caching results. The client may not be able to
handle the entire result set in a single call. If so, the client may need server-side caching and
navigation functions to traverse the result set.
EJB finder methods have predetermined query constructs and offer minimum
flexibility. The EJB specification 2.0 allows a query language, EJB QL, for
container-managed entity beans. EJB QL makes it easier to write portable finders and offers
greater flexibility for querying.
Client wants to scroll forward and backward within a result set.
Solution
Use a Value List Handler to control the search, cache the results, and provide the
results to the client in a result set whose size and traversal meets the client's requirements.
This pattern creates a ValueListHandler to control query execution functionality and
results caching. The ValueListHandler directly accesses a DAO that can execute the
required query. The ValueListHandler stores the results obtained from the DAO as a
collection of Transfer Objects. The client requests the ValueListHandler to provide the
query results as needed. The ValueListHandler implements an Iterator pattern [GoF] to
provide the solution.

分享到:
评论

相关推荐

    敏捷软件开发:原则、模式与实践

    第25章 ABSTRACT SERVER模式、ADAPTER模式和BRIDGE模式 第26章 PROXY模式和STAIRWAY TO HEAVEN模式:管理第三方API 第27章 案例研究:气象站 第六部分 ETS案例研究 第28章 VISITOR模式 第29章 STATE模式 第30章 ETS...

    23种设计模式入门到精通详解.txt

    单例模式:某个类只能有一个实例,提供一个全局的访问点。 简单工厂:一个工厂类根据传入的参量决定创建出那一种产品类的实例。 工厂方法:定义一个创建对象的接口,让子类决定实例化那个类。 抽象工厂:创建相关...

    表示层设计模式:InterceptingFilter(截取筛选器)

    本页内容上下文问题影响因素解决方案变体示例结果上下文相关模式致谢 上下文对于任何一个曾经从头建立Web应用程序的人来说,他们都会有这样的体会:这项任务所需要的独立完成的工作量要比建立内部客户端-服务器应用...

    工厂模式三层结构示例项目源码

    CodematicDemoF3 是一个基于工厂模式的三层架构示例项目源码,基于VS2005 SP1开发(如果没有装SP1,web项目会打不开),结构更简洁,提供更多有效的示例源码参考。方便用户更好的理解和使用该架构进行开发,配合动软...

    网站生成器-工厂模式开发,用于页面表示层

    网站开发的一层 二层开发完成之后,所有的页面表示层都可以用此软件来生成。这是我们开发时自己开发的软件。绝对好用。提高工作效率。

    JavaEE设计模式之表示层模式

    因为表示层是请求驱动的,所以“用户”可以是任意请求的发起者。控制器处理该请求。模型就是业务数据,而视图就是最终发生的应答。控制器是与请求发生联系的起点。控制器就是一个主管,首先规划要做哪些更新和要显示...

    快速学习C++设计模式:观察者模式实例代码

    观察者模式是目前应用最广、影响范围最大的模式之一,因为 Observer 的一个实例 MVC结构(Model/View/Control )在系统开发架构设计中有着很重要的地位和意义,实现了业务逻辑和表示层的解耦。下面示例代码以篮球...

    PipelineProcessor:通用用户可定义管道处理器

    每个节点(如上所示)表示对数据的操作,任何人都可以通过简单地实现一个接口并将生成的dll放入文件夹中来进行操作。 数据“流经”节点的输入和输出,直到到达将其写入磁盘的末尾(或输出节点确定的任何数据)。有...

    软件设计模式实验2结构型模式源码

    享元模式:在天猫商城里存在着成天上万的网店,但是天猫所提供的网站模板是一样的,存在许多天猫网店使用同一个网店模板的情况,如果每一个网店都用一个网店对象来表示,因为网店数量巨大,我们需求很

    表示层设计模式:在ASP.NET中实现PageController

    本页内容上下文实现策略测试考虑事项结果上下文相关模式 上下文您要在ASP.NET中构建Web应用程序,您希望通过使用内置的PageController(页面控制器)来利用ASP.NET的事件驱动特性。返回页首 实现策略默认情况下,...

    实用J2EE设计模式编程指南

    第2章 Web层设计模式 表示模式 案例:宾馆订房管理系统 标识模式 小结 第3章 持久性框架设计模式 开始模型 何谓持久性框架 TitleDAO会话Bean Value Object模式 Service Locator模式 使用持久性框架 持久性框架...

    接口描述-表示层-控制层-数据调度器-数据层1

    表示层Browse:浏览本地文件导入:将选择的文件传输至控制层开始转换:触发控制层中的translation控制层Home:展示主页面import_backgr

    251.JRT 0066.3-2019《银行间市场业务数据交换协议 第3部分:适流表示层》.rar

    251.JRT 0066.3-2019《银行间市场业务数据交换协议 第3部分:适流表示层》 251.JRT 0066.3-2019《银行间市场业务数据交换协议 第3部分:适流表示层》

    三层结构示例项目源码VS2005版201261

    该项目是一个基于接口的工厂模式的三层架构示例解决方案,数据库是(SQL2000) 本软件导航菜单使用了微软的iewebcontrols控件,如果不能显示树菜单链接,请安装该控件。 如果win2003系统,还需要将IE的Internet选项...

    12种常用设计模式C#代码示例

    10,迭代器模式:提供一种方法,顺序访问一个聚合对象中的各个元素,而又不暴露其内部的表示。 11,组合模式:允许你将对象组合成树形结构来表现“整体/部分”层次结构。组合能让客户以一致的方式处理个别对象已经...

    JobProcessor:用于编排执行的作业处理器和任务框架

    该项目是开放的以供发表意见/建议/建议作业处理器是一种类似于工作流来表示流程的方式。 作业处理器中的所有内容均来自TaskNode。 总体轮廓是创建一个请求以启动该过程。 然后,流程创建一个执行上下文,该上下文在...

    敏捷软件开发:原则、模式与实践.pdf

    第二十五章 ABSTRACT SERVER模式、ADAPTER模式和BRIDGE模式 第二十六章 PROXY模式和STAIRWAY TO HEAVEN模式:管理第三方API 第二十七章 案例研究:气象站 第Ⅵ部分 ETS案例研究 第二十八章 VISITOR模式 第二十九章 ...

Global site tag (gtag.js) - Google Analytics