Java Code Examples for org.apache.ibatis.parsing.XNode#getIntAttribute()

The following examples show how to use org.apache.ibatis.parsing.XNode#getIntAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLMapperBuilder.java    From Shop-for-JavaWeb with MIT License 6 votes vote down vote up
private void cacheElement(XNode context) throws Exception {
	if (context != null) {
		String type = context.getStringAttribute("type", "PERPETUAL");
		Class<? extends Cache> typeClass = typeAliasRegistry
				.resolveAlias(type);
		String eviction = context.getStringAttribute("eviction", "LRU");
		Class<? extends Cache> evictionClass = typeAliasRegistry
				.resolveAlias(eviction);
		Long flushInterval = context.getLongAttribute("flushInterval");
		Integer size = context.getIntAttribute("size");
		boolean readWrite = !context.getBooleanAttribute("readOnly", false);
		Properties props = context.getChildrenAsProperties();
		builderAssistant.useNewCache(typeClass, evictionClass,
				flushInterval, size, readWrite, props);
	}
}
 
Example 2
Source File: XMLMapperBuilder.java    From mybaties with Apache License 2.0 6 votes vote down vote up
private void cacheElement(XNode context) throws Exception {
    if (context != null) {
      String type = context.getStringAttribute("type", "PERPETUAL");
      Class<? extends Cache> typeClass = typeAliasRegistry.resolveAlias(type);
      String eviction = context.getStringAttribute("eviction", "LRU");
      Class<? extends Cache> evictionClass = typeAliasRegistry.resolveAlias(eviction);
      Long flushInterval = context.getLongAttribute("flushInterval");
      Integer size = context.getIntAttribute("size");
      boolean readWrite = !context.getBooleanAttribute("readOnly", false);
      boolean blocking = context.getBooleanAttribute("blocking", false);
      //读入额外的配置信息,易于第三方的缓存扩展,例:
//    <cache type="com.domain.something.MyCustomCache">
//      <property name="cacheFile" value="/tmp/my-custom-cache.tmp"/>
//    </cache>
      Properties props = context.getChildrenAsProperties();
      //调用builderAssistant.useNewCache
      builderAssistant.useNewCache(typeClass, evictionClass, flushInterval, size, readWrite, blocking, props);
    }
  }
 
Example 3
Source File: XMLMapperBuilder.java    From mybaties with Apache License 2.0 6 votes vote down vote up
private void parameterMapElement(List<XNode> list) throws Exception {
  for (XNode parameterMapNode : list) {
    String id = parameterMapNode.getStringAttribute("id");
    String type = parameterMapNode.getStringAttribute("type");
    Class<?> parameterClass = resolveClass(type);
    List<XNode> parameterNodes = parameterMapNode.evalNodes("parameter");
    List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
    for (XNode parameterNode : parameterNodes) {
      String property = parameterNode.getStringAttribute("property");
      String javaType = parameterNode.getStringAttribute("javaType");
      String jdbcType = parameterNode.getStringAttribute("jdbcType");
      String resultMap = parameterNode.getStringAttribute("resultMap");
      String mode = parameterNode.getStringAttribute("mode");
      String typeHandler = parameterNode.getStringAttribute("typeHandler");
      Integer numericScale = parameterNode.getIntAttribute("numericScale");
      ParameterMode modeEnum = resolveParameterMode(mode);
      Class<?> javaTypeClass = resolveClass(javaType);
      JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
      @SuppressWarnings("unchecked")
      Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
      ParameterMapping parameterMapping = builderAssistant.buildParameterMapping(parameterClass, property, javaTypeClass, jdbcTypeEnum, resultMap, modeEnum, typeHandlerClass, numericScale);
      parameterMappings.add(parameterMapping);
    }
    builderAssistant.addParameterMap(id, parameterClass, parameterMappings);
  }
}
 
Example 4
Source File: XMLMapperBuilder.java    From mybatis with Apache License 2.0 6 votes vote down vote up
private void cacheElement(XNode context) throws Exception {
    if (context != null) {
      String type = context.getStringAttribute("type", "PERPETUAL");
      Class<? extends Cache> typeClass = typeAliasRegistry.resolveAlias(type);
      String eviction = context.getStringAttribute("eviction", "LRU");
      Class<? extends Cache> evictionClass = typeAliasRegistry.resolveAlias(eviction);
      Long flushInterval = context.getLongAttribute("flushInterval");
      Integer size = context.getIntAttribute("size");
      boolean readWrite = !context.getBooleanAttribute("readOnly", false);
      boolean blocking = context.getBooleanAttribute("blocking", false);
      //读入额外的配置信息,易于第三方的缓存扩展,例:
//    <cache type="com.domain.something.MyCustomCache">
//      <property name="cacheFile" value="/tmp/my-custom-cache.tmp"/>
//    </cache>
      Properties props = context.getChildrenAsProperties();
      //调用builderAssistant.useNewCache
      builderAssistant.useNewCache(typeClass, evictionClass, flushInterval, size, readWrite, blocking, props);
    }
  }
 
Example 5
Source File: XMLMapperBuilder.java    From mybatis with Apache License 2.0 6 votes vote down vote up
private void parameterMapElement(List<XNode> list) throws Exception {
  for (XNode parameterMapNode : list) {
    String id = parameterMapNode.getStringAttribute("id");
    String type = parameterMapNode.getStringAttribute("type");
    Class<?> parameterClass = resolveClass(type);
    List<XNode> parameterNodes = parameterMapNode.evalNodes("parameter");
    List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
    for (XNode parameterNode : parameterNodes) {
      String property = parameterNode.getStringAttribute("property");
      String javaType = parameterNode.getStringAttribute("javaType");
      String jdbcType = parameterNode.getStringAttribute("jdbcType");
      String resultMap = parameterNode.getStringAttribute("resultMap");
      String mode = parameterNode.getStringAttribute("mode");
      String typeHandler = parameterNode.getStringAttribute("typeHandler");
      Integer numericScale = parameterNode.getIntAttribute("numericScale");
      ParameterMode modeEnum = resolveParameterMode(mode);
      Class<?> javaTypeClass = resolveClass(javaType);
      JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
      @SuppressWarnings("unchecked")
      Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
      ParameterMapping parameterMapping = builderAssistant.buildParameterMapping(parameterClass, property, javaTypeClass, jdbcTypeEnum, resultMap, modeEnum, typeHandlerClass, numericScale);
      parameterMappings.add(parameterMapping);
    }
    builderAssistant.addParameterMap(id, parameterClass, parameterMappings);
  }
}
 
Example 6
Source File: XMLMapperBuilder.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
private void parameterMapElement(List<XNode> list) throws Exception {
	for (XNode parameterMapNode : list) {
		String id = parameterMapNode.getStringAttribute("id");
		String type = parameterMapNode.getStringAttribute("type");
		Class<?> parameterClass = resolveClass(type);
		List<XNode> parameterNodes = parameterMapNode
				.evalNodes("parameter");
		List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
		for (XNode parameterNode : parameterNodes) {
			String property = parameterNode.getStringAttribute("property");
			String javaType = parameterNode.getStringAttribute("javaType");
			String jdbcType = parameterNode.getStringAttribute("jdbcType");
			String resultMap = parameterNode
					.getStringAttribute("resultMap");
			String mode = parameterNode.getStringAttribute("mode");
			String typeHandler = parameterNode
					.getStringAttribute("typeHandler");
			Integer numericScale = parameterNode
					.getIntAttribute("numericScale");
			ParameterMode modeEnum = resolveParameterMode(mode);
			Class<?> javaTypeClass = resolveClass(javaType);
			JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
			@SuppressWarnings("unchecked")
			Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
			ParameterMapping parameterMapping = builderAssistant
					.buildParameterMapping(parameterClass, property,
							javaTypeClass, jdbcTypeEnum, resultMap,
							modeEnum, typeHandlerClass, numericScale);
			parameterMappings.add(parameterMapping);
		}
		builderAssistant.addParameterMap(id, parameterClass,
				parameterMappings);
	}
}