package me.prettyprint.cassandra.service;

public class CassandraHostConfigurator {

  private final String hosts;
  private int maxActive;
  private int maxIdle;
  private long maxWaitTimeWhenExhausted;
  private int cassandraThriftSocketTimeout;
  private ExhaustedPolicy exhaustedPolicy;
  
  public CassandraHostConfigurator(String hosts) {
    this.hosts = hosts;
  }
  
  public CassandraHost[] buildCassandraHosts() {
    String[] hostVals = hosts.split(",");
    CassandraHost[] cassandraHosts = new CassandraHost[hostVals.length];
    for (int x=0; x<hostVals.length; x++) {
      CassandraHost cassandraHost = new CassandraHost(hostVals[x]);     
      if (maxActive > 0)
        cassandraHost.setMaxActive(maxActive);
      if (maxIdle > 0)
        cassandraHost.setMaxIdle(maxIdle);
      if (maxWaitTimeWhenExhausted > 0) 
        cassandraHost.setMaxWaitTimeWhenExhausted(maxWaitTimeWhenExhausted);
      if (cassandraThriftSocketTimeout > 0)
        cassandraHost.setCassandraThriftSocketTimeout(cassandraThriftSocketTimeout);
      if (exhaustedPolicy != null)
        cassandraHost.setExhaustedPolicy(exhaustedPolicy);
      
      cassandraHosts[x] = cassandraHost;
    }
    return cassandraHosts;
  }

  public void setMaxActive(int maxActive) {
    this.maxActive = maxActive;
  }

  public void setMaxIdle(int maxIdle) {
    this.maxIdle = maxIdle;
  }

  public void setMaxWaitTimeWhenExhausted(long maxWaitTimeWhenExhausted) {
    this.maxWaitTimeWhenExhausted = maxWaitTimeWhenExhausted;
  }

  public void setCassandraThriftSocketTimeout(int cassandraThriftSocketTimeout) {
    this.cassandraThriftSocketTimeout = cassandraThriftSocketTimeout;
  }

  public void setExhaustedPolicy(ExhaustedPolicy exhaustedPolicy) {
    this.exhaustedPolicy = exhaustedPolicy;
  }
  
  
}

@@ -36,16 +36,42 @@
 rvice;%0A%0A
+import java.lang.String;%0A%0A
 public c
@@ -118,14 +118,8 @@
 ate 
-final 
 Stri
@@ -303,24 +303,92 @@
 dPolicy;%0A  %0A
+%0A  public CassandraHostConfigurator() %7B%0A    this.hosts = null;%0A  %7D%0A%0A
   public Cas
@@ -457,16 +457,16 @@
 %0A  %7D%0A  %0A
-
   public
@@ -502,24 +502,81 @@
 raHosts() %7B%0A
+    if (this.hosts == null) %7B%0A        return null;%0A    %7D%0A
     String%5B%5D
@@ -1356,24 +1356,92 @@
 Hosts;%0A  %7D%0A%0A
+  public void setHosts(String hosts) %7B%0A    this.hosts = hosts;%0A  %7D%0A%0A
   public voi

Modify CassandraHostConfigurator to conform to the standard JavaBeans naming convention so that it can be configured by the standard Tomcat's resource factory in context.xml. E.g.,