Context
The presentation-tier request handling mechanism receives many different types of
requests, which require varied types of processing. Some requests are simply forwarded to
the appropriate handler component, while other requests must be modified, audited, or
uncompressed before being further processed.
Problem
Preprocessing and post-processing of a client Web request and response are required.
When a request enters a Web application, it often must pass several entrance tests
prior to the main processing stage. For example,
Has the client been authenticated?
Does the client have a valid session?
Is the client's IP address from a trusted network?
Does the request path violate any constraints?
What encoding does the client use to send the data?
Do we support the browser type of the client?
Some of these checks are tests, resulting in a yes or no answer that determines
whether processing will continue. Other checks manipulate the incoming data stream into a
form suitable for processing.
The classic solution consists of a series of conditional checks, with any failed check
aborting the request. Nested if/else statements are a standard strategy, but this solution leads
to code fragility and a copy-and-paste style of programming, because the flow of the
filtering and the action of the filters is compiled into the application.
The key to solving this problem in a flexible and unobtrusive manner is to have a
simple mechanism for adding and removing processing components, in which each
component completes a specific filtering action.
Forces
Common processing, such as checking the data-encoding scheme or logging
information about each request, completes per request.
Centralization of common logic is desired.
Services should be easy to add or remove unobtrusively without affecting existing
components, so that they can be used in a variety of combinations, such as
Logging and authentication
Debugging and transformation of output for a specific client
Uncompressing and converting encoding scheme of input
Solution
Create pluggable filters to process common services in a standard manner without
requiring changes to core request processing code. The filters intercept incoming requests
and outgoing responses, allowing preprocessing and post-processing. We are able to add
and remove these filters unobtrusively, without requiring changes to our existing code.
We are able, in effect, to decorate our main processing with a variety of common
services, such as security, logging, debugging, and so forth. These filters are components
that are independent of the main application code, and they may be added or removed
declaratively. For example, a deployment configuration file may be modified to set up a
chain of filters. The same configuration file might include a mapping of specific URLs to
this filter chain. When a client requests a resource that matches this configured URL
mapping, the filters in the chain are each processed in order before the requested target
resource is invoked.
- 浏览: 14543 次
- 性别:
- 来自: 北京
文章分类
最新评论
发表评论
-
集成层模式:Service Activator—服务激发器模式
2014-04-09 20:31 1004ContextEnterprise beans and o ... -
集成层模式:Data Access Object—数据访问对象模式
2014-04-09 20:31 489ContextAccess to data varies ... -
业务层模式:Service Locator—服务定位器模式
2014-04-09 20:31 1132ContextService lookup and cre ... -
表示层模式:Value List Handler—值列表处理器模式
2014-04-09 20:32 741ContextThe client requires a ... -
表示层模式:Transfer Object Assembler—传输对象组装器模式
2014-04-10 22:48 724ContextIn a Java 2 Platform, ... -
业务层模式:Composite Entity—复合实体模式
2014-04-08 21:38 464ContextEntity beans are not i ... -
业务层模式:Session Facade—会话门面模式
2014-04-08 21:38 401ContextEnterprise beans encap ... -
业务层模式:Transfer Object—传输对象模式
2014-04-08 21:37 397ContextApplication clients ne ... -
业务层模式:Business Delegate—业务委托模式
2014-04-08 21:37 953ContextA multi-tiered, distri ... -
表示层模式:Dispatcher View—分发者视图模式
2014-04-08 21:37 513ContextSystem controls flow o ... -
表示层模式:Service to Worker—工作者服务模式
2014-04-07 10:48 953ContextThe system controls flow ... -
表示层模式:Front Controller—前端控制器模式
2014-04-07 10:45 346ContextThe presentation-tier re ... -
表示层模式:Composite View—复合视图模式
2014-04-07 10:41 458ContextSophisticated Web page ... -
表示层模式:View Helper—视图助手模式
2014-04-07 10:37 995ContextThe system creates pre ...
相关推荐
创建型模式 这些设计模式提供了一种在创建对象的同时隐藏创建逻辑的方式,而...拦截过滤器模式(Intercepting Filter Pattern) 服务定位器模式(Service Locator Pattern) 传输对象模式(Transfer Object Pattern)
本文对应于Web表示模式集群,文章的前半部分重笔墨的描述了MVC模式的架构、设计及其ASP.NET实现,而在更加复杂的...简要介绍了Web表示模式集群的另外两个模式:Intercepting Filter(筛选器)和Page Cache(页面缓存)模式
本页内容上下文问题影响因素解决方案变体示例结果上下文相关模式致谢 上下文对于任何一个曾经从头建立Web应用程序的人来说,他们都会有这样的体会:这项任务所需要的独立完成的工作量要比建立内部客户端-服务器应用...
第一部分 敏捷开发 第1章 敏捷联盟 第2章 极限编程概述 第3章 计划 第4章 测试 第5章 重构 第6章 一次编程实践 ...附录B UML表示法II:统计多路复用器 附录C 两上公司的讽刺小品 附录D 源代码就是设计 索引
用户故事: 数学家想查看内核的实时表示,进入网站,生成矩阵并获得过滤器的预览一个学生想了解图像内核,访问网站并探索不同的内核并学习东西一个人想要看到很酷的图像过滤器,来到网站并浏览不同的过滤器特征: ...
Dmhy Filter Dmhy Filter为特别为动漫花园设计的RSS过滤器,设定每笔项目的关键字后,配合crontab设定,可自制个人的RSS供各Bittorrent程式或服务订阅,达到自动下载的目的。How toFilter于目录下建立filter,如...
解释器模式:给定一个语言,定义它的文法的一种表示,并定义一个解释器。 策略模式:定义一系列算法,把他们封装起来,并且使它们可以相互替换。 状态模式:允许一个对象在其对象内部状态改变时改变它的行为。 ...
Filter中的模糊过滤: 要实现模糊过滤,BDE中要用“*”,不允许使用“Like”关键字,且只能向后匹配,如“Fcode=’101*’”;而ADO则是使用“%”或“*”都可以,可以使用“Like”关键字,且和SQL语句用法一致,可以...
组合模式作为一种强大的设计模式,通过将对象组合成树形结构,可以表示“部分-整体”的层次结构,并统一地处理单个对象和组合对象,简化了客户端代码的复杂性,从而提高代码的灵活性和可扩展性。在实际开发中,它在...
网站开发的一层 二层开发完成之后,所有的页面表示层都可以用此软件来生成。这是我们开发时自己开发的软件。绝对好用。提高工作效率。
表示层Browse:浏览本地文件导入:将选择的文件传输至控制层开始转换:触发控制层中的translation控制层Home:展示主页面import_backgr
因为表示层是请求驱动的,所以“用户”可以是任意请求的发起者。控制器处理该请求。模型就是业务数据,而视图就是最终发生的应答。控制器是与请求发生联系的起点。控制器就是一个主管,首先规划要做哪些更新和要显示...
CodematicDemoF3 是一个基于工厂模式的三层架构示例项目源码,基于VS2005 SP1开发(如果没有装SP1,web项目会打不开),结构更简洁,提供更多有效的示例源码参考。方便用户更好的理解和使用该架构进行开发,配合动软...
第二步:选择IP过滤器。 第三步:填写名字。 第四步:填写通讯两端的IP地址。 问题:为什么要填写它? 设定你拦截的的数据是这两个IP的通讯数据,0.0.0.0表示任何IP。 问题:如果有多个IP使用哪一个可以表示我本机的...
迭代器(Iterator)模式:提供一种方法来顺序访问聚合对象中的一系列数据,而不暴露聚合对象的内部表示。 访问者(Visitor)模式:在不改变集合元素的前提下,为一个集合中的每个元素提供多种访问方式,即每个元素...
4.MVC Pattern:模型视图控制器模式,分离应用程序的关注点,实现高内聚、低耦合的设计。 在 Spring 中,MVC 模式是框架的核心部分,提供了一个松耦合的架构,开发者可以根据需要选择不同的视图技术和模型来实现...
中国大陆IP过滤器-Java IP文件路径: 项目的resources/china_ip目录下 使用ChinaIPRecognizer类即可 更新记录 201911月30日更新 原文链接: 概述 本篇讲解如何快速判断IPV4地址是否在大陆境内的IP地址。 中国IPV4的...
观察者模式是目前应用最广、影响范围最大的模式之一,因为 Observer 的一个实例 MVC结构(Model/View/Control )在系统开发架构设计中有着很重要的地位和意义,实现了业务逻辑和表示层的解耦。下面示例代码以篮球...
本页内容上下文实现策略测试考虑事项结果上下文相关模式 上下文您要在ASP.NET中构建Web应用程序,您希望通过使用内置的PageController(页面控制器)来利用ASP.NET的事件驱动特性。返回页首 实现策略默认情况下,...