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

com.tairanchina.csp.dew.jdbc.DaoFactoryBean Maven / Gradle / Ivy

package com.tairanchina.csp.dew.jdbc;

import com.tairanchina.csp.dew.Dew;
import com.tairanchina.csp.dew.jdbc.proxy.ProxyInvoker;
import org.springframework.beans.factory.FactoryBean;

/**
 * Created by 迹_Jason on 2017/7/26.
 * 接口动态实现
 */
public class DaoFactoryBean implements FactoryBean {

    private Class mapperInterface;

    public Class getMapperInterface() {
        return mapperInterface;
    }

    public void setMapperInterface(Class mapperInterface) {
        this.mapperInterface = mapperInterface;
    }

    @Override
    public T getObject() throws Exception {
        return Dew.applicationContext.containsBean(mapperInterface.getName()) ?
                Dew.applicationContext.getBean(mapperInterface) : new ProxyInvoker().getInstance(mapperInterface);
    }

    @Override
    public Class getObjectType() {
        return mapperInterface;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy