`

集成层模式:Service Activator—服务激发器模式

阅读更多

Context
Enterprise beans and other business services need a way to be activated
asynchronously.
Problem
When a client needs to access an enterprise bean, it first looks up the bean's home
object. The client requests the Enterprise JavaBeans (EJB) component's home to provide a
remote reference to the required enterprise bean. The client then invokes business method
calls on the remote reference to access the enterprise bean services. All these method calls,
such as lookup and remote method calls, are synchronous. The client has to wait until these
methods return.
Another factor to consider is the life cycle of an enterprise bean. The EJB
specification permits the container to passivate an enterprise bean to secondary storage. As
a result, the EJB container has no mechanism by which it can provide a process-like service
to keep an enterprise bean constantly in an activated and ready state. Because the client
must interact with the enterprise bean using the bean's remote interface, even if the bean is
in an activated state in the container, the client still needs to obtain its remote interface via
the lookup process and still interacts with the bean in a synchronous manner.
If an application needs synchronous processing for its server-side business
components, then enterprise beans are an appropriate choice. Some application clients may
require asynchronous processing for the server-side business objects because the clients do
not need to wait or do not have the time to wait for the processing to complete. In cases
where the application needs a form of asynchronous processing, enterprise beans do not
offer this capability in implementations prior to the EJB 2.0 specification.
The EJB 2.0 specification provides integration by introducing message-driven bean,
which is a special type of stateless session bean that offers asynchronous invocation
capabilities. However, the new specification does not offer asynchronous invocation for
other types of enterprise beans, such as stateful or entity beans.
In general, a business service such as a session or entity bean provides only
synchronous processing and thus presents a challenge to implementing asynchronous
processing.
Forces
Enterprise beans are exposed to their clients via their remote interfaces, which allow
only synchronous access.
The container manages enterprise beans, allowing interactions only via the remote
references. The EJB container does not allow direct access to the bean implementation and
its methods. Thus, implementing the JMS message listener in an enterprise bean is not
feasible, since this violates the EJB specification by permitting direct access to the bean
implementation.
An application needs to provide a publish/subscribe or point-to-point messaging
framework where clients can publish requests to enterprise beans for asynchronous
processing.
Clients need asynchronous processing capabilities from the enterprise beans and
other business components that can only provide synchronous access, so that the client can
send a request for processing without waiting for the results.
Clients want to use the message-oriented middleware (MOM) interfaces offered by
the Java Messaging Service (JMS). These interfaces are not integrated into EJB server
products that are based on the pre-EJB 2.0 specification.
An application needs to provide daemon-like service so that an enterprise bean can be
in a quiet mode until an event (or a message) triggers its activity.
Enterprise beans are subject to the container life cycle management, which includes
passivation due to time-outs, inactivity and resource management. The client will have to
invoke on an enterprise bean to activate it again.
The EJB 2.0 specification introduces a message-driven bean as a stateless session
bean, but it is not possible to invoke other types of enterprise beans asynchronously.
Solution
Use a Service Activator to receive asynchronous client requests and messages. On
receiving a message, the Service Activator locates and invokes the necessary business
methods on the business service components to fulfill the request asynchronously.
The ServiceActivator is a JMS Listener and delegation service that requires
implementing the JMS message listener-making it a JMS listener object that can listen to
JMS messages. The ServiceActivator can be implemented as a standalone service. Clients
act as the message generator, generating events based on their activity.
Any client that needs to asynchronously invoke a business service, such as an
enterprise bean, may create and send a message to the Service Activator. The Service
Activator receives the message and parses it to interpret the client request. Once the client's
request is parsed or unmarshalled, the Service Activator identifies and locates the necessary
business service component and invokes business methods to complete processing of the
client's request asynchronously.
The Service Activator may optionally send an acknowledgement to the client after
successfully completing the request processing. The Service Activator may also notify the
client or other services on failure events if it fails to complete the asynchronous request
processing.
The Service Activator may use the services of a Service Locator to locate a business
component. See "Service Locator" on page 368.

分享到:
评论

相关推荐

    Core j2ee Patterns Best Practices And Design Strategies

    - 集成层模式:Data Access Object、Service Activator等。 这些模式各自代表了解决特定问题的通用解决方案,并且在J2EE应用开发中被广泛采用。 此外,书籍的后记部分强调了设计模式的价值,将其比喻为开发过程中...

    activator 越狱后必装

    6. **功能扩展**:除了基本的手势操作,Activator还可以与其他越狱插件集成,实现更多高级功能,例如控制音乐播放、开关Wi-Fi、调整屏幕亮度等。 7. **安全风险**:虽然Activator提供了许多便利,但越狱行为本身可能...

    UnlockEvents:为 Activator 添加解锁事件

    为 Activator 添加解锁事件 激活器事件示例 该软件添加了3个事件: 解锁取消。 解锁失败。 解锁成功。 不是我写的代码有源代码链接。 如果我侵犯了您的版权,请告诉我,以便我解决。 许可证:我不确定是哪一个...

    模拟spring依赖注入

    在Spring框架中,依赖注入(Dependency Injection,简称DI)是一种重要的设计模式,它极大地提高了代码的可测试性和可维护性。模拟Spring的依赖注入,旨在理解其核心机制,让我们一起深入探讨这一主题。 首先,我们...

    C#设计模式-整理收藏(吕震宇 设计模式速成经典示例)

    结构型模式包括适配器模式、装饰器模式、代理模式、桥接模式、组合模式、外观模式和享元模式,它们关注如何组合和构建对象,以实现更复杂的结构。行为型模式如观察者模式、命令模式、策略模式、模板方法模式、访问者...

    Java™ 2 平台高级核心模式, 企业版(J2EE™) 模式和重构

    - 服务激活器(Service Activator):响应消息队列。 - 域存储(Domain Store):持久化业务对象。 - Web服务代理(Web Service Proxy):调用Web服务。 - **综合层**:处理跨层的问题。 - 微体系结构(Micro-...

    C#设计模式

    - 工厂模式:定义一个用于创建对象的接口,让子类决定实例化哪一个类,如.NET框架中的Activator类。 - 抽象工厂模式:提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们的具体类,这在多平台环境下尤其...

    QuickPhil:使用 Activator 播放一系列歌曲!

    快拍使用 Activator 播放一系列歌曲! 这是目前正在进行的工作。 我不是音乐播放器好,所以我的希望,人们知道的音乐... ##去做: 修复更改随机播放模式并再次调用侦听器时崩溃的问题。 其他的我现在想不起来了。

    .NET设计模式系列文章

    .NET设计模式系列文章是一份详尽的资源,涵盖了软件开发中的23种经典设计模式,这些模式在.NET框架中有着广泛的应用。设计模式是解决软件设计中常见问题的经验总结,它们提供了一种标准的解决方案,使得开发者能够用...

    通过remoting和Activator远程连接服务器并调用方法

    在这个场景中,我们将关注如何在C# WinForms应用中利用Remoting和Activator来实现远程连接到服务器,并调用服务器上的方法。 首先,我们要理解Remoting的基本概念。在.NET Remoting中,服务器端的对象称为"服务器...

    DoulCI iCloud Activator V2.5

    《DoulCI iCloud Activator V2.5:解锁与激活苹果设备的新技术解析》 DoulCI iCloud Activator V2.5是一款针对苹果设备iCloud激活锁的专业工具,旨在帮助用户绕过或解除iOS设备上的iCloud账户锁定,以便重新激活和...

    Embarcadero.Delphi.XE7.Activator.v10.1

    为了便于在 Lite 10.x 中使用大侠们的特别补丁,初步写成这个:Activator.exe 他的主要作用: 1、整合 CrackerJack 的特别补丁、sn 等 相对原始部署方式,这个 Activator 实现“一键激活”! 使用方法: 1、...

    C#設計模式

    3. 行为型模式:关注对象之间的通信和职责分配,如策略模式(Strategy)、模板方法模式(Template Method)、观察者模式(Observer)、责任链模式(Chain of Responsibility)、命令模式(Command)、解释器模式...

    delphi activator

    《Delphi Activator:提升Delphi开发效率的秘密武器》 Delphi Activator,作为一个专为Delphi开发者设计的工具,它的出现无疑为编程工作带来了极大的便利。Delphi,这款由Embarcadero Technologies开发的集成开发...

    Delphi XE6 Update 1 Activator Ver 9.1 lsuper

    Delphi XE6 Update1 Activator Ver 9.1 lsuper ## 針對 Delphi XE6 Update1 製作的 Activator Ver 9.1 From lsuper 为了便于在 Lite 9.x 中使用 unis 大侠的特别补丁,初步写成这个:Activator.exe 他的主要作用...

    DoulCi Activator

    《DoulCi Activator:绕过iCloud激活的利器》 在iOS设备的世界里,iCloud作为苹果公司的云端服务,为用户提供了数据备份、查找我的iPhone等功能,但也因其严格的设备激活策略,有时会成为用户面临的问题。特别是当...

    keys for doulci activator

    关于doulci activator 4.0版本的keys, doulci activator 的keys需要花钱买,此文档总结了好几条买来的keys .

    lsuper_Embarcadero.Delphi.XE2.Activator.v5.6_delphixe2activator_

    delphi xe2 activator

    Doulci_Activator.exe

    Doulci_Activator.exe Doulci_Activator.exe Doulci_Activator.exe

    DoulCi Activator_2

    【DoulCi Activator_2】是一个针对苹果设备的解锁工具,主要被用户用来激活未授权的iOS设备,如iPhone或iPad。这个工具的名字“DoulCi”是“Digital Unlock by iCloud”的缩写,意为通过iCloud进行数字解锁。然而,...

Global site tag (gtag.js) - Google Analytics