當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.classForName方法代碼示例

本文整理匯總了Java中org.apache.ibatis.io.Resources.classForName方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.classForName方法的具體用法?Java Resources.classForName怎麽用?Java Resources.classForName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.ibatis.io.Resources的用法示例。


在下文中一共展示了Resources.classForName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initializeDriver

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
private synchronized void initializeDriver() throws SQLException {
  if (!registeredDrivers.containsKey(driver)) {
    Class<?> driverType;
    try {
      if (driverClassLoader != null) {
        driverType = Class.forName(driver, true, driverClassLoader);
      } else {
        driverType = Resources.classForName(driver);
      }
      // DriverManager requires the driver to be loaded via the system ClassLoader.
      // http://www.kfu.com/~nsayer/Java/dyn-jdbc.html
      Driver driverInstance = (Driver)driverType.newInstance();
      DriverManager.registerDriver(new DriverProxy(driverInstance));
      registeredDrivers.put(driver, driverInstance);
    } catch (Exception e) {
      throw new SQLException("Error setting driver on UnpooledDataSource. Cause: " + e);
    }
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:20,代碼來源:UnpooledDataSource.java

示例2: bindMapperForNamespace

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
private void bindMapperForNamespace() {
    String namespace = builderAssistant.getCurrentNamespace();
    if (namespace != null) {
        Class<?> boundType = null;
        try {
            boundType = Resources.classForName(namespace);
        } catch (ClassNotFoundException e) {
            // ignore, bound type is not required
        }
        if (boundType != null) {
            if (!configuration.hasMapper(boundType)) {
                // Spring may not know the real resource name so we set a
                // flag
                // to prevent loading again this resource from the mapper
                // interface
                // look at MapperAnnotationBuilder#loadXmlResource
                configuration.addLoadedResource("namespace:" + namespace);
                configuration.addMapper(boundType);
            }
            //TODO 注入 CURD 動態 SQL
            if (BaseMapper.class.isAssignableFrom(boundType)) {
                GlobalConfigUtils.getSqlInjector(configuration).inspectInject(builderAssistant, boundType);
            }
        }
    }
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:27,代碼來源:MybatisXMLMapperBuilder.java

示例3: typeAliasesElement

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
private void typeAliasesElement(XNode parent) {
    if (parent != null) {
        for (XNode child : parent.getChildren()) {
            if ("package".equals(child.getName())) {
                String typeAliasPackage = child.getStringAttribute("name");
                configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage);
            } else {
                String alias = child.getStringAttribute("alias");
                String type = child.getStringAttribute("type");
                try {
                    Class<?> clazz = Resources.classForName(type);
                    if (alias == null) {
                        typeAliasRegistry.registerAlias(clazz);
                    } else {
                        typeAliasRegistry.registerAlias(alias, clazz);
                    }
                } catch (ClassNotFoundException e) {
                    throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e);
                }
            }
        }
    }
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:24,代碼來源:MybatisXMLConfigBuilder.java

示例4: typeAliasesElement

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
private void typeAliasesElement(XNode parent) {
	if (parent != null) {
		for (XNode child : parent.getChildren()) {
			if ("package".equals(child.getName())) {
				String typeAliasPackage = child.getStringAttribute("name");
				configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage);
			} else {
				String alias = child.getStringAttribute("alias");
				String type = child.getStringAttribute("type");
				try {
					Class<?> clazz = Resources.classForName(type);
					if (alias == null) {
						typeAliasRegistry.registerAlias(clazz);
					} else {
						typeAliasRegistry.registerAlias(alias, clazz);
					}
				} catch (ClassNotFoundException e) {
					throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e);
				}
			}
		}
	}
}
 
開發者ID:whatlookingfor,項目名稱:spring-boot-sample,代碼行數:24,代碼來源:XMLConfigBuilder.java

示例5: bindMapperForNamespace

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
private void bindMapperForNamespace() {
  String namespace = builderAssistant.getCurrentNamespace();
  if (namespace != null) {
    Class<?> boundType = null;
    try {
      boundType = Resources.classForName(namespace);
    } catch (ClassNotFoundException e) {
      //ignore, bound type is not required
    }
    if (boundType != null) {
      if (!configuration.hasMapper(boundType)) {
        // Spring may not know the real resource name so we set a flag
        // to prevent loading again this resource from the mapper interface
        // look at MapperAnnotationBuilder#loadXmlResource
        configuration.addLoadedResource("namespace:" + namespace);
        configuration.addMapper(boundType);
      }
    }
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:21,代碼來源:XMLMapperBuilder.java

示例6: typeAliasesElement

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
private void typeAliasesElement(XNode parent) {
  if (parent != null) {
    for (XNode child : parent.getChildren()) {
      if ("package".equals(child.getName())) {
        String typeAliasPackage = child.getStringAttribute("name");
        configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage);
      } else {
        String alias = child.getStringAttribute("alias");
        String type = child.getStringAttribute("type");
        try {
          Class<?> clazz = Resources.classForName(type);
          if (alias == null) {
            typeAliasRegistry.registerAlias(clazz);
          } else {
            typeAliasRegistry.registerAlias(alias, clazz);
          }
        } catch (ClassNotFoundException e) {
          throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e);
        }
      }
    }
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:24,代碼來源:XMLConfigBuilder.java

示例7: bindMapperForNamespace

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
private void bindMapperForNamespace() {
	String namespace = builderAssistant.getCurrentNamespace();
	if (namespace != null) {
		Class<?> boundType = null;
		try {
			boundType = Resources.classForName(namespace);
		} catch (ClassNotFoundException e) {
			// ignore, bound type is not required
		}
		if (boundType != null) {
			if (!configuration.hasMapper(boundType)) {
				// Spring may not know the real resource name so we set a
				// flag
				// to prevent loading again this resource from the mapper
				// interface
				// look at MapperAnnotationBuilder#loadXmlResource
				configuration.addLoadedResource("namespace:" + namespace);
				configuration.addMapper(boundType);
			}
		}
	}
}
 
開發者ID:EleTeam,項目名稱:Shop-for-JavaWeb,代碼行數:23,代碼來源:XMLMapperBuilder.java

示例8: classForName

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
@Override
public Class classForName(String className, Map context) throws ClassNotFoundException {
  Class<?> result = null;
  if ((result = classes.get(className)) == null) {
    try {
      result = Resources.classForName(className);
    } catch (ClassNotFoundException e1) {
      if (className.indexOf('.') == -1) {
        result = Resources.classForName("java.lang." + className);
        classes.put("java.lang." + className, result);
      }
    }
    classes.put(className, result);
  }
  return result;
}
 
開發者ID:txazo,項目名稱:mybatis,代碼行數:17,代碼來源:OgnlClassResolver.java

示例9: JavassistProxyFactory

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
public JavassistProxyFactory() {
  try {
    Resources.classForName("javassist.util.proxy.ProxyFactory");
  } catch (Throwable e) {
    throw new IllegalStateException("Cannot enable lazy loading because Javassist is not available. Add Javassist to your classpath.", e);
  }
}
 
開發者ID:txazo,項目名稱:mybatis,代碼行數:8,代碼來源:JavassistProxyFactory.java

示例10: resolveAlias

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
// throws class cast exception as well if types cannot be assigned
public <T> Class<T> resolveAlias(String string) {
  try {
    if (string == null) {
      return null;
    }
    // issue #748
    String key = string.toLowerCase(Locale.ENGLISH);
    Class<T> value;
    if (TYPE_ALIASES.containsKey(key)) {
      value = (Class<T>) TYPE_ALIASES.get(key);
    } else {
      value = (Class<T>) Resources.classForName(string);
    }
    return value;
  } catch (ClassNotFoundException e) {
    throw new TypeException("Could not resolve type alias '" + string + "'.  Cause: " + e, e);
  }
}
 
開發者ID:txazo,項目名稱:mybatis,代碼行數:21,代碼來源:TypeAliasRegistry.java

示例11: loadCustomVfs

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
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);
            }
        }
    }
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:14,代碼來源:MybatisXMLConfigBuilder.java

示例12: setResource

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
/**
 * 查找mybatis配置文件填充至Set集合
 *
 * @param parent    節點
 * @param resources
 * @param mapper
 * @throws ClassNotFoundException
 */
private void setResource(XNode parent, Set<String> resources, Set<Class<?>> mapper) throws ClassNotFoundException {
    for (XNode child : parent.getChildren()) {
        if ("package".equals(child.getName())) {
            String mapperPackage = child.getStringAttribute("name");
            ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<>();
            resolverUtil.find(new ResolverUtil.IsA(Object.class), mapperPackage);
            Set<Class<? extends Class<?>>> mapperSet = resolverUtil.getClasses();
            mapper.addAll(mapperSet);
        } else {
            String resource = child.getStringAttribute("resource");
            String url = child.getStringAttribute("url");
            String mapperClass = child.getStringAttribute("class");
            if (resource != null && url == null && mapperClass == null) {
                resources.add(resource);
            } else if (resource == null && url != null && mapperClass == null) {
                resources.add(url);
            } else if (resource == null && url == null && mapperClass != null) {
                Class<?> mapperInterface = Resources.classForName(mapperClass);
                mapper.add(mapperInterface);
            } else {
                throw new BuilderException(
                        "A mapper element may only specify a url, resource or class, but not more than one.");
            }
        }
    }
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:35,代碼來源:MybatisXMLConfigBuilder.java

示例13: handleTypeAlias

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
/**
 * 加載別名
 * @param configuration
 */
private void handleTypeAlias(Configuration configuration, XNode root) {
	log.info("load alias message...........................");
	TypeAliasRegistry typeAliasRegistry = configuration.getTypeAliasRegistry();
	XNode parent = root.evalNode("typeAliases");
	if(parent!=null){
		for (XNode child : parent.getChildren()) {
			if ("package".equals(child.getName())) {
				String typeAliasPackage = child.getStringAttribute("name");
				configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage);
				log.info("package:"+typeAliasPackage);
			} else {
				String alias = child.getStringAttribute("alias");
				String type = child.getStringAttribute("type");
				try {
					Class<?> clazz = Resources.classForName(type);
					if (alias == null) {
						typeAliasRegistry.registerAlias(clazz);
					} else {
						typeAliasRegistry.registerAlias(alias, clazz);
					}
					log.info("alias:"+alias+"   type:"+clazz);
				} catch (ClassNotFoundException e) {
					throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e);
				}
			}
		}
	}
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:33,代碼來源:MapperScanApplication.java

示例14: loadCustomVfs

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
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);
      }
    }
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:14,代碼來源:XMLConfigBuilder.java

示例15: resolveClass

import org.apache.ibatis.io.Resources; //導入方法依賴的package包/類
private Class<?> resolveClass(String className) {
  try {
    // #699 className could be null
    if (className != null) {
      return Resources.classForName(className);
    }
  } catch (ClassNotFoundException e) {
    // ignore
  }
  return null;
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:12,代碼來源:ResultSetWrapper.java


注:本文中的org.apache.ibatis.io.Resources.classForName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。