基于MVC插件模式构建支持数据库集群、数据实时同步、数据发布与订阅的Web框架系统。如下图:

  1、基于插件式开发

     采用插件模式开发的优点是使得系统框架和业务模式有效地进行分离,系统更新也比较简单,只需更新业务插件,不需要动整个框架,开发人员无需关心整个框架结构。

但插件模式调试稍微麻烦一点,比不采用插件模式开发的效率上也要差一点,因为它采用反射进行动态加载插件。

登录插件示例:

namespace LoginPlugin
{
public class Plugin : NetUML.Portal.Framework.AbstractPlugin
{ public Plugin()
{ this.Title = "系统登录";
this.Description = "登录插件";
} public override string Name
{
get { return "LoginPlugin"; }
set { }
} public override int StartLevel
{
get { return ; }
set { }
} public override void Start(NetUML.Portal.Framework.IBundleContext context)
{ } public override void Stop(NetUML.Portal.Framework.IBundleContext context)
{ }
public override string SymbolicName
{
set { }
get { return "System.Login"; }
} public override List<NetUML.Portal.Framework.MenuItem> MenuItems
{
get { return null; }
} public override NetUML.Portal.Framework.PluginType PluginType
{
get
{
return NetUML.Portal.Framework.PluginType.Login;
}
} public override string Title
{
get;
set;
} public override string Description
{
get;
set;
}
}
}

    所有插件必须实现 NetUML.Portal.Framework.AbstractPlugin 这个插件抽象类。

         当加载插件的时候会执行Start方法,停止插件的时候会执行Stop方法。

  2、数据库引擎

     数据库引擎NetUML.DataEngine类,采用IBatisNet底层访问数据库原理,动态创建IDbConnection连接池,核心代码如下

 namespace NetUML.DataEngine
{
public class DbSession : MarshalByRefObject, IDalSession
{ #region Fields
private IDataSource _dataSource = null;
private bool _isTransactionOpen = false;
private bool _consistent = false;
private IDbConnection _connection = null;
private IDbTransaction _transaction = null;
#endregion
public DbSession(IDataSource dataSource)
{
_dataSource = dataSource;
}
public IDataSource DataSource
{
get { return _dataSource; }
} public System.Data.IDbConnection Connection
{
get { return _connection; }
} public System.Data.IDbTransaction Transaction
{
get { return _transaction; }
} public bool IsTransactionStart
{
get { return _isTransactionOpen; }
}
private bool Consistent
{
set { _consistent = value; }
}
public void Complete()
{
this.Consistent = true;
} public void OpenConnection()
{
this.OpenConnection(_dataSource.ConnectionString);
}
public void OpenConnection(string connectionString)
{
if (_connection == null)
{
CreateConnection(connectionString);
try
{
_connection.Open();
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description));
//}
}
catch (Exception ex)
{
//DataMapperException
throw new Exception(string.Format("Unable to open connection to \"{0}\".", _dataSource.DbProvider.Description), ex);
}
}
else if (_connection.State != ConnectionState.Open)
{
try
{
_connection.Open();
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug(string.Format("Open Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description));
//}
}
catch (Exception ex)
{
throw new Exception(string.Format("Unable to open connection to \"{0}\".", _dataSource.DbProvider.Description), ex);
}
}
}
public void CreateConnection()
{
CreateConnection(_dataSource.ConnectionString);
}
/// <summary>
/// Create the connection
/// </summary>
public void CreateConnection(string connectionString)
{
_connection = _dataSource.DbProvider.CreateConnection();
_connection.ConnectionString = connectionString;
} public void CloseConnection()
{
if ((_connection != null) && (_connection.State != ConnectionState.Closed))
{
_connection.Close();
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug(string.Format("Close Connection \"{0}\" to \"{1}\".", _connection.GetHashCode().ToString(), _dataSource.DbProvider.Description));
//}
_connection.Dispose();
}
_connection = null;
} public void BeginTransaction()
{
this.BeginTransaction(_dataSource.ConnectionString);
} public void BeginTransaction(string connectionString)
{
if (_connection == null || _connection.State != ConnectionState.Open)
{
this.OpenConnection(connectionString);
}
_transaction = _connection.BeginTransaction();
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("Begin Transaction.");
//}
_isTransactionOpen = true;
}
public void BeginTransaction(bool openConnection)
{
if (openConnection)
{
this.BeginTransaction();
}
else
{
if (_connection == null || _connection.State != ConnectionState.Open)
{
this.OpenConnection();
}
_transaction = _connection.BeginTransaction();
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("Begin Transaction.");
//}
_isTransactionOpen = true;
}
}
public void BeginTransaction(System.Data.IsolationLevel isolationLevel)
{
this.BeginTransaction(_dataSource.ConnectionString, isolationLevel);
}
public void BeginTransaction(string connectionString, System.Data.IsolationLevel isolationLevel)
{
if (_connection == null || _connection.State != ConnectionState.Open)
{
this.OpenConnection(connectionString);
}
_transaction = _connection.BeginTransaction(isolationLevel);
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("Begin Transaction.");
//}
_isTransactionOpen = true;
}
public void BeginTransaction(bool openConnection, System.Data.IsolationLevel isolationLevel)
{
this.BeginTransaction(_dataSource.ConnectionString, openConnection, isolationLevel);
}
public void BeginTransaction(string connectionString, bool openConnection, System.Data.IsolationLevel isolationLevel)
{
if (openConnection)
{
this.BeginTransaction(connectionString, isolationLevel);
}
else
{
if (_connection == null || _connection.State != ConnectionState.Open)
{
//DataMapperException
throw new Exception("SqlMapSession could not invoke StartTransaction(). A Connection must be started. Call OpenConnection() first.");
}
_transaction = _connection.BeginTransaction(isolationLevel);
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("Begin Transaction.");
//}
_isTransactionOpen = true;
}
}
public void CommitTransaction()
{
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("Commit Transaction.");
//}
_transaction.Commit();
_transaction.Dispose();
_transaction = null;
_isTransactionOpen = false; if (_connection.State != ConnectionState.Closed)
{
this.CloseConnection();
}
} public void CommitTransaction(bool closeConnection)
{
if (closeConnection)
{
this.CommitTransaction();
}
else
{
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("Commit Transaction.");
//}
_transaction.Commit();
_transaction.Dispose();
_transaction = null;
_isTransactionOpen = false;
}
} public void RollBackTransaction()
{
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("RollBack Transaction.");
//}
_transaction.Rollback();
_transaction.Dispose();
_transaction = null;
_isTransactionOpen = false;
if (_connection.State != ConnectionState.Closed)
{
this.CloseConnection();
}
} public void RollBackTransaction(bool closeConnection)
{
if (closeConnection)
{
this.RollBackTransaction();
}
else
{
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("RollBack Transaction.");
//}
_transaction.Rollback();
_transaction.Dispose();
_transaction = null;
_isTransactionOpen = false;
}
} public IDbCommand CreateCommand(CommandType commandType)
{
IDbCommand command = _dataSource.DbProvider.CreateCommand();
command.CommandType = commandType;
command.Connection = _connection;
if (_transaction != null)
{
try
{
command.Transaction = _transaction;
}
catch
{ }
}
if (_connection != null)
{
try
{
command.CommandTimeout = _connection.ConnectionTimeout;
}
catch (NotSupportedException e)
{
//if (_logger.IsInfoEnabled)
//{
// _logger.Info(e.Message);
//}
}
}
return command;
} public System.Data.IDbDataParameter CreateDataParameter()
{
return _dataSource.DbProvider.CreateDataParameter();
}
public System.Data.IDbDataAdapter CreateDataAdapter()
{
return _dataSource.DbProvider.CreateDataAdapter();
}
public System.Data.IDbDataAdapter CreateDataAdapter(System.Data.IDbCommand command)
{
IDbDataAdapter dataAdapter = null;
dataAdapter = _dataSource.DbProvider.CreateDataAdapter();
dataAdapter.SelectCommand = command;
return dataAdapter;
}
public void Dispose()
{
//if (_logger.IsDebugEnabled)
//{
// _logger.Debug("Dispose SqlMapSession");
//}
if (_isTransactionOpen == false)
{
if (_connection.State != ConnectionState.Closed)
{
this.CloseConnection();
}
}
else
{
if (_consistent)
{
this.CommitTransaction();
_isTransactionOpen = false;
}
else
{
if (_connection.State != ConnectionState.Closed)
{
this.RollBackTransaction();
_isTransactionOpen = false;
}
}
}
}
}
}

