// 判断table name 集合是否为空
public void afterPropertiesSet() {
super.afterPropertiesSet();
Assert.notEmpty(tableNames, "at least one table needs to be specified");
}
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
// 存放table name 与 hbase table 关联映射
Set<String> boundTables = new LinkedHashSet<String>();
// 通过HbaseSynchronizationManager判断对应的table name
// 是否已经绑定
// 若是没有绑定 则根据tableName、hbase Configuration
// 、charset、table factory构建HTableInterface对象
// 完成绑定之后,执行方法调用;并返回处理结果
for (String tableName : tableNames) {
if (!HbaseSynchronizationManager.hasResource(tableName)) {
boundTables.add(tableName);
HTableInterface table = HbaseUtils.getHTable(tableName, getConfiguration(), getCharset(), getTableFactory());
HbaseSynchronizationManager.bindResource(tableName, table);
}
}
public void setTableNames(String[] tableNames) {
this.tableNames = tableNames;
}
/**
* Sets whether to convert any {@link IOException} raised to a Spring DataAccessException,
* compatible with the <code>org.springframework.dao</code> exception hierarchy.
* <p>Default is "true". Turn this flag off to let the caller receive raw exceptions
* as-is, without any wrapping.
* @see org.springframework.dao.DataAccessException
*
* @param exceptionConversionEnabled enable exceptionConversion
*/
public void setExceptionConversionEnabled(boolean exceptionConversionEnabled) {
this.exceptionConversionEnabled = exceptionConversionEnabled;
}
}
该类主要使用hbase table之前完成bind的操作;完成table name到具体的hbase table之间的映射;不过在执行完成对应的操作之后来释放绑定的资源