Agile framework features (1): Automatic event connection

Source: Internet
Author: User

Use the agile Framework framework to develop enterprise applicationsProgramA large number of business components are written. These components are inserted into the framework as plug-ins, and the structure is completely decoupled. Although there should be no direct communication between each subsystem according to the SOA design concept, sometimes it may also need to communicate between components, such as with the basic subsystem or workflow component.

To maximize the decoupling between components, agile framework provides an automatic event Connection Mechanism between components (castle also provides eventwiringfacility and provides the same functionality, however, there is a serious bug: if there is a component in the system that has a publish-subscribe relationship with each other, it will lead to an endless loop ).

Using Automatic event connection in Agile framework is very simple. You only need to add the eventpublisher attribute to the published event, and then add the eventsubscriber tag to the subscription method, the framework automatically connects events with the same eventkey:

Public   Class Publisher
{
[Eventpublisher ( " Eventkey " , " Description " )]
Public   Event Eventhandler < Commoneventargs < String > Eventpublished;

Public   Void Raiseevent ( String Data)
{
If (Eventpublished ! =   Null )
Eventpublished ( This , New Commoneventargs < String > (Data ));
}
}

Public ClassSubstriber
{
Private StringRecievedargs;

[Eventsubscriber ("Eventkey")]
Public VoidEventsubstribe (ObjectSender, commoneventargs<String>ARGs)
{
Recievedargs=Args. ARGs;
}
}

In this way, when publisher triggers eventpublished, substriber will accept this event.

For more information about agile framework, visit 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.