程序结构如下图:

  3、数据库集群服务

     NetUML.DataEngine支持多数据库连接,主持数据库读写分离操作,哪些数据表需要读写分离可以进行相应的配置和管理,类似于MVC中的路由概念,咱们可以配置多条路由表,路由表内容包括数

据表名,数据对象关键词以及数据库信息,用户保存数据的时候,系统根据要保存的数据表以及数据对象去寻找路由,再根据路由中的配置信息进行提交到数据库。

进在开发中。。。。。。。。

  4、数据同步、发布和订阅服务

     如果第三方系统接入当前系统当中来,当前系统中的数据发生变化,需要立马通知接入进来的系统,把变化的数据提交给第三方系统,第三方系统接入到数据进行相应的处理。

     第三方系统只需要提供给当前系统一个URL地址,当前系统把数据POST到URL地址。

进在开发中。。。。。。。。

  5、插件管理

系统框架支持上传插件包,不需要到服务器进行更新程序,上传完插件包之后,系统自动把插件包解压出来,进行动态编译加载插件。

系统框架也支持停止和卸载插件。如下图:

  6、海量文档资料+全文搜索插件

    文档管理插件支持office等文档在线浏览以及文件转换,把文档转换成HTML文件,支持全文解析和全文搜索功能

进在开发中。。。。。。。。

  7、微信公共帐号订制插件

进在开发中。。。。。。。。

  8、待续.....

  

构建高性能插件式Web框架的更多相关文章

  1. 插件式Web框架

    转载构建高性能插件式Web框架 基于MVC插件模式构建支持数据库集群.数据实时同步.数据发布与订阅的Web框架系统.如下图: 1.基于插件式开发 采用插件模式开发的优点是使得系统框架和业务模式有效地进 ...

  2. Asp.net MVC 插件式应用框架

    Asp.net MVC 插件式应用框架 2013年05月13日 10:16供稿中心: 互联网运营部 摘要:这几年来做了很多个网站系统,一直坚持使用asp.net mvc建站,每次都从头开始做Layou ...

  3. (1)从底层设计,探讨插件式GIS框架的实现

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 研一时,听当时的师兄推荐,买了蒋波涛的一本关于GIS插件框架的书.当时 ...

  4. 用Inferno代替React开发高性能响应式WEB应用

    什么是Inferno Inferno可以看做是React的另一个精简.高性能实现.它的使用方式跟React基本相同,无论是JSX语法.组件的建立.组件的生命周期,还是与Redux或Mobx的配合.路由 ...

  5. python三大web框架Django,Flask,Flask,Python几种主流框架,13个Python web框架比较,2018年Python web五大主流框架

    Python几种主流框架 从GitHub中整理出的15个最受欢迎的Python开源框架.这些框架包括事件I/O,OLAP,Web开发,高性能网络通信,测试,爬虫等. Django: Python We ...

  6. JAVA web 框架集合

    “框架”犹如滔滔江水连绵不绝, 知道有它就好,先掌握自己工作和主流的框架: 在研究好用和新框架. 主流框架教程分享在Java帮帮-免费资源网 其他教程需要时间制作,会陆续分享!!! 152款框架,你还 ...

  7. Django,Flask,Tornado三大框架对比,Python几种主流框架,13个Python web框架比较,2018年Python web五大主流框架

    Django 与 Tornado 各自的优缺点Django优点: 大和全(重量级框架)自带orm,template,view 需要的功能也可以去找第三方的app注重高效开发全自动化的管理后台(只需要使 ...

  8. Python 常用Web框架的比较

    转载来自:https://www.cnblogs.com/sunshine-1/p/7372934.html 从GitHub中整理出的15个最受欢迎的Python开源框架.这些框架包括事件I/O,OL ...

  9. 蜗牛历险记(二) Web框架(上)

    接上篇所说,本篇主要内容是讲述如何使用Autofac来管理整个平台的生命周期(初级). 一.简述 插件式Web开发的同学应该还会记得PreApplicationStartMethod这个Assembl ...

随机推荐

  1. 2.在centos7虚拟机搭建nginx网站

    1.nginx配置目录 cd /etc/nginx/conf.d/ 添加 vi www.18cat.conf server{ listen 80; server_name www.18cat.com; ...

  2. 今日工作总结:jquery轮转效果的集成与前台页面banner的设计思路总结

    今日做了两个项目中的两个问题,现在特来总结一下,以便分享给更多的朋友们. 1.jquery轮转效果的集成 涉及到jquery的不同版本问题,解决办法是在后缀用jQuery代替$.项目地址在:121.4 ...

  3. PIE SDK栅格拉伸渲染

    1. 功能简介 栅格数据拉伸渲染是对指定的波段进行图像拉伸,并设置拉伸之后的颜色带,根据像元值和颜色带进行数据渲染. 2. 功能实现说明 2.1. 实现思路及原理说明 第一步 实例化拉伸渲染对象示例 ...

  4. 《The Python Standard Library》——http模块阅读笔记2

    http.server是用来构建HTTP服务器(web服务器)的模块,定义了许多相关的类. 创建及运行服务器的代码一般为: def run(server_class=HTTPServer, handl ...

  5. linux 期中架构之 nginx 安装与排错

    1, 安装 nginx 所需要的pcre库 即:perl 兼容正则表达式 yum install pcre pcre-devel -y rpm -qa pcre pcre-devel 检查是否安装好p ...

  6. 引导篇之web结构组件

    web结构组件有如下几种: 代理 HTTP代理服务器,是Web安全.应用集成以及性能优化的重要组成模块.代理位于客户端和服务器之间,接收所有客户端的HTTP请求,并将这些请求转发给服务器(可能会对请求 ...

  7. os.popen('python hello_out.py')中Python程序执行时默认的当前路径为MS-DOS CMD的默认路径

    >>> import os >>> os.getcwd() 'D:\\pythonCode\\pp4e' >>> os.chdir('Stream ...

  8. zookeeper简单命令

    bin/zkCli.sh -server ls / create /zk_test my_data get /zk_test set /zk_test admln delete /zk_test ad ...

  9. word 快捷键

    Ctrl+shift+F9  清除word文档中的超链接

  10. Nmap原理02 - 版本探测介绍(上)

    Nmap原理02 - 版本探测介绍(上) 1.介绍 本文将介绍如何通过修改或添加nmap-service-probes文件来实现对nmap中未知服务的探测,首先介绍服务和版本探测的相关信息,然后介绍服 ...