当前位置: 首页>>代码示例>>Java>>正文


Java ResolverUtil.getClasses方法代码示例

本文整理汇总了Java中org.apache.ibatis.io.ResolverUtil.getClasses方法的典型用法代码示例。如果您正苦于以下问题:Java ResolverUtil.getClasses方法的具体用法?Java ResolverUtil.getClasses怎么用?Java ResolverUtil.getClasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.io.ResolverUtil的用法示例。


在下文中一共展示了ResolverUtil.getClasses方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMigrations

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的package包/类
@Override
public List<Change> getMigrations() {
  List<Change> migrations = new ArrayList<Change>();
  ResolverUtil<MigrationScript> resolver = getResolver(MigrationScript.class);
  resolver.findImplementations(MigrationScript.class, packageNames);
  Set<Class<? extends MigrationScript>> classes = resolver.getClasses();
  for (Class<? extends MigrationScript> clazz : classes) {
    try {
      if (!Modifier.isAbstract(clazz.getModifiers())) {
        MigrationScript script = clazz.newInstance();
        Change change = parseChangeFromMigrationScript(script);
        migrations.add(change);
      }
    } catch (Exception e) {
      throw new MigrationException("Could not instanciate MigrationScript: " + clazz.getName(), e);
    }
  }
  return migrations;
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:20,代码来源:JavaMigrationLoader.java

示例2: getScriptReader

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的package包/类
@Override
public Reader getScriptReader(Change change, boolean undo) {
  ResolverUtil<MigrationScript> resolver = getResolver(MigrationScript.class);
  final String className = change.getFilename();
  for (String pkg : packageNames) {
    resolver.find(new Test() {
      @Override
      public boolean matches(Class<?> type) {
        return type != null && MigrationScript.class.isAssignableFrom(type) && type.getName().equals(className);
      }
    }, pkg);
  }
  Reader reader = null;
  Set<Class<? extends MigrationScript>> classes = resolver.getClasses();
  for (Class<? extends MigrationScript> clazz : classes) {
    try {
      MigrationScript script = clazz.newInstance();
      reader = new StringReader(undo ? script.getDownScript() : script.getUpScript());
    } catch (Exception e) {
      throw new MigrationException("Could not instanciate MigrationScript: " + clazz.getName(), e);
    }
    // There should be only one script.
    break;
  }
  return reader;
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:27,代码来源:JavaMigrationLoader.java

示例3: getSoleScriptReader

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的package包/类
public <T extends SimpleScript> Reader getSoleScriptReader(Class<T> scriptClass) {
  ResolverUtil<T> resolver = getResolver(scriptClass);
  resolver.findImplementations(scriptClass, packageNames);
  Set<Class<? extends T>> classes = resolver.getClasses();
  if (classes == null || classes.isEmpty()) {
    return null;
  }
  if (classes.size() > 1) {
    throw new MigrationException("There can be only one implementation of " + scriptClass.getName());
  }
  Class<? extends T> clazz = classes.iterator().next();
  try {
    T script = clazz.newInstance();
    return new StringReader(script.getScript());
  } catch (Exception e) {
    throw new MigrationException("Could not instanciate script class: " + clazz.getName(), e);
  }
}
 
开发者ID:mybatis,项目名称:migrations,代码行数:19,代码来源:JavaMigrationLoader.java

示例4: setResource

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的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

示例5: addMappers

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的package包/类
/**
 * @since 3.2.2
 */
public void addMappers(String packageName, Class<?> superType) {
  ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<Class<?>>();
  resolverUtil.find(new ResolverUtil.IsA(superType), packageName);
  Set<Class<? extends Class<?>>> mapperSet = resolverUtil.getClasses();
  for (Class<?> mapperClass : mapperSet) {
    addMapper(mapperClass);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:12,代码来源:MapperRegistry.java

示例6: registerAliases

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的package包/类
public void registerAliases(String packageName, Class<?> superType){
  ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<Class<?>>();
  resolverUtil.find(new ResolverUtil.IsA(superType), packageName);
  Set<Class<? extends Class<?>>> typeSet = resolverUtil.getClasses();
  for(Class<?> type : typeSet){
    // Ignore inner classes and interfaces (including package-info.java)
    // Skip also inner classes. See issue #6
    if (!type.isAnonymousClass() && !type.isInterface() && !type.isMemberClass()) {
      registerAlias(type);
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:13,代码来源:TypeAliasRegistry.java

示例7: register

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的package包/类
public void register(String packageName) {
  ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<Class<?>>();
  resolverUtil.find(new ResolverUtil.IsA(TypeHandler.class), packageName);
  Set<Class<? extends Class<?>>> handlerSet = resolverUtil.getClasses();
  for (Class<?> type : handlerSet) {
    //Ignore inner classes and interfaces (including package-info.java) and abstract classes
    if (!type.isAnonymousClass() && !type.isInterface() && !Modifier.isAbstract(type.getModifiers())) {
      register(type);
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:12,代码来源:TypeHandlerRegistry.java

示例8: addMappers

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的package包/类
/**
 * @since 3.2.2
 */
public void addMappers(String packageName, Class<?> superType) {
  //查找包下所有是superType的类
  ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<Class<?>>();
  resolverUtil.find(new ResolverUtil.IsA(superType), packageName);
  Set<Class<? extends Class<?>>> mapperSet = resolverUtil.getClasses();
  for (Class<?> mapperClass : mapperSet) {
    addMapper(mapperClass);
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:13,代码来源:MapperRegistry.java

示例9: registerAliases

import org.apache.ibatis.io.ResolverUtil; //导入方法依赖的package包/类
public void registerAliases(String packageName, Class<?> superType){
//TODO ResolverUtil
  ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<Class<?>>();
  resolverUtil.find(new ResolverUtil.IsA(superType), packageName);
  Set<Class<? extends Class<?>>> typeSet = resolverUtil.getClasses();
  for(Class<?> type : typeSet){
    // Ignore inner classes and interfaces (including package-info.java)
    // Skip also inner classes. See issue #6
    if (!type.isAnonymousClass() && !type.isInterface() && !type.isMemberClass()) {
      registerAlias(type);
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:14,代码来源:TypeAliasRegistry.java


注:本文中的org.apache.ibatis.io.ResolverUtil.getClasses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。