package com.eactive.eai.rms.common.datasource;

/**
 * 다음 과 같이 사용 합니다. 
 * {@code         
 *      new SpecifiedDataSourceExecutor(DataSourceType.DEVE_COMMON) {
 *          protected void doExecute() {
 *              // call transactional inboundErrorInfoDao or transactional service
 *          }
 *      }.execute();
 * @author kspark
 */
public abstract class SpecifiedDataSourceExecutor<T> {

    protected DataSourceType dataSourceType;

    public SpecifiedDataSourceExecutor(DataSourceType dataSourceType) {
        super();
        this.dataSourceType = dataSourceType;
    }

    public T execute() {
        try {
            return doExecute();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    protected abstract T doExecute() throws Exception;

}
