Agile framework function introduction (2): Framework event model

Source: Internet
Author: User

The previous section briefly introduced the event auto-connection feature of agile framework. This section describes the implementation principles of the event feature in detail.

In the agile framework, you only need to mark eventpublisher and eventsubscriber for the components separately to automatically connect to each other and completely decouple events. This function is similar to the eventwiringfacility function of the castle container (the same event mechanism is also available in the composite UI Application Block ). However, unlike the containers, Castle and cab only support the interconnection of events in the same container. The container of agile framework is distributed, and client and server components can be added to the container. Therefore, the event transfer mechanism of agile framework is also distributed. Simply put, events defined in the service components of the server can also be received by client components.

To implement this function, you must first solve a problem: Agile framework supports both web service and remoting data transmission interfaces (you only need to modify the configuration in the configuration file, what types of transmission interfaces are used by the Framework is completely transparent to developers). Therefore, the event transfer mechanism must support both interfaces at the same time. Remoting is a better solution, because remoting itself supports remote event mechanisms. However, the Web Service is troublesome. It only supports the stateless access model of simple requests/responses and cannot actively send messages to the client.

The event dispatch mechanism used by agile framework perfectly solves this problem. The following is the event model diagram of the framework:

In the entire structure, event dispather is the transfer station for all events. It subscribes to all events in the system and knows the receiver of each event.

The event transfer mechanism is described as follows:

When event dispatcher receives a triggered event, it checks the event subscription list and distributes the event to each receiver one by one, depending on the location of the event receiver, the following situations may occur:

    1. If the event receiver is inside the container, event dispatcher directly sends the event to the receiver.
    2. If the event receiver is on the Smart Client and the interface is remoting, event dispatcher calls the remoting remote interface to send the event to the client.
    3. If the event receiver is in the Smart Client and the interface is Web Service, event dispatcher will send the event to an object called event holder, this object is responsible for receiving and saving all the events sent to the client. In the client framework, an object called event detector regularly performs polling through web service to check events in eventholder. If an event is sent to the client, it accepts the event data and forwards it to the client's event receiving method.
    4. If the event receiver is a Web page, an Ajax object with a function similar to event detector in Agile framework also polls event holder. Therefore, events defined by business components in Agile framework can also be received by web page objects.

These are the basic principles of the agile framework event distribution mechanism. Agile framework is an open-source middleware platform based on. NET 2.0 technology. It is currently under development. For more information, visit the agile lab.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.