org.scale7.cassandra.pelops.spring
Class CommonsBackedPoolFactoryBean

java.lang.Object
  extended by org.scale7.cassandra.pelops.spring.CommonsBackedPoolFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<IThriftPool>, org.springframework.beans.factory.InitializingBean

public class CommonsBackedPoolFactoryBean
extends Object
implements org.springframework.beans.factory.FactoryBean<IThriftPool>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

Used to initialize a Pelops pool that honors Spring's context life cycle. Using this class ensures that the dependency graph that's managed by Spring won't attempt to use Pelops when it isn't available.

To use it add the following to your context file:
 <bean id="pelopsPool" class="org.scale7.cassandra.pelops.spring.CommonsBackedPoolFactoryBean">
      <property name="cluster">
          <bean class="org.scale7.cassandra.pelops.Cluster">
              <constructor-arg index="0" type="java.lang.String" value="${digitalpigeon.cassandra.host}" />
              <constructor-arg index="1" type="int" value="${digitalpigeon.cassandra.port}" />
          </bean>
      </property>
      <property name="keyspace" value="keyspace" />
 </bean>
 

NOTE: If you intend to use this class you'll need to bypass the static convenience methods on Pelops.

Inject the instance of IThriftPool created by this factory bean into your application code and use it's method directly.

For example:
 private IThriftPool pool;
 
 public void doStuff() {
     Selector selector = pool.createSelector();
     ...
 }
 


Constructor Summary
CommonsBackedPoolFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
          Initializes the Pelops pool.
 void destroy()
          Shuts down the Pelops pool.
 Cluster getCluster()
           
 CommonsBackedPool.IConnectionValidator getConnectionValidator()
           
 String getKeyspace()
           
 CommonsBackedPool.INodeSelectionStrategy getNodeSelectionStrategy()
           
 CommonsBackedPool.INodeSuspensionStrategy getNodeSuspensionStrategy()
           
 IThriftPool getObject()
          .
 Class<?> getObjectType()
          .
 OperandPolicy getOperandPolicy()
           
 CommonsBackedPool.Policy getPolicy()
           
 boolean isSingleton()
          .
 void setCluster(Cluster cluster)
           
 void setConnectionValidator(CommonsBackedPool.IConnectionValidator connectionValidator)
           
 void setKeyspace(String keyspace)
           
 void setNodeSelectionStrategy(CommonsBackedPool.INodeSelectionStrategy nodeSelectionStrategy)
           
 void setNodeSuspensionStrategy(CommonsBackedPool.INodeSuspensionStrategy nodeSuspensionStrategy)
           
 void setOperandPolicy(OperandPolicy operandPolicy)
           
 void setPolicy(CommonsBackedPool.Policy policy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonsBackedPoolFactoryBean

public CommonsBackedPoolFactoryBean()
Method Detail

getObject

public IThriftPool getObject()
                      throws Exception
.

Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<IThriftPool>
Returns:
the pool
Throws:
Exception

getObjectType

public Class<?> getObjectType()
.

Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<IThriftPool>
Returns:
IThriftPool

isSingleton

public boolean isSingleton()
.

Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<IThriftPool>
Returns:
true

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Initializes the Pelops pool.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception - if an error occurs

destroy

public void destroy()
             throws Exception
Shuts down the Pelops pool.

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception - if an error occurs
See Also:
org.scale7.cassandra.pelops.pool.IThriftPool#shutdown()}

getCluster

public Cluster getCluster()

setCluster

public void setCluster(Cluster cluster)

getKeyspace

public String getKeyspace()

setKeyspace

public void setKeyspace(String keyspace)

getPolicy

public CommonsBackedPool.Policy getPolicy()

setPolicy

public void setPolicy(CommonsBackedPool.Policy policy)

getOperandPolicy

public OperandPolicy getOperandPolicy()

setOperandPolicy

public void setOperandPolicy(OperandPolicy operandPolicy)

getNodeSelectionStrategy

public CommonsBackedPool.INodeSelectionStrategy getNodeSelectionStrategy()

setNodeSelectionStrategy

public void setNodeSelectionStrategy(CommonsBackedPool.INodeSelectionStrategy nodeSelectionStrategy)

getNodeSuspensionStrategy

public CommonsBackedPool.INodeSuspensionStrategy getNodeSuspensionStrategy()

setNodeSuspensionStrategy

public void setNodeSuspensionStrategy(CommonsBackedPool.INodeSuspensionStrategy nodeSuspensionStrategy)

getConnectionValidator

public CommonsBackedPool.IConnectionValidator getConnectionValidator()

setConnectionValidator

public void setConnectionValidator(CommonsBackedPool.IConnectionValidator connectionValidator)


Copyright © 2011. All Rights Reserved.