- 注册
- 2002-10-12
- 消息
- 47,114
- 荣誉分数
- 2,376
- 声望点数
- 393
最近闲来无事,所以想研究以下dynamic class loading
例如我要实现一个generic database client.
支持mysql/postgresql, 在用户安装程序的时候选择使用mysql或者postgresql
private static final String[]dbtypes = {"test.db.servers.MySQL.MySQL","test.db.servers.PostgreSQL.PostgreSQL"};
private static final String[]qyerttypes = {"test.db.servers.MySQL.QueryObject","test.db.servers.PostgreSQL.QueryObject"};
private IDatabase db;
private IQueryObject query;
private Class DBClass;
private Class QueryClass;
try{
dbclass = Class.forName(dbtypes[1]);
db = (IDatabase) dbclass.newInstance();
querylass = Class.forName(querytypes[1]);
query = (IQueryObject) QueryClass.netInstance();
}catch(.....)....
问题是performance是不是会比直接建立对应的sql lib更慢,会慢多少呢?
例如我要实现一个generic database client.
支持mysql/postgresql, 在用户安装程序的时候选择使用mysql或者postgresql
private static final String[]dbtypes = {"test.db.servers.MySQL.MySQL","test.db.servers.PostgreSQL.PostgreSQL"};
private static final String[]qyerttypes = {"test.db.servers.MySQL.QueryObject","test.db.servers.PostgreSQL.QueryObject"};
private IDatabase db;
private IQueryObject query;
private Class DBClass;
private Class QueryClass;
try{
dbclass = Class.forName(dbtypes[1]);
db = (IDatabase) dbclass.newInstance();
querylass = Class.forName(querytypes[1]);
query = (IQueryObject) QueryClass.netInstance();
}catch(.....)....
问题是performance是不是会比直接建立对应的sql lib更慢,会慢多少呢?