- 浏览: 115289 次
- 性别:
- 来自: 杭州
-
文章分类
- 全部博客 (79)
- iBATIS (6)
- MySQL (4)
- english song (4)
- 软件过程管理 (1)
- 人生大事 (1)
- ruby (7)
- JAVACC (1)
- IT生活 (1)
- jQuery (0)
- database (1)
- JVM (3)
- jQueryUI (1)
- OSCache (6)
- JCS (1)
- sip servlet (2)
- 正则表达式 (1)
- R (1)
- Java (4)
- GAE (1)
- SSH (1)
- SVN (1)
- network (1)
- 经典面试题 (1)
- CSS (1)
- Spring (4)
- Rest (0)
- SipServlet (1)
- vnc (1)
- jmx-console (1)
- JavaScript (2)
- node.js (5)
- HTML5 (1)
- Android (1)
- Hadoop (0)
最新评论
-
lb86haha:
DispatcherServlet在web.xml中的配置 -
蜀山客:
我查看源代码,知道了分页的机制:操作结果集,移动指针到指定的第 ...
SqlMapClientImpl -
蜀山客:
最近对分页查询,怎么运用产生了兴趣并遇到了困惑,希望大神帮忙
SqlMapClientImpl -
蜀山客:
public List queryForList(String ...
SqlMapClientImpl -
aoems:
请教博主。上述代码细节上有问题,比如标点,比如新版本中。另外, ...
node.js连接 mysql
package com.ibatis.sqlmap.engine.builder.xml;
import com.ibatis.common.resources.*;
import com.ibatis.common.xml.*;
import com.ibatis.sqlmap.client.*;
import com.ibatis.sqlmap.engine.config.*;
import com.ibatis.sqlmap.engine.transaction.*;
import com.ibatis.sqlmap.engine.datasource.*;
import com.ibatis.sqlmap.engine.mapping.result.*;
import org.w3c.dom.Node;
import java.io.*;
import java.util.Properties;
//璇ョ被涓昏鏄鐞嗚В鏋怱QL Map閰嶇疆鏂囦欢
public class SqlMapConfigParser {
// parser鍙橀噺鏄В鏋怷ML鐨勬牳蹇�
protected final NodeletParser parser = new NodeletParser();
// state鍙橀噺鍏呭綋涓�釜涓棿鍙橀噺鐨勫鍣紝鎴栬�鏄竴涓厤缃俊鎭殑闂ㄦ埛
private XmlParserState state = new XmlParserState();
private boolean usingStreams = false;
public SqlMapConfigParser() {
// 楠岃瘉dtd鏂囦欢锛岃缃獙璇佸弬鏁�
parser.setValidation(true);
parser.setEntityResolver(new SqlMapClasspathEntityResolver());
//杩涜鍒濆鍖栫殑璧嬪�澶勭悊
addSqlMapConfigNodelets();
addGlobalPropNodelets();
addSettingsNodelets();
addTypeAliasNodelets();
addTypeHandlerNodelets();
addTransactionManagerNodelets();
addSqlMapNodelets();
addResultObjectFactoryNodelets();
}
public SqlMapClient parse(Reader reader, Properties props) {
if (props != null)
state.setGlobalProps(props);
return parse(reader);
}
//鍩轰簬瀛楃妯″紡瑙f瀽XML閰嶇疆鏂囦欢
public SqlMapClient parse(Reader reader) {
try {
usingStreams = false;
parser.parse(reader);
return state.getConfig().getClient();
} catch (Exception e) {
throw new RuntimeException("Error occurred. Cause: " + e, e);
}
}
public SqlMapClient parse(InputStream inputStream, Properties props) {
if (props != null)
state.setGlobalProps(props);
return parse(inputStream);
}
// 鍩轰簬瀛楄妭妯″紡瑙f瀽XML閰嶇疆鏂囦欢
public SqlMapClient parse(InputStream inputStream) {
try {
usingStreams = true;
parser.parse(inputStream);
return state.getConfig().getClient();
} catch (Exception e) {
throw new RuntimeException("Error occurred. Cause: " + e, e);
}
}
// 澶勭悊sqlMapConfig鏍硅妭鐐逛俊鎭紝琛ㄦ槑鍏跺凡缁忕粨鏉�
private void addSqlMapConfigNodelets() {
parser.addNodelet("/sqlMapConfig/end()", new Nodelet() {
public void process(Node node) throws Exception {
state.getConfig().finalizeSqlMapConfig();
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/properties淇℃伅锛屼骇鐢熶竴涓叏灞�殑Properties
private void addGlobalPropNodelets() {
parser.addNodelet("/sqlMapConfig/properties", new Nodelet() {
public void process(Node node) throws Exception {
// 鑾峰緱/sqlMapConfig/properties鑺傜偣涓嬬殑鍏ㄩ儴灞炴�鍊硷紝骞舵妸杩欎簺灞炴�鍊艰祴鍊肩粰Properties绫诲瀷鐨勫彉閲廰ttributes
Properties attributes = NodeletUtils.parseAttributes(node,
state.getGlobalProps());
String resource = attributes.getProperty("resource");
String url = attributes.getProperty("url");
// 鐢眘tate鍙橀噺浣滀负涓棿浣撲紶閫掍俊鎭�
state.setGlobalProperties(resource, url);
}
});
}
//澶勭悊鑺傜偣/sqlMapConfig/settings淇℃伅锛屼骇鐢熷叏灞�彉閲�
private void addSettingsNodelets() {
parser.addNodelet("/sqlMapConfig/settings", new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(node,
state.getGlobalProps());
SqlMapConfiguration config = state.getConfig();
String classInfoCacheEnabledAttr = attributes
.getProperty("classInfoCacheEnabled");
boolean classInfoCacheEnabled = (classInfoCacheEnabledAttr == null || "true"
.equals(classInfoCacheEnabledAttr));
config.setClassInfoCacheEnabled(classInfoCacheEnabled);
String lazyLoadingEnabledAttr = attributes
.getProperty("lazyLoadingEnabled");
boolean lazyLoadingEnabled = (lazyLoadingEnabledAttr == null || "true"
.equals(lazyLoadingEnabledAttr));
config.setLazyLoadingEnabled(lazyLoadingEnabled);
String statementCachingEnabledAttr = attributes
.getProperty("statementCachingEnabled");
boolean statementCachingEnabled = (statementCachingEnabledAttr == null || "true"
.equals(statementCachingEnabledAttr));
config.setStatementCachingEnabled(statementCachingEnabled);
String cacheModelsEnabledAttr = attributes
.getProperty("cacheModelsEnabled");
boolean cacheModelsEnabled = (cacheModelsEnabledAttr == null || "true"
.equals(cacheModelsEnabledAttr));
config.setCacheModelsEnabled(cacheModelsEnabled);
String enhancementEnabledAttr = attributes
.getProperty("enhancementEnabled");
boolean enhancementEnabled = (enhancementEnabledAttr == null || "true"
.equals(enhancementEnabledAttr));
config.setEnhancementEnabled(enhancementEnabled);
String useColumnLabelAttr = attributes
.getProperty("useColumnLabel");
boolean useColumnLabel = (useColumnLabelAttr == null || "true"
.equals(useColumnLabelAttr));
config.setUseColumnLabel(useColumnLabel);
String forceMultipleResultSetSupportAttr = attributes
.getProperty("forceMultipleResultSetSupport");
boolean forceMultipleResultSetSupport = "true"
.equals(forceMultipleResultSetSupportAttr);
config
.setForceMultipleResultSetSupport(forceMultipleResultSetSupport);
String defaultTimeoutAttr = attributes
.getProperty("defaultStatementTimeout");
Integer defaultTimeout = defaultTimeoutAttr == null ? null
: Integer.valueOf(defaultTimeoutAttr);
config.setDefaultStatementTimeout(defaultTimeout);
String useStatementNamespacesAttr = attributes
.getProperty("useStatementNamespaces");
boolean useStatementNamespaces = "true"
.equals(useStatementNamespacesAttr);
state.setUseStatementNamespaces(useStatementNamespaces);
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/typeAlias淇℃伅锛屽鐞嗗埆鍚嶏紙typeAlias锛夎浆鍖�
private void addTypeAliasNodelets() {
parser.addNodelet("/sqlMapConfig/typeAlias", new Nodelet() {
public void process(Node node) throws Exception {
Properties prop = NodeletUtils.parseAttributes(node, state
.getGlobalProps());
String alias = prop.getProperty("alias");
String type = prop.getProperty("type");
//鑾峰彇鍒悕鍙婂叾瀵瑰簲鐨凜lass绫诲瀷锛屾敞鍐屽埌TypeHandlerFactory宸ュ巶瀵硅薄涓�
state.getConfig().getTypeHandlerFactory().putTypeAlias(alias,
type);
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/typeHandler淇℃伅锛屽鍔犳柊鐨刯dbcType
private void addTypeHandlerNodelets() {
parser.addNodelet("/sqlMapConfig/typeHandler", new Nodelet() {
public void process(Node node) throws Exception {
Properties prop = NodeletUtils.parseAttributes(node, state
.getGlobalProps());
String jdbcType = prop.getProperty("jdbcType");
String javaType = prop.getProperty("javaType");
String callback = prop.getProperty("callback");
javaType = state.getConfig().getTypeHandlerFactory()
.resolveAlias(javaType);
callback = state.getConfig().getTypeHandlerFactory()
.resolveAlias(callback);
state.getConfig().newTypeHandler(
Resources.classForName(javaType), jdbcType,
Resources.instantiate(callback));
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager淇℃伅锛屽寘鎷瑃ransactionManager鍜宒ataSource
private void addTransactionManagerNodelets() {
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager/property鐨勪俊鎭紝杞寲鍒皌ransactionManager瀵硅薄鐨勭浉鍏冲睘鎬т腑
parser.addNodelet("/sqlMapConfig/transactionManager/property",
new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String name = attributes.getProperty("name");
String value = NodeletUtils.parsePropertyTokens(
attributes.getProperty("value"), state
.getGlobalProps());
state.getTxProps().setProperty(name, value);
}
});
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager/锛岀敓鎴恡ransactionManager瀵硅薄骞惰繘琛岀粨鏉熷鐞�
parser.addNodelet("/sqlMapConfig/transactionManager/end()",
new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String type = attributes.getProperty("type");
boolean commitRequired = "true".equals(attributes
.getProperty("commitRequired"));
state.getConfig().getErrorContext().setActivity(
"configuring the transaction manager");
type = state.getConfig().getTypeHandlerFactory()
.resolveAlias(type);
TransactionManager txManager;
try {
state.getConfig().getErrorContext().setMoreInfo(
"Check the transaction manager type or class.");
TransactionConfig config = (TransactionConfig) Resources
.instantiate(type);
config.setDataSource(state.getDataSource());
state
.getConfig()
.getErrorContext()
.setMoreInfo(
"Check the transactio nmanager properties or configuration.");
config.setProperties(state.getTxProps());
config.setForceCommit(commitRequired);
config.setDataSource(state.getDataSource());
state.getConfig().getErrorContext().setMoreInfo(
null);
txManager = new TransactionManager(config);
} catch (Exception e) {
if (e instanceof SqlMapException) {
throw (SqlMapException) e;
} else {
throw new SqlMapException(
"Error initializing TransactionManager. Could not instantiate TransactionConfig. Cause: "
+ e, e);
}
}
state.getConfig().setTransactionManager(txManager);
}
});
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager/dataSource/property锛屽鐞哾ataSource鑺傜偣鐨刾roperty鍐呭
parser.addNodelet(
"/sqlMapConfig/transactionManager/dataSource/property",
new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String name = attributes.getProperty("name");
String value = NodeletUtils.parsePropertyTokens(
attributes.getProperty("value"), state
.getGlobalProps());
state.getDsProps().setProperty(name, value);
}
});
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager/dataSource/end()锛屽姩鎬佸疄渚嬪寲dataSource瀵硅薄锛岀劧鍚庤繘琛屽睘鎬у垵濮嬪寲
parser.addNodelet("/sqlMapConfig/transactionManager/dataSource/end()",
new Nodelet() {
public void process(Node node) throws Exception {
state.getConfig().getErrorContext().setActivity(
"configuring the data source");
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String type = attributes.getProperty("type");
Properties props = state.getDsProps();
type = state.getConfig().getTypeHandlerFactory()
.resolveAlias(type);
try {
state.getConfig().getErrorContext().setMoreInfo(
"Check the data source type or class.");
DataSourceFactory dsFactory = (DataSourceFactory) Resources
.instantiate(type);
state.getConfig().getErrorContext().setMoreInfo(
"Check the data source properties or configuration.");
dsFactory.initialize(props);
state.setDataSource(dsFactory.getDataSource());
state.getConfig().getErrorContext().setMoreInfo(
null);
} catch (Exception e) {
if (e instanceof SqlMapException) {
throw (SqlMapException) e;
} else {
throw new SqlMapException(
"Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: "
+ e, e);
}
}
}
});
}
//澶勭悊鑺傜偣/sqlMapConfig/sqlMap锛屽幓鑾峰彇sqlMap鐨勬槧灏勬枃浠讹紝鐒跺悗瀵瑰悇涓槧灏勬枃浠惰繘琛岃鍙栧鐞�
protected void addSqlMapNodelets() {
parser.addNodelet("/sqlMapConfig/sqlMap", new Nodelet() {
public void process(Node node) throws Exception {
state.getConfig().getErrorContext().setActivity(
"loading the SQL Map resource");
Properties attributes = NodeletUtils.parseAttributes(node,
state.getGlobalProps());
String resource = attributes.getProperty("resource");
String url = attributes.getProperty("url");
if (usingStreams) {
//閲囩敤瀛楄妭娴佹ā寮忔潵璇诲彇鏂囦欢
InputStream inputStream = null;
if (resource != null) {
state.getConfig().getErrorContext().setResource(
resource);
inputStream = Resources.getResourceAsStream(resource);
} else if (url != null) {
state.getConfig().getErrorContext().setResource(url);
inputStream = Resources.getUrlAsStream(url);
} else {
throw new SqlMapException(
"The <sqlMap> element requires either a resource or a url attribute.");
}
new SqlMapParser(state).parse(inputStream);
} else {
// 閲囩敤瀛楃娴佹ā寮忔潵璇诲彇鏂囦欢
Reader reader = null;
if (resource != null) {
state.getConfig().getErrorContext().setResource(
resource);
reader = Resources.getResourceAsReader(resource);
} else if (url != null) {
state.getConfig().getErrorContext().setResource(url);
reader = Resources.getUrlAsReader(url);
} else {
throw new SqlMapException(
"The <sqlMap> element requires either a resource or a url attribute.");
}
new SqlMapParser(state).parse(reader);
}
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/resultObjectFactory锛屽垵濮嬪寲鏂扮殑resultObjectFactory
private void addResultObjectFactoryNodelets() {
parser.addNodelet("/sqlMapConfig/resultObjectFactory", new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(node,
state.getGlobalProps());
String type = attributes.getProperty("type");
state.getConfig().getErrorContext().setActivity(
"configuring the Result Object Factory");
ResultObjectFactory rof;
try {
rof = (ResultObjectFactory) Resources.instantiate(type);
state.getConfig().setResultObjectFactory(rof);
} catch (Exception e) {
throw new SqlMapException(
"Error instantiating resultObjectFactory: " + type,
e);
}
}
});
parser.addNodelet("/sqlMapConfig/resultObjectFactory/property",
new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String name = attributes.getProperty("name");
String value = NodeletUtils.parsePropertyTokens(
attributes.getProperty("value"), state
.getGlobalProps());
state.getConfig().getDelegate()
.getResultObjectFactory().setProperty(name,
value);
}
});
}
}
import com.ibatis.common.resources.*;
import com.ibatis.common.xml.*;
import com.ibatis.sqlmap.client.*;
import com.ibatis.sqlmap.engine.config.*;
import com.ibatis.sqlmap.engine.transaction.*;
import com.ibatis.sqlmap.engine.datasource.*;
import com.ibatis.sqlmap.engine.mapping.result.*;
import org.w3c.dom.Node;
import java.io.*;
import java.util.Properties;
//璇ョ被涓昏鏄鐞嗚В鏋怱QL Map閰嶇疆鏂囦欢
public class SqlMapConfigParser {
// parser鍙橀噺鏄В鏋怷ML鐨勬牳蹇�
protected final NodeletParser parser = new NodeletParser();
// state鍙橀噺鍏呭綋涓�釜涓棿鍙橀噺鐨勫鍣紝鎴栬�鏄竴涓厤缃俊鎭殑闂ㄦ埛
private XmlParserState state = new XmlParserState();
private boolean usingStreams = false;
public SqlMapConfigParser() {
// 楠岃瘉dtd鏂囦欢锛岃缃獙璇佸弬鏁�
parser.setValidation(true);
parser.setEntityResolver(new SqlMapClasspathEntityResolver());
//杩涜鍒濆鍖栫殑璧嬪�澶勭悊
addSqlMapConfigNodelets();
addGlobalPropNodelets();
addSettingsNodelets();
addTypeAliasNodelets();
addTypeHandlerNodelets();
addTransactionManagerNodelets();
addSqlMapNodelets();
addResultObjectFactoryNodelets();
}
public SqlMapClient parse(Reader reader, Properties props) {
if (props != null)
state.setGlobalProps(props);
return parse(reader);
}
//鍩轰簬瀛楃妯″紡瑙f瀽XML閰嶇疆鏂囦欢
public SqlMapClient parse(Reader reader) {
try {
usingStreams = false;
parser.parse(reader);
return state.getConfig().getClient();
} catch (Exception e) {
throw new RuntimeException("Error occurred. Cause: " + e, e);
}
}
public SqlMapClient parse(InputStream inputStream, Properties props) {
if (props != null)
state.setGlobalProps(props);
return parse(inputStream);
}
// 鍩轰簬瀛楄妭妯″紡瑙f瀽XML閰嶇疆鏂囦欢
public SqlMapClient parse(InputStream inputStream) {
try {
usingStreams = true;
parser.parse(inputStream);
return state.getConfig().getClient();
} catch (Exception e) {
throw new RuntimeException("Error occurred. Cause: " + e, e);
}
}
// 澶勭悊sqlMapConfig鏍硅妭鐐逛俊鎭紝琛ㄦ槑鍏跺凡缁忕粨鏉�
private void addSqlMapConfigNodelets() {
parser.addNodelet("/sqlMapConfig/end()", new Nodelet() {
public void process(Node node) throws Exception {
state.getConfig().finalizeSqlMapConfig();
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/properties淇℃伅锛屼骇鐢熶竴涓叏灞�殑Properties
private void addGlobalPropNodelets() {
parser.addNodelet("/sqlMapConfig/properties", new Nodelet() {
public void process(Node node) throws Exception {
// 鑾峰緱/sqlMapConfig/properties鑺傜偣涓嬬殑鍏ㄩ儴灞炴�鍊硷紝骞舵妸杩欎簺灞炴�鍊艰祴鍊肩粰Properties绫诲瀷鐨勫彉閲廰ttributes
Properties attributes = NodeletUtils.parseAttributes(node,
state.getGlobalProps());
String resource = attributes.getProperty("resource");
String url = attributes.getProperty("url");
// 鐢眘tate鍙橀噺浣滀负涓棿浣撲紶閫掍俊鎭�
state.setGlobalProperties(resource, url);
}
});
}
//澶勭悊鑺傜偣/sqlMapConfig/settings淇℃伅锛屼骇鐢熷叏灞�彉閲�
private void addSettingsNodelets() {
parser.addNodelet("/sqlMapConfig/settings", new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(node,
state.getGlobalProps());
SqlMapConfiguration config = state.getConfig();
String classInfoCacheEnabledAttr = attributes
.getProperty("classInfoCacheEnabled");
boolean classInfoCacheEnabled = (classInfoCacheEnabledAttr == null || "true"
.equals(classInfoCacheEnabledAttr));
config.setClassInfoCacheEnabled(classInfoCacheEnabled);
String lazyLoadingEnabledAttr = attributes
.getProperty("lazyLoadingEnabled");
boolean lazyLoadingEnabled = (lazyLoadingEnabledAttr == null || "true"
.equals(lazyLoadingEnabledAttr));
config.setLazyLoadingEnabled(lazyLoadingEnabled);
String statementCachingEnabledAttr = attributes
.getProperty("statementCachingEnabled");
boolean statementCachingEnabled = (statementCachingEnabledAttr == null || "true"
.equals(statementCachingEnabledAttr));
config.setStatementCachingEnabled(statementCachingEnabled);
String cacheModelsEnabledAttr = attributes
.getProperty("cacheModelsEnabled");
boolean cacheModelsEnabled = (cacheModelsEnabledAttr == null || "true"
.equals(cacheModelsEnabledAttr));
config.setCacheModelsEnabled(cacheModelsEnabled);
String enhancementEnabledAttr = attributes
.getProperty("enhancementEnabled");
boolean enhancementEnabled = (enhancementEnabledAttr == null || "true"
.equals(enhancementEnabledAttr));
config.setEnhancementEnabled(enhancementEnabled);
String useColumnLabelAttr = attributes
.getProperty("useColumnLabel");
boolean useColumnLabel = (useColumnLabelAttr == null || "true"
.equals(useColumnLabelAttr));
config.setUseColumnLabel(useColumnLabel);
String forceMultipleResultSetSupportAttr = attributes
.getProperty("forceMultipleResultSetSupport");
boolean forceMultipleResultSetSupport = "true"
.equals(forceMultipleResultSetSupportAttr);
config
.setForceMultipleResultSetSupport(forceMultipleResultSetSupport);
String defaultTimeoutAttr = attributes
.getProperty("defaultStatementTimeout");
Integer defaultTimeout = defaultTimeoutAttr == null ? null
: Integer.valueOf(defaultTimeoutAttr);
config.setDefaultStatementTimeout(defaultTimeout);
String useStatementNamespacesAttr = attributes
.getProperty("useStatementNamespaces");
boolean useStatementNamespaces = "true"
.equals(useStatementNamespacesAttr);
state.setUseStatementNamespaces(useStatementNamespaces);
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/typeAlias淇℃伅锛屽鐞嗗埆鍚嶏紙typeAlias锛夎浆鍖�
private void addTypeAliasNodelets() {
parser.addNodelet("/sqlMapConfig/typeAlias", new Nodelet() {
public void process(Node node) throws Exception {
Properties prop = NodeletUtils.parseAttributes(node, state
.getGlobalProps());
String alias = prop.getProperty("alias");
String type = prop.getProperty("type");
//鑾峰彇鍒悕鍙婂叾瀵瑰簲鐨凜lass绫诲瀷锛屾敞鍐屽埌TypeHandlerFactory宸ュ巶瀵硅薄涓�
state.getConfig().getTypeHandlerFactory().putTypeAlias(alias,
type);
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/typeHandler淇℃伅锛屽鍔犳柊鐨刯dbcType
private void addTypeHandlerNodelets() {
parser.addNodelet("/sqlMapConfig/typeHandler", new Nodelet() {
public void process(Node node) throws Exception {
Properties prop = NodeletUtils.parseAttributes(node, state
.getGlobalProps());
String jdbcType = prop.getProperty("jdbcType");
String javaType = prop.getProperty("javaType");
String callback = prop.getProperty("callback");
javaType = state.getConfig().getTypeHandlerFactory()
.resolveAlias(javaType);
callback = state.getConfig().getTypeHandlerFactory()
.resolveAlias(callback);
state.getConfig().newTypeHandler(
Resources.classForName(javaType), jdbcType,
Resources.instantiate(callback));
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager淇℃伅锛屽寘鎷瑃ransactionManager鍜宒ataSource
private void addTransactionManagerNodelets() {
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager/property鐨勪俊鎭紝杞寲鍒皌ransactionManager瀵硅薄鐨勭浉鍏冲睘鎬т腑
parser.addNodelet("/sqlMapConfig/transactionManager/property",
new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String name = attributes.getProperty("name");
String value = NodeletUtils.parsePropertyTokens(
attributes.getProperty("value"), state
.getGlobalProps());
state.getTxProps().setProperty(name, value);
}
});
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager/锛岀敓鎴恡ransactionManager瀵硅薄骞惰繘琛岀粨鏉熷鐞�
parser.addNodelet("/sqlMapConfig/transactionManager/end()",
new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String type = attributes.getProperty("type");
boolean commitRequired = "true".equals(attributes
.getProperty("commitRequired"));
state.getConfig().getErrorContext().setActivity(
"configuring the transaction manager");
type = state.getConfig().getTypeHandlerFactory()
.resolveAlias(type);
TransactionManager txManager;
try {
state.getConfig().getErrorContext().setMoreInfo(
"Check the transaction manager type or class.");
TransactionConfig config = (TransactionConfig) Resources
.instantiate(type);
config.setDataSource(state.getDataSource());
state
.getConfig()
.getErrorContext()
.setMoreInfo(
"Check the transactio nmanager properties or configuration.");
config.setProperties(state.getTxProps());
config.setForceCommit(commitRequired);
config.setDataSource(state.getDataSource());
state.getConfig().getErrorContext().setMoreInfo(
null);
txManager = new TransactionManager(config);
} catch (Exception e) {
if (e instanceof SqlMapException) {
throw (SqlMapException) e;
} else {
throw new SqlMapException(
"Error initializing TransactionManager. Could not instantiate TransactionConfig. Cause: "
+ e, e);
}
}
state.getConfig().setTransactionManager(txManager);
}
});
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager/dataSource/property锛屽鐞哾ataSource鑺傜偣鐨刾roperty鍐呭
parser.addNodelet(
"/sqlMapConfig/transactionManager/dataSource/property",
new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String name = attributes.getProperty("name");
String value = NodeletUtils.parsePropertyTokens(
attributes.getProperty("value"), state
.getGlobalProps());
state.getDsProps().setProperty(name, value);
}
});
// 澶勭悊鑺傜偣/sqlMapConfig/transactionManager/dataSource/end()锛屽姩鎬佸疄渚嬪寲dataSource瀵硅薄锛岀劧鍚庤繘琛屽睘鎬у垵濮嬪寲
parser.addNodelet("/sqlMapConfig/transactionManager/dataSource/end()",
new Nodelet() {
public void process(Node node) throws Exception {
state.getConfig().getErrorContext().setActivity(
"configuring the data source");
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String type = attributes.getProperty("type");
Properties props = state.getDsProps();
type = state.getConfig().getTypeHandlerFactory()
.resolveAlias(type);
try {
state.getConfig().getErrorContext().setMoreInfo(
"Check the data source type or class.");
DataSourceFactory dsFactory = (DataSourceFactory) Resources
.instantiate(type);
state.getConfig().getErrorContext().setMoreInfo(
"Check the data source properties or configuration.");
dsFactory.initialize(props);
state.setDataSource(dsFactory.getDataSource());
state.getConfig().getErrorContext().setMoreInfo(
null);
} catch (Exception e) {
if (e instanceof SqlMapException) {
throw (SqlMapException) e;
} else {
throw new SqlMapException(
"Error initializing DataSource. Could not instantiate DataSourceFactory. Cause: "
+ e, e);
}
}
}
});
}
//澶勭悊鑺傜偣/sqlMapConfig/sqlMap锛屽幓鑾峰彇sqlMap鐨勬槧灏勬枃浠讹紝鐒跺悗瀵瑰悇涓槧灏勬枃浠惰繘琛岃鍙栧鐞�
protected void addSqlMapNodelets() {
parser.addNodelet("/sqlMapConfig/sqlMap", new Nodelet() {
public void process(Node node) throws Exception {
state.getConfig().getErrorContext().setActivity(
"loading the SQL Map resource");
Properties attributes = NodeletUtils.parseAttributes(node,
state.getGlobalProps());
String resource = attributes.getProperty("resource");
String url = attributes.getProperty("url");
if (usingStreams) {
//閲囩敤瀛楄妭娴佹ā寮忔潵璇诲彇鏂囦欢
InputStream inputStream = null;
if (resource != null) {
state.getConfig().getErrorContext().setResource(
resource);
inputStream = Resources.getResourceAsStream(resource);
} else if (url != null) {
state.getConfig().getErrorContext().setResource(url);
inputStream = Resources.getUrlAsStream(url);
} else {
throw new SqlMapException(
"The <sqlMap> element requires either a resource or a url attribute.");
}
new SqlMapParser(state).parse(inputStream);
} else {
// 閲囩敤瀛楃娴佹ā寮忔潵璇诲彇鏂囦欢
Reader reader = null;
if (resource != null) {
state.getConfig().getErrorContext().setResource(
resource);
reader = Resources.getResourceAsReader(resource);
} else if (url != null) {
state.getConfig().getErrorContext().setResource(url);
reader = Resources.getUrlAsReader(url);
} else {
throw new SqlMapException(
"The <sqlMap> element requires either a resource or a url attribute.");
}
new SqlMapParser(state).parse(reader);
}
}
});
}
// 澶勭悊鑺傜偣/sqlMapConfig/resultObjectFactory锛屽垵濮嬪寲鏂扮殑resultObjectFactory
private void addResultObjectFactoryNodelets() {
parser.addNodelet("/sqlMapConfig/resultObjectFactory", new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(node,
state.getGlobalProps());
String type = attributes.getProperty("type");
state.getConfig().getErrorContext().setActivity(
"configuring the Result Object Factory");
ResultObjectFactory rof;
try {
rof = (ResultObjectFactory) Resources.instantiate(type);
state.getConfig().setResultObjectFactory(rof);
} catch (Exception e) {
throw new SqlMapException(
"Error instantiating resultObjectFactory: " + type,
e);
}
}
});
parser.addNodelet("/sqlMapConfig/resultObjectFactory/property",
new Nodelet() {
public void process(Node node) throws Exception {
Properties attributes = NodeletUtils.parseAttributes(
node, state.getGlobalProps());
String name = attributes.getProperty("name");
String value = NodeletUtils.parsePropertyTokens(
attributes.getProperty("value"), state
.getGlobalProps());
state.getConfig().getDelegate()
.getResultObjectFactory().setProperty(name,
value);
}
});
}
}
发表评论
-
SqlMapClientImpl
2011-01-14 15:07 3323/* * Copyright 2004 Clinton B ... -
SqlMapConfiguration
2011-01-14 14:49 1110package com.ibatis.sqlmap.engin ... -
XmlParserState
2011-01-14 12:52 897package com.ibatis.sqlmap.engin ... -
SqlMapClientBuilder
2011-01-14 12:45 3203/* * Copyright 2004 Clinton B ... -
NodeletParser
2011-01-14 09:59 1497package com.ibatis.common.xml; ...
相关推荐
它通过SqlMapConfigParser解析SqlMapConfig.xml文件,创建SqlMap实例。SqlMap则包含了对数据库操作的具体配置,包括数据源、事务管理等。对于SQL语句的执行,SqlMapClient使用Executor接口,该接口定义了不同类型的...
- **Spring与MyBatis的集成**:使用Spring的MyBatisNamespaceHandler和SqlMapConfigParser处理MyBatis的配置,使Spring能够管理MyBatis的生命周期。 4. **SpringMVCIbatisSmartClient**: - 这个文件名可能指的是...
在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!
前端分析-2023071100789
基于kinect的3D人体建模C++完整代码.cpp
搞机工具箱10.1.0.7z
GRU+informer时间序列预测(Python完整源码和数据),python代码,pytorch架构,适合各种时间序列直接预测。 适合小白,注释清楚,都能看懂。功能如下: 代码基于数据集划分为训练集测试集。 1.多变量输入,单变量输出/可改多输出 2.多时间步预测,单时间步预测 3.评价指标:R方 RMSE MAE MAPE,对比图 4.数据从excel/csv文件中读取,直接替换即可。 5.结果保存到文本中,可以后续处理。 代码带数据,注释清晰,直接一键运行即可,适合新手小白。
在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!
基于ANSYS LSDyna的DEM-SPH-FEM耦合模拟滑坡入水动态行为研究,基于ANSYS LSDyna的DEM-SPH-FEM耦合的滑坡入水模拟分析研究,基于ansys lsdyna的滑坡入水模拟dem-sph-fem耦合 ,基于ANSYS LSDyna; 滑坡入水模拟; DEM-SPH-FEM 耦合,基于DEM-SPH-FEM耦合的ANSYS LSDyna滑坡入水模拟
auto_gptq-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
复件 复件 建设工程可行性研究合同[示范文本].doc
13考试真题最近的t64.txt
好用我已经解决报错问题
# 踏入C语言的奇妙编程世界 在编程的广阔宇宙中,C语言宛如一颗璀璨恒星,以其独特魅力与强大功能,始终占据着不可替代的地位。无论你是编程小白,还是有一定基础想进一步提升的开发者,C语言都值得深入探索。 C语言的高效性与可移植性令人瞩目。它能直接操控硬件,执行速度快,是系统软件、嵌入式开发的首选。同时,代码可在不同操作系统和硬件平台间轻松移植,极大节省开发成本。 学习C语言,能让你深入理解计算机底层原理,培养逻辑思维和问题解决能力。掌握C语言后,再学习其他编程语言也会事半功倍。 现在,让我们一起开启C语言学习之旅。这里有丰富教程、实用案例、详细代码解析,助你逐步掌握C语言核心知识和编程技巧。别再犹豫,加入我们,在C语言的海洋中尽情遨游,挖掘无限可能,为未来的编程之路打下坚实基础!
auto_gptq-0.4.2-cp38-cp38-win_amd64.whl
自动立体库设计方案.pptx
# 踏入C语言的奇妙编程世界 在编程的广阔宇宙中,C语言宛如一颗璀璨恒星,以其独特魅力与强大功能,始终占据着不可替代的地位。无论你是编程小白,还是有一定基础想进一步提升的开发者,C语言都值得深入探索。 C语言的高效性与可移植性令人瞩目。它能直接操控硬件,执行速度快,是系统软件、嵌入式开发的首选。同时,代码可在不同操作系统和硬件平台间轻松移植,极大节省开发成本。 学习C语言,能让你深入理解计算机底层原理,培养逻辑思维和问题解决能力。掌握C语言后,再学习其他编程语言也会事半功倍。 现在,让我们一起开启C语言学习之旅。这里有丰富教程、实用案例、详细代码解析,助你逐步掌握C语言核心知识和编程技巧。别再犹豫,加入我们,在C语言的海洋中尽情遨游,挖掘无限可能,为未来的编程之路打下坚实基础!
在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!
在日常的工作和学习中,你是否常常为处理复杂的数据、生成高质量的文本或者进行精准的图像识别而烦恼?DeepSeek 或许就是你一直在寻找的解决方案!它以其高效、智能的特点,在各个行业都展现出了巨大的应用价值。然而,想要充分发挥 DeepSeek 的优势,掌握从入门到精通的知识和技能至关重要。本文将从实际应用的角度出发,为你详细介绍 DeepSeek 的基本原理、操作方法以及高级技巧。通过系统的学习,你将能够轻松地运用 DeepSeek 解决实际问题,提升工作效率和质量,让自己在职场和学术领域脱颖而出。现在,就让我们一起开启这场实用又高效的学习之旅吧!
# 踏入C语言的奇妙编程世界 在编程的广阔宇宙中,C语言宛如一颗璀璨恒星,以其独特魅力与强大功能,始终占据着不可替代的地位。无论你是编程小白,还是有一定基础想进一步提升的开发者,C语言都值得深入探索。 C语言的高效性与可移植性令人瞩目。它能直接操控硬件,执行速度快,是系统软件、嵌入式开发的首选。同时,代码可在不同操作系统和硬件平台间轻松移植,极大节省开发成本。 学习C语言,能让你深入理解计算机底层原理,培养逻辑思维和问题解决能力。掌握C语言后,再学习其他编程语言也会事半功倍。 现在,让我们一起开启C语言学习之旅。这里有丰富教程、实用案例、详细代码解析,助你逐步掌握C语言核心知识和编程技巧。别再犹豫,加入我们,在C语言的海洋中尽情遨游,挖掘无限可能,为未来的编程之路打下坚实基础!