We often explicitly create different service classes for calling different functions. This call relationship is closely dependent. In many cases, we use the factory mode for separation. the message-based application framework is refined by adopting the factory model. in actual work, developers do not need to understand the business function classes, but only need to send the corresponding function messages to the business container; after receiving the message, the Business container analyzes the message and starts to execute relevant business functions. because the message and service classes are separated and described, you can easily keep the original
Code Insert new functions. the framework also binds context objects. Transaction processing is used to solve the problem of Object Information Sharing and transactions, so that developers can focus more on business function design.
The framework consists of the following parts::
Message(IMessage)
In the Framework, a message is used to describe what needs to be done. It can be said that a message processing container refers to a message. to define a message of its own, you only need to implement the Framework.IMessage interface; The iMessage interface does not have any Members, but is used to identify messages processed by the framework.
Public class businessmessage: messages. iMessage
{
}
Message Processing container(Dispensecontainer)
Container isUsedThe container has only one entry point for receiving messages and sending them to the calling object.
Messages. dispensecontainer Container = messages. dispensecontainer. openconfig ();
Messages. iMessage MSG = container. incept (NewBusinessobjects. businessmessage ());
Description of the relationship between messages and Business Objects(Messagesectionhandler)
Framework isUse XMLThe configuration file describes the relationship between messages and Business Objects. One or more business objects can be configured for the message type.
<Message Type= "Type name,ProgramSet" Transaction= "Whether the message processing channel has the transaction function">
<Export Type= "Type name, assembly" Single= "Single instantiation"/>
...
</Message>
Context object(Messagecontext)
ContextObjectThe problem of information sharing between objects can be well solved. As long as the business object is executed in the message channel, the access permission of the object can be obtained.
Public class bobject1: messages. idispense
{
# Region idispense members
Messages. iMessage messages. idispense. Export (messages. iMessage message)
{
If (messages. messagecontext. Current. properties. Contains ("name "))
{
Messages. messagecontext. Current. properties ["name"] =
Messages. messagecontext. Current. properties ["name"] + "\ n \ r" + this. tostring ();
}
Else
{
Messages. messagecontext. Current. properties ["name"] = This. tostring ();
}
Console. Write (messages. messagecontext. Current. properties ["name"] + "\ n ");
Return new counter ();
}
# Endregion
}
Transaction Processing
Framework for message ChannelsIntegrationWith the transaction processing capability, you can set whether this type of message channel has the transaction capability in the description of the relationship between messages and Business Objects. If there is a transaction, all business objects in the channel will run in the transaction environment. transactions are provided by COM + and cannot be guaranteed for stateless calls to Business Objects (if WebService is called)
Framework class diagram description
The framework is still in the design stage, and some functions are not yet available. I 'd like to give you some comments and ideas so early.
Related examples and source code