拦截过滤器模式

拦截过滤器模式

来源:http://corej2eepatterns.com/I...

问题需求

需要在一次请求处理的之前或之后进行拦截处理请求和响应

  • 集中统一校验数据编码、记录请求信息、压缩响应信息等
  • 松耦合处理额外的添加和删除
  • 希望预处理和后处理相互独立,也能整合复用

解决方案

使用一个可插拔的过滤器可以预处理和后处理请求和响应

一个过滤管理器可以在链路、委派控制中松耦合的整合多个过滤器并恰当的过滤

用这种方式可以添加、删除、组合多个过滤器不需要改变已经存在的代码

策略

  • 标准过滤策略
  • 自定义过滤策略
  • 基础过滤策略
  • 模版过滤策略
  • web服务消息处理策略

    • 自定义SOAP过滤策略
    • JAX RPC 过滤策略

结论

  • 集中控制和松耦合处理
  • 提升可复用性
  • 声明式与灵活的配置
  • 低效信息共享

相关模式

  • 前端控制模式

    The controller solves some similar problems, but is better suited to handling core processing.

  • 装饰器模式

    The Intercepting Filter is related to the Decorator, which provides for dynamically pluggable wrappers.

  • 模版方法

    The Template Method is used to implement the Template Filter strategy

  • 拦截器模式

    The Intercepting Filter is related to the Interceptor, which allows services to be added transparently and triggered automatically

  • 管道过滤器模式

    The Intercepting Filter is related to Pipes and Filters.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值