`

业务层模式:Business Delegate—业务委托模式

阅读更多

Context
A multi-tiered, distributed system requires remote method invocations to send and
receive data across tiers. Clients are exposed to the complexity of dealing with distributed
components.
Problem
Presentation-tier components interact directly with business services. This direct
interaction exposes the underlying implementation details of the business service
application program interface (API) to the presentation tier. As a result, the presentation-tier
components are vulnerable to changes in the implementation of the business services: When
the implementation of the business services change, the exposed implementation code in the
presentation tier must change too.
Additionally, there may be a detrimental impact on network performance because
presentation-tier components that use the business service API make too many invocations
over the network. This happens when presentation-tier components use the underlying API
directly, with no client-side caching mechanism or aggregating service.
Lastly, exposing the service APIs directly to the client forces the client to deal with
the networking issues associated with the distributed nature of Enterprise JavaBeans (EJB)
technology.
Forces
Presentation-tier clients need access to business services.
Different clients, such as devices, Web clients, and thick clients, need access to
business service.
Business services APIs may change as business requirements evolve.
It is desirable to minimize coupling between presentation-tier clients and the business
service, thus hiding the underlying implementation details of the service, such as lookup
and access.
Clients may need to implement caching mechanisms for business service information.
It is desirable to reduce network traffic between client and business services.
Solution
Use a Business Delegate to reduce coupling between presentation-tier clients and
business services. The Business Delegate hides the underlying implementation details of the
business service, such as lookup and access details of the EJB architecture.
The Business Delegate acts as a client-side business abstraction; it provides an
abstraction for, and thus hides, the implementation of the business services. Using a
Business Delegate reduces the coupling between presentation-tier clients and the system's
business services. Depending on the implementation strategy, the Business Delegate may
shield clients from possible volatility in the implementation of the business service API.
Potentially, this reduces the number of changes that must be made to the presentation-tier
client code when the business service API or its underlying implementation changes.
However, interface methods in the Business Delegate may still require modification if
the underlying business service API changes. Admittedly, though, it is more likely that
changes will be made to the business service rather than to the Business Delegate.
Often, developers are skeptical when a design goal such as abstracting the business
layer causes additional upfront work in return for future gains. However, using this pattern
or its strategies results in only a small amount of additional upfront work and provides
considerable benefits. The main benefit is hiding the details of the underlying service. For
example, the client can become transparent to naming and lookup services. The Business
Delegate also handles the exceptions from the business services, such as java.rmi.Remote
exceptions, Java Messages Service (JMS) exceptions and so on. The Business Delegate may
intercept such service level exceptions and generate application level exceptions instead.
Application level exceptions are easier to handle by the clients, and may be user friendly.
The Business Delegate may also transparently perform any retry or recovery operations
necessary in the event of a service failure without exposing the client to the problem until it
is determined that the problem is not resolvable. These gains present a compelling reason to
use the pattern.
Another benefit is that the delegate may cache results and references to remote
business services. Caching can significantly improve performance, because it limits
unnecessary and potentially costly round trips over the network.
A Business Delegate uses a component called the Lookup Service. The Lookup
Service is responsible for hiding the underlying implementation details of the business
service lookup code. The Lookup Service may be written as part of the Delegate, but we
recommend that it be implemented as a separate component, as outlined in the Service
Locator pattern (See "Service Locator" on page 368.)
When the Business Delegate is used with a Session Facade, typically there is a
one-to-one relationship between the two. This one-to-one relationship exists because logic
that might have been encapsulated in a Business Delegate relating to its interaction with
multiple business services (creating a one-to-many relationship) will often be factored back
into a Session Facade.
Finally, it should be noted that this pattern could be used to reduce coupling between
other tiers, not simply the presentation and the business tiers.

分享到:
评论

相关推荐

    事件委托 event delegate

    在编程领域,事件委托(Event Delegate)是一种设计模式,它允许我们把事件处理代码与触发事件的对象解耦。这种模式在.NET框架中尤其常见,它为面向对象编程提供了灵活的事件处理机制。在这个例子中,我们将关注如何...

    [其他类别]javabean分页程序_javabean(毕设 + 课设).zip

    4. 业务委托模式:BusinessDelegate可能是用来解耦视图和数据访问层的类,它封装了对DAO的调用,使得JSP页面与数据库操作分离。 【文件详解】: 1. GoodsList_jsp.class:这是展示商品列表的JSP页面的编译后版本,...

    RIA框架Cairngorm

    Cairngorm是Abode推出的Flex RIAs框架,其实是MVC的发扬光大,它由七大部分组成。 Model(数据模型M):使用singleton(单例)模式共享变量; VO( Value Object):储存特定值对象变量。...Business(业务):定义RPC。

    Cairngorm框架学习

    为了处理服务器端的业务逻辑,命令会委托给业务代理(Business Delegate)。业务代理通过服务定位器(Service Locator)找到远程过程调用(RPC)服务,从而获取或更新数据。数据通常以值对象(Value Object)的形式...

    C#面试宝典

    2. **BLL层(Business Logic Layer)**: 负责业务逻辑处理。 3. **DAL层(Data Access Layer)**: 负责数据访问操作。 这种架构的好处在于提高了系统的可维护性和可扩展性,各层之间通过接口进行通信,降低了耦合度。 ...

    Java专业术语标准化规范表

    - **Delegate**:委托,一种设计模式,允许对象将其部分功能委托给另一个对象。 - **Dependency Injection**:依赖注入,一种设计模式,通过外部源向对象注入其依赖项,以减少对象间的耦合。 - **Deploy**:部署,...

    Mandragora-开源

    业务委托(Business Delegate)模式是一种设计模式,它在客户端和远程服务之间提供了一个抽象层。在Mandragora中,这一模式被用于创建一个中间层,负责调用实际的数据访问服务。这样,控制器只需与业务委托交互,而...

    【。net 专业】 面试题

    - Business层: 处理业务逻辑。 - DataAccess层: 处理数据存取。 #### 十三、ASP.NET实现MVC模式 - **实现方式**: 通过分离关注点,将Web层分为模型(Model)、视图(View)、控制器(Controller)三个部分。 #### 十四...

    .net评测试卷

    2. **委托声明**:C# 中声明委托的关键字是 `delegate`。 3. **三元运算符**:C# 的三元运算符是 `?:`,它是一种简洁的条件表达式。 4. **方法签名**:方法的签名包括方法的名称和参数列表。 5. **类的三大特性**:...

    asp.net面试题

    - **业务逻辑层**(Business Logic Layer): 实现应用程序的核心功能。 - **数据访问层**(Data Access Layer): 处理与数据库的交互。 各层之间通过接口进行通信,确保了松耦合的设计,易于维护和扩展。 ### 12. ...

    C#经典试题,哈

    - **业务逻辑层**(Business Logic Layer):处理业务规则和流程,执行实际的业务操作。 - **数据访问层**(Data Access Layer):负责与数据库交互,提供数据的增删改查等功能。 ### 12. 类的构造函数和虚方法的...

    java术语 it术语

    DAO 层通常位于业务逻辑层和数据层之间,它的目的是将业务逻辑与数据访问逻辑分离。 #### Data 数据是指在计算机系统中存储、处理和传输的信息。在 Java 应用程序中,数据通常以变量、数组、集合等形式存在。 ###...

Global site tag (gtag.js) - Google Analytics