本文整理汇总了Java中org.apache.ibatis.io.ResolverUtil.findImplementations方法的典型用法代码示例。如果您正苦于以下问题:Java ResolverUtil.findImplementations方法的具体用法?Java ResolverUtil.findImplementations怎么用?Java ResolverUtil.findImplementations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ibatis.io.ResolverUtil
的用法示例。
在下文中一共展示了ResolverUtil.findImplementations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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);
}
}