spring hadoop 系列(二)

一、源码分析
/**
*
* HbaseAccessor作为HbaseTemplate以及HbaseIntercepter的基类;同时也定义
* 公共的HBase Configuration 以及 HTableInterfaceFactory
*
*/
public abstract class HbaseAccessor implements InitializingBean {
        // 设定编码
private String encoding;
private Charset charset = HbaseUtils.getCharset(encoding);
        // 定义公共属性 HTableInterfaceFactory  及 Configuration
private HTableInterfaceFactory tableFactory;
private Configuration configuration;

@Override
public void afterPropertiesSet() {
Assert.notNull(configuration, " a valid configuration is required");
// detect charset
charset = HbaseUtils.getCharset(encoding);
}

/**
* Sets the table factory.
*
* @param tableFactory The tableFactory to set.
*/
public void setTableFactory(HTableInterfaceFactory tableFactory) {
this.tableFactory = tableFactory;
}

/**
* Sets the encoding.
*
* @param encoding The encoding to set.
*/
public void setEncoding(String encoding) {
this.encoding = encoding;
}

/**
* Sets the configuration.
*
* @param configuration The configuration to set.
*/
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}

public Charset getCharset() {
return charset;
}

public HTableInterfaceFactory getTableFactory() {
return tableFactory;
}

public Configuration getConfiguration() {
return configuration;
}
}
该类是spring-hadoop访问hbase的基类,定义访问hbase的通用部分,用作抽象基类,不能直接使用。

猜你喜欢

转载自dalan-123.iteye.com/blog/2259751