Context
The system controls flow of execution and access to business data, from which it
creates presentation content.
Note
The Service to Worker pattern, like the Dispatcher View pattern, describes a common
combination of other patterns from the catalog. Both of these macro patterns describe the
combination of a controller and dispatcher with views and helpers. While describing this
common structure, they emphasize related but different usage patterns.
Problem
The problem is a combination of the problems solved by the Front Controller and
View Helper patterns in the presentation tier. There is no centralized component for
managing access control, content retrieval, or view management, and there is duplicate
control code scattered throughout various views. Additionally, business logic and
presentation formatting logic are intermingled within these views, making the system less
flexible, less reusable, and generally less resilient to change.
Intermingling business logic with view processing also reduces modularity and
provides a poor separation of roles among Web production and software development
teams.
Forces
Authentication and authorization checks are completed per request.
Scriptlet code within views should be minimized.
Business logic should be encapsulated in components other than the view.
Control flow is relatively complex and based on values from dynamic content.
View management logic is relatively sophisticated, with multiple views potentially
mapping to the same request.
Solution
Combine a controller and dispatcher with views and helpers (see "Front Controller"
on page 172 and "View Helper" on page 186) to handle client requests and prepare a
dynamic presentation as the response. Controllers delegate content retrieval to helpers,
which manage the population of the intermediate model for the view. A dispatcher is
responsible for view management and navigation and can be encapsulated either within a
controller or a separate component.
Service to Worker describes the combination of the Front Controller and View Helper
patterns with a dispatcher component.
While this pattern and the Dispatcher View pattern describe a similar structure, the
two patterns suggest a different division of labor among the components. In Service to
Worker, the controller and the dispatcher have more responsibilities.
Since the Service to Worker and Dispatcher View patterns represent a common
combination of other patterns from the catalog, each warrants its own name to promote
efficient communication among developers. Unlike the Service to Worker pattern, the
Dispatcher View pattern suggests deferring content retrieval to the time of view processing.
In the Dispatcher View pattern, the dispatcher typically plays a limited to moderate
role in view management. In the Service to Worker pattern, the dispatcher typically plays a
moderate to large role in view management.
A limited role for the dispatcher occurs when no outside resources are utilized in
order to choose the view. The information encapsulated in the request is sufficient to
determine the view to dispatch the request. For example,
http://some.server.com/servlet/Controller?next=login.jsp
The sole responsibility of the dispatcher component in this case is to dispatch to the
view login.jsp.
An example of the dispatcher playing a moderate role is the case where the client
submits a request directly to a controller with a query parameter that describes an action to
be completed:
http://some.server.com/servlet/Controller?action=login
The responsibility of the dispatcher component here is to translate the logical name
login into the resource name of an appropriate view, such as login.jsp, and dispatch to that
view. To accomplish this translation, the dispatcher may access resources such as an XML
configuration file that specifies the appropriate view to display.
On the other hand, in the Service to Worker pattern, the dispatcher might be more
sophisticated. The dispatcher may invoke a business service to determine the appropriate
view to display.
The shared structure of Service to Worker and Dispatcher View consists of a
controller working with a dispatcher, views, and helpers.
- 浏览: 15372 次
- 性别:
- 来自: 北京
文章分类
最新评论
发表评论
-
集成层模式:Service Activator—服务激发器模式
2014-04-09 20:31 1107ContextEnterprise beans and o ... -
集成层模式:Data Access Object—数据访问对象模式
2014-04-09 20:31 533ContextAccess to data varies ... -
业务层模式:Service Locator—服务定位器模式
2014-04-09 20:31 1167ContextService lookup and cre ... -
表示层模式:Value List Handler—值列表处理器模式
2014-04-09 20:32 772ContextThe client requires a ... -
表示层模式:Transfer Object Assembler—传输对象组装器模式
2014-04-10 22:48 757ContextIn a Java 2 Platform, ... -
业务层模式:Composite Entity—复合实体模式
2014-04-08 21:38 498ContextEntity beans are not i ... -
业务层模式:Session Facade—会话门面模式
2014-04-08 21:38 423ContextEnterprise beans encap ... -
业务层模式:Transfer Object—传输对象模式
2014-04-08 21:37 434ContextApplication clients ne ... -
业务层模式:Business Delegate—业务委托模式
2014-04-08 21:37 984ContextA multi-tiered, distri ... -
表示层模式:Dispatcher View—分发者视图模式
2014-04-08 21:37 543ContextSystem controls flow o ... -
表示层模式:Front Controller—前端控制器模式
2014-04-07 10:45 377ContextThe presentation-tier re ... -
表示层模式:Composite View—复合视图模式
2014-04-07 10:41 490ContextSophisticated Web page ... -
表示层模式:View Helper—视图助手模式
2014-04-07 10:37 1028ContextThe system creates pre ... -
表示层模式:Intercepting Filter—拦截过滤器模式
2014-04-07 10:29 627Context The presentati ...
相关推荐
- **服务到工作者**(Service To Worker):将任务分配给后台线程处理。 - **调度视图**(Dispatcher View):负责分发视图更新。 #### 业务层模式 - **业务代理**(Business Delegate):简化远程业务对象的调用...
- **LiveData**:是一个观察者模式的实现,用于在ViewModel和Activity之间传递数据。 - **生命周期感知**:LiveData会根据观察者的生命周期自动回调观察者,确保数据在适当的时候被更新。 **8.2 Navigation如何解决...
- PWA(渐进式Web应用):Service Worker、离线存储、Web App Manifest。 3. 计算机科学基础: - 数据结构:数组、链表、栈、队列、树(二叉树、平衡树)、图、哈希表。 - 算法:排序(冒泡、选择、插入、快速、...
Service Mesh是一个基础设施层,用于处理服务间通信。它透明地管理网络请求,并提供服务发现、负载均衡等功能。常见的实现包括Istio、Linkerd等。 **44. 描述Kubernetes Aggregated APIs。** Aggregated APIs允许...
13. 最新前端技术:面试者应关注前沿技术,如WebAssembly、Web Components、Service Worker和WebXR,这些都是现代前端开发的重要组成部分。 以上只是前端开发面试中可能涵盖的部分主题,每个话题都足够深入探讨,...
5. **Push Notifications**:通过服务工作者实现,PWA可以向用户发送即时通知,即使在应用未打开时。 6. **App Shell**:这是一种架构模式,用于预先加载和缓存应用的基本UI框架,以快速呈现核心用户体验。 7. **...
5. **Service Worker**:通过Service Worker实现离线缓存,即使在没有网络连接的情况下,用户也能访问部分网站内容。 6. **API集成**:如果网站包含应用发布功能,可能涉及到与应用商店API的交互,学习如何发送和...
在实际工作中,前端开发者需要不断跟进最新的技术趋势,例如响应式设计、Web组件、Service Worker、WebAssembly等。同时,熟悉开发工具,如IDE(集成开发环境)、包管理器(npm或yarn)、构建工具(Webpack或Gulp)...
6. PWA(Progressive Web App):了解PWA的特点,如离线工作、添加到主屏幕、推送通知等,以及如何使用Service Worker和Web App Manifest创建PWA。 7. 版本控制与Git:在软件开发中,版本控制工具如Git对于协作和...
5. **HTML5**:深入理解HTML5的新特性,如离线存储(Service Worker)、拖放API、画布(Canvas)和Web Audio API等。同时,学习Web Storage(localStorage和sessionStorage)和WebSocket实现数据持久化和实时通信。 ...
在IT行业中,框架是开发人员构建应用程序的基础结构,它们提供了预定义的规则、模式和工具,使得开发工作更加高效和规范。"framework-guides"是一个集合,旨在为开发者提供关于新框架和现有框架的指导,帮助他们更好...