构建高性能插件式Web框架
基于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框架的更多相关文章
- 插件式Web框架
转载构建高性能插件式Web框架 基于MVC插件模式构建支持数据库集群.数据实时同步.数据发布与订阅的Web框架系统.如下图: 1.基于插件式开发 采用插件模式开发的优点是使得系统框架和业务模式有效地进 ...
- Asp.net MVC 插件式应用框架
Asp.net MVC 插件式应用框架 2013年05月13日 10:16供稿中心: 互联网运营部 摘要:这几年来做了很多个网站系统,一直坚持使用asp.net mvc建站,每次都从头开始做Layou ...
- (1)从底层设计,探讨插件式GIS框架的实现
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 研一时,听当时的师兄推荐,买了蒋波涛的一本关于GIS插件框架的书.当时 ...
- 用Inferno代替React开发高性能响应式WEB应用
什么是Inferno Inferno可以看做是React的另一个精简.高性能实现.它的使用方式跟React基本相同,无论是JSX语法.组件的建立.组件的生命周期,还是与Redux或Mobx的配合.路由 ...
- python三大web框架Django,Flask,Flask,Python几种主流框架,13个Python web框架比较,2018年Python web五大主流框架
Python几种主流框架 从GitHub中整理出的15个最受欢迎的Python开源框架.这些框架包括事件I/O,OLAP,Web开发,高性能网络通信,测试,爬虫等. Django: Python We ...
- JAVA web 框架集合
“框架”犹如滔滔江水连绵不绝, 知道有它就好,先掌握自己工作和主流的框架: 在研究好用和新框架. 主流框架教程分享在Java帮帮-免费资源网 其他教程需要时间制作,会陆续分享!!! 152款框架,你还 ...
- Django,Flask,Tornado三大框架对比,Python几种主流框架,13个Python web框架比较,2018年Python web五大主流框架
Django 与 Tornado 各自的优缺点Django优点: 大和全(重量级框架)自带orm,template,view 需要的功能也可以去找第三方的app注重高效开发全自动化的管理后台(只需要使 ...
- Python 常用Web框架的比较
转载来自:https://www.cnblogs.com/sunshine-1/p/7372934.html 从GitHub中整理出的15个最受欢迎的Python开源框架.这些框架包括事件I/O,OL ...
- 蜗牛历险记(二) Web框架(上)
接上篇所说,本篇主要内容是讲述如何使用Autofac来管理整个平台的生命周期(初级). 一.简述 插件式Web开发的同学应该还会记得PreApplicationStartMethod这个Assembl ...
随机推荐
- D. Diverse Garland-----CF字符串
D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- web服务器架构演化及所其技术知识体系(分布式的由来)
文章标题是我自己取的,内容来着百度百科k5665219的一篇回答,觉得讲的很不错就转载过来了. 最开始,由于某些想法,于是在互联网上搭建了一个网站,这个时候甚至有可能主机都是租借的,但由于这篇文章我们 ...
- Python+Selenium之通过batch跑脚本
例如在执行路径C:\Portal_Scripts\Scripts下的脚本CreateIndicativeBOP.py,可以在notepad里面编写如下: @echo off cd C:\Portal ...
- 三大视频网站Url的处理保存(视频和图片二选一操作)
前台Js // 视频处理 var textVideoLink=$("input[name='textVideoLink']").val(); // 去除所有有的引号和空格 var ...
- Android IntentFilter 匹配原则浅析
1 Intent分为两大类,显式和隐式. 显式事件,就是指通过 component Name 属性,明确指定了目标组件的事件. 比如我们新建一个Intent,指名道姓的说,此事件用于启动名为" ...
- 牛客网Java刷题知识点之UDP协议是否支持HTTP和HTTPS协议?为什么?TCP协议支持吗?
不多说,直接上干货! 福利 => 每天都推送 欢迎大家,关注微信扫码并加入我的4个微信公众号: 大数据躺过的坑 Java从入门到架构师 人工智能躺过的坑 ...
- 【Unity&独立游戏&音效】免费音效网站总览
转载 http://blog.csdn.net/BuladeMian/article/details/70240868
- WPF 窗体在Alt+Tab中隐藏
问题: 近段时间由于项目上的需求,需要在WPF中使用COM组件,并且由于软件界面设计等等原因,需要将部分控件显示在COM组件之上,由于WindowsFormsHost的一些原因,导致继承在WPF中的W ...
- 用Gvim建立IDE编程环境 (Windows篇)
转自:http://my.oschina.net/kontor/blog/50717 0.准备软件及插件.(a)gvim72.exe 地址ftp://ftp.vim.org/pub/vim/pc/gv ...
- 深入理解JavaScript系列(16):闭包(Closures)
介绍 本章我们将介绍在JavaScript里大家经常来讨论的话题 —— 闭包(closure).闭包其实大家都已经谈烂了.尽管如此,这里还是要试着从理论角度来讨论下闭包,看看ECMAScript中的闭 ...