com.github.zhengframework.mybatis.MyBatisMultiModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zheng-mybatis Show documentation
Show all versions of zheng-mybatis Show documentation
zheng framework module: mybatis support
package com.github.zhengframework.mybatis;
import static com.google.inject.name.Names.named;
import com.github.zhengframework.configuration.ConfigurationAwareModule;
import com.github.zhengframework.configuration.ConfigurationBeanMapper;
import java.util.Map;
import java.util.Map.Entry;
public class MyBatisMultiModule extends ConfigurationAwareModule {
@Override
protected void configure() {
Map myBatisConfigMap = ConfigurationBeanMapper
.resolve(getConfiguration(), MyBatisConfig.class);
for (Entry entry : myBatisConfigMap.entrySet()) {
String name = entry.getKey();
MyBatisConfig myBatisConfig = entry.getValue();
if (!name.isEmpty()) {
install(new MyBatisPrivateModule(named(name), myBatisConfig));
} else {
install(new MyBatisPrivateModule(null, myBatisConfig));
}
}
}
}