6、Configuration构建之setting节点解析
来源:互联网 发布:查九牧卫浴型号软件 编辑:程序博客网 时间:2024/06/06 03:27
setting元素的判断
对于setting元素会先进行判读,是否有非法的值
private Properties settingsAsProperties(XNode context) { if (context == null) { return new Properties(); } //得到配置文件setting节点下的所有属性 Properties props = context.getChildrenAsProperties(); // 通过反射工具得到Configuration对象 MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory); //如果setting节点下的属性有Configuration对象未包含的属性则报错 for (Object key : props.keySet()) { if (!metaConfig.hasSetter(String.valueOf(key))) { throw new BuilderException("The setting " + key + " is not known. Make sure you spelled it correctly (case sensitive)."); } } return props; }
加载Vfs
对于完成判断的setting元素会先对vfs进行复制
private void loadCustomVfs(Properties props) throws ClassNotFoundException { String value = props.getProperty("vfsImpl"); if (value != null) { String[] clazzes = value.split(","); for (String clazz : clazzes) { if (!clazz.isEmpty()) { @SuppressWarnings("unchecked") Class<? extends VFS> vfsImpl = (Class<? extends VFS>) Resources.classForName(clazz); configuration.setVfsImpl(vfsImpl); } } } }
其他setting元素的赋值
其他setting元素的赋值,并不会立即执行,在其他节点解析后才会调用settingsElement(settings);
private void settingsElement(Properties props) throws Exception { configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL"))); configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE"))); configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true)); configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory"))); configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false)); configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), false)); configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true)); configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true)); configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false)); configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE"))); configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null)); configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null)); configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false)); configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false)); configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION"))); configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER"))); configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString")); configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true)); configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage"))); configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false)); configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true)); configuration.setReturnInstanceForEmptyRow(booleanValueOf(props.getProperty("returnInstanceForEmptyRow"), false)); configuration.setLogPrefix(props.getProperty("logPrefix")); @SuppressWarnings("unchecked") Class<? extends Log> logImpl = (Class<? extends Log>) resolveClass(props.getProperty("logImpl")); configuration.setLogImpl(logImpl); configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory"))); }
阅读全文
0 0
- 6、Configuration构建之setting节点解析
- 5、Configuration构建之setting节点介绍
- 7、Configuration构建之typeAliases别名节点解析
- 4、Configuration构建之properties节点
- hadoop源码之Configuration解析
- 【hibernate源码解析】之Configuration
- Setting解析
- SpringBoot构建微服务实战 之 Configuration(一)
- SpringBoot构建微服务实战 之 Configuration(二)
- SpringBoot构建微服务实战 之 Configuration(三)
- Where a configuration setting may be set
- 17.1.1.1 Setting the Replication Master Configuration
- 17.1.1.2 Setting the Replication Slave Configuration
- Setting the Master Configuration on the Slave
- 17.1.1.2 Setting the Replication Slave Configuration
- 17.1.1.2 Setting the Replication Slave Configuration
- 007-logback根节点configuration
- HBase configuration解析
- Java常用设计模式
- Map深入
- String类解析
- linux_时区修改
- JS正则截取首尾单双引号中间内容
- 6、Configuration构建之setting节点解析
- 某机构招生总监透露Java培训行业内幕
- CRC校验
- 计算机网络知识
- Java核心类库,线程通信
- Linux驱动修炼之道-SPI驱动框架源码分析(上)
- 安装虚拟机后不能连接网络Determining IP Information for eth0...failed
- 树莓派 学习笔记1
- Android怎样实现传递对象集合?