org.noear.wood.impl.IMapperAdaptorImpl Maven / Gradle / Ivy
package org.noear.wood.impl;
import org.noear.wood.BaseMapper;
import org.noear.wood.DbContext;
import org.noear.wood.DbProcedure;
import org.noear.wood.mapper.IMapperAdaptor;
import java.util.Map;
/**
* @author noear
* @since 1.1
*/
public class IMapperAdaptorImpl implements IMapperAdaptor {
static final String hint = "To use the mapper feature, use the 'wood.plus' dependency package";
private IMapperAdaptor real;
public IMapperAdaptorImpl() {
try {
Class> clz = IMapperAdaptor.class.getClassLoader().loadClass("org.noear.wood.impl.IMapperAdaptorPlusImpl");
real = (IMapperAdaptor) clz.getDeclaredConstructor().newInstance();
} catch (Exception e) {
}
}
@Override
public DbProcedure createXmlProcedure(DbContext db, String process, Map args) {
if (real == null) {
throw new UnsupportedOperationException(hint);
} else {
return real.createXmlProcedure(db, process, args);
}
}
@Override
public BaseMapper createMapperBase(DbContext db, Class clz, String tableName) {
if (real == null) {
throw new UnsupportedOperationException(hint);
} else {
return real.createMapperBase(db, clz, tableName);
}
}
@Override
public T createMapper(DbContext db, Class clz) {
if (real == null) {
throw new UnsupportedOperationException(hint);
} else {
return real.createMapper(db, clz);
}
}
@Override
public T createMapper(DbContext db, String xsqlid, Map args) throws Exception {
if (real == null) {
throw new UnsupportedOperationException(hint);
} else {
return real.createMapper(db, xsqlid, args);
}
}
}