You need to create a FactoryBean for this. Roughly the class should look something like this
Code:
public class KeyspaceFactoryBean<Keyspace> implements FactoryBean<Keyspace> {
private String clusterName;
private String keyspaceName;
private String connectionPoolName;
private int portNo;
private String seeds;
public String getSeeds() {
return seeds;
}
public void setSeeds(String seeds) {
this.seeds = seeds;
}
public int getPortNo() {
return portNo;
}
public void setPortNo(int portNo) {
this.portNo = portNo;
}
public void setConnectionPoolName(String name) {
this.connectionPoolName = name;
}
public String getConnectionPoolName() {
return this.connectionPoolName;
}
public String getKeyspaceName() {
return this.keyspaceName;
}
public void setKeyspaceName(String name) {
this.keyspaceName = name;
}
public void setClusterName(String name) {
this.clusterName = name;
}
public String getClusterName() {
return this.clusterName;
}
public Keyspace getObject() throws Exception {
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(clusterName)
.forKeyspace(keyspaceName)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl(connectionPoolName )
.setPort(portNo)
.setSeeds(seeds)
)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
Keyspace keyspace = context.getEntity();
return keyspace;
}
}
now this can be declared inside your XML Configuration like this
Code:
<bean id="keyspace" class="KeyspaceFactoryBean">
<property name="clusterName" value="clusterName" />
<property name="keyspaceName" value="keyspaceName" />
<property name="connectionPoolName" value="connectionPoolName" />
<property name="clusterName" value="clusterName" />
<property name="portNo" value="9110" />
<property name="seeds" value="someAppropriateSeedsValue" />
</bean>
As suggested