多层系统框架
本框架已经讲解中间层请参照讲义
<a href="http://www.cnblogs.com/dksoft/category/10146.html">http://www.cnblogs.com/dksoft/category/10146.html</a>
主题:<插件式>的中间层框架 第一节
主题:<插件式>的中间层框架 第二节 |DLL的Exception你如何处理?|不同宿主内如果接口抛出异常,怎么处理
客户端框架的解决方案可以参照
EXE BPL DLL Interface Package 解决方案
<a href="http://www.2ccc.com/article.asp?articleid=1903">http://www.2ccc.com/article.asp?articleid=1903</a>
来实现插件式的框架
概述
为了解少维护成本,开发成本,重复编写代码特编写此框架。分为中间层框架,客户层框架,插件式编写各个模块。
框架即一种平台,有了这个平台才有各个模块,平台是模块运作的前提,因此各个模块必须遵守该平台内的制定规则才能在这个平台内更好的运作。本系统框架,就是要实现此功能。
中间层框架
中间层主框架,以EXE应用程序向客户端提供服务, 各业务模块 以DLL的形式向中间层提供服务。
<图1>中间层框架
中间层接口
中间层框架提供一个接口(IFrameworkService)供各业务模块使用
IFrameworkService = interface //框架提供接口
function GetFrameWorkInfo(ActionIndex: Integer; var Data, Msg: OleVariant): HResult;
end;
模块接口
业务模块必须提供两个两个接口,供中间层获取信息,进行业务逻辑处理。
IModelInfo = interface //模块基本信息接口
procedure GetModelInfo(var ModelInfo: OleVariant); stdcall;
(ModelInfo: OleVariant)必须保存如下信息以便模块管理员获取信息
procedure TModelInfo.GetModelInfo(var ModelInfo: OleVariant);
var
hash: TdkHashTools;
begin
hash := TdkHashTools.Create();
hash['Name'] := '系统模块';
hash['Code'] := 'SystemMgr';
hash['Version'] := 1.01;
hash['Programmer'] := '杨茂峰';
hash['CreateDate'] := '2004-11-12';
hash['ModifyDate'] := '2004-11-12';
hash['Notes'] := '';
hash.SaveToOleVariant(ModelInfo);
hash.Free;
end;
IModelService = interface //模块操作接口
function Opeartor(ActionIndex: Integer; var Data, Msg: OleVariant): HResult; stdcall;
模块输出函数
各模块(DLL)必须输出三个函数
exports
GetModelInfo, GetModelService, SetFrameWorkService;
下面是三个函数的原形
function GetModelInfo: IModelInfo; //获取模块信息接口
function GetModelService: IModelService; //获取模块服务接口
function SetFrameWorkService(AFrameworkService:
IFrameworkService): HResult; //传入框架服务接口到模块