toolbox.pooling
Class SocketResourcePool

Package class diagram package SocketResourcePool
java.lang.Object
  extended by toolbox.pooling.ResourcePoolImpl
      extended by toolbox.pooling.SocketResourcePool
All Implemented Interfaces:
ResourcePool

public class SocketResourcePool
extends ResourcePoolImpl

ResourcePool implementation to do client socket connection pooling.


Field Summary
 
Fields inherited from class toolbox.pooling.ResourcePoolImpl
m_customProps
 
Constructor Summary
SocketResourcePool()
          Default constructor
 
Method Summary
protected  java.lang.Object createResource(XMLProperties xmlProps, int count)
          Create a SocketConfig instance from the given XMLProperties and retrieve a Socket instance from the config instance.
protected  void destroyResource(java.lang.Object resource)
          Destroy the given Socket.
protected  boolean isResourceValid(java.lang.Object resource)
          Validates the given socket connection and returns the validation state.
protected  void preInit(XMLProperties xmlProps)
          Initialises the components required by this pool to perform resource creation and validation.
 
Methods inherited from class toolbox.pooling.ResourcePoolImpl
destroy, getName, getResource, getStatus, getStatusString, init, releaseResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketResourcePool

public SocketResourcePool()
Default constructor

Method Detail

preInit

protected void preInit(XMLProperties xmlProps)
                throws ResourcePoolException
Initialises the components required by this pool to perform resource creation and validation.

Specified by:
preInit in class ResourcePoolImpl
Parameters:
xmlProps - XML configuration properties.
Throws:
ResourcePoolException - if the custom initialisation fails.

createResource

protected java.lang.Object createResource(XMLProperties xmlProps,
                                          int count)
                                   throws ResourcePoolException
Create a SocketConfig instance from the given XMLProperties and retrieve a Socket instance from the config instance.

Specified by:
createResource in class ResourcePoolImpl
Parameters:
xmlProps - XML configuration properties.
count - int indicating how many times this method has been called.
Returns:
Socket instance that was created.
Throws:
ResourcePoolException - if the socket connection cannot be created.

destroyResource

protected void destroyResource(java.lang.Object resource)
                        throws ResourcePoolException
Destroy the given Socket.

Specified by:
destroyResource in class ResourcePoolImpl
Parameters:
resource - Socket resource to destroy.
Throws:
ResourcePoolException - if the connection could not be closed.

isResourceValid

protected boolean isResourceValid(java.lang.Object resource)
                           throws ResourcePoolException
Validates the given socket connection and returns the validation state.

Specified by:
isResourceValid in class ResourcePoolImpl
Parameters:
resource - Socket connection to validate.
Returns:
boolean indicating the state of the socket connection.
Throws:
ResourcePoolException