use of com.ikoori.vip.common.annotion.DataSource in project vip by guangdada.
the class TestServiceImpl method testGuns.
@Override
@DataSource(name = DSEnum.DATA_SOURCE_GUNS)
public void testGuns() {
Test test = testMapper.selectById(1);
test.setId(33);
test.insert();
}
use of com.ikoori.vip.common.annotion.DataSource in project vip by guangdada.
the class TestServiceImpl method testBiz.
@Override
@DataSource(name = DSEnum.DATA_SOURCE_BIZ)
public void testBiz() {
Test test = testMapper.selectById(1);
test.setId(22);
test.insert();
}
use of com.ikoori.vip.common.annotion.DataSource in project vip by guangdada.
the class MultiSourceExAop method around.
@Around("cut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
Signature signature = point.getSignature();
MethodSignature methodSignature = null;
if (!(signature instanceof MethodSignature)) {
throw new IllegalArgumentException("该注解只能用于方法");
}
methodSignature = (MethodSignature) signature;
Object target = point.getTarget();
Method currentMethod = target.getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes());
DataSource datasource = currentMethod.getAnnotation(DataSource.class);
if (datasource != null) {
DataSourceContextHolder.setDataSourceType(datasource.name());
log.debug("设置数据源为:" + datasource.name());
} else {
DataSourceContextHolder.setDataSourceType(DSEnum.DATA_SOURCE_GUNS);
log.debug("设置数据源为:dataSourceCurrent");
}
try {
return point.proceed();
} finally {
log.debug("清空数据源信息!");
DataSourceContextHolder.clearDataSourceType();
}
}
Aggregations