All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.ibatis.solon.integration.DbBeanBuilderImpl Maven / Gradle / Ivy

There is a newer version: 3.0.0-M4
Show newest version
package org.apache.ibatis.solon.integration;

import org.apache.ibatis.solon.annotation.Db;
import org.noear.solon.core.BeanBuilder;
import org.noear.solon.core.BeanWrap;
import org.noear.solon.data.datasource.DsUtils;

/**
 * @author noear
 * @since 3.0
 */
public class DbBeanBuilderImpl implements BeanBuilder {
    @Override
    public void doBuild(Class clz, BeanWrap bw, Db anno) throws Throwable {
        if (clz.isInterface() == false) {
            return;
        }

        DsUtils.observeDs(bw.context(), anno.value(), (dsWrap) -> {
            create0(clz, dsWrap);
        });
    }

    private void create0(Class clz, BeanWrap dsBw) {
        Object raw = MybatisAdapterManager.get(dsBw).getMapper(clz);
        dsBw.context().wrapAndPut(clz, raw);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy