PooliT v2.0

org.ascentphase.poolit.handlers
Class SocketHandler

java.lang.Object
  extended byorg.ascentphase.poolit.handlers.SocketHandler
All Implemented Interfaces:
PoolHandler

public class SocketHandler
extends java.lang.Object
implements PoolHandler

Handler for Socket connections. This class must be subclassed and override the methods postCreate() and/or preDestroy() if work is to be done after a Socket is created or before it is closed, respectively. Examples might be authentication after establishing a connection, or issuing a logout command prior to disconnect.

Author:
huyd

Constructor Summary
SocketHandler(java.net.InetAddress address, int port)
           
SocketHandler(java.lang.String host, int port)
           
 
Method Summary
 java.lang.Object create()
          Called by a Pooler to create a new object.
 void destroy(java.lang.Object o)
          Called by a Pooler to perform any cleanup and destroy the object for garbage collection.
protected  void postCreate(java.net.Socket s)
          This method should be overridden by subclasses that need to perform connection setup prior to having the Socket used.
protected  void preDestroy(java.net.Socket s)
          This method should be overridden by subclasses that need to perform connection cleanup after it is no longer used and to be garbage- collected.
 boolean verify(java.lang.Object o)
          Called by a Pooler to verify that the object is in a consistent and useable state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketHandler

public SocketHandler(java.net.InetAddress address,
                     int port)

SocketHandler

public SocketHandler(java.lang.String host,
                     int port)
              throws java.net.UnknownHostException
Method Detail

create

public java.lang.Object create()
                        throws CreateException
Description copied from interface: PoolHandler
Called by a Pooler to create a new object.

Specified by:
create in interface PoolHandler
Throws:
CreateException
See Also:
PoolHandler.create()

destroy

public void destroy(java.lang.Object o)
Description copied from interface: PoolHandler
Called by a Pooler to perform any cleanup and destroy the object for garbage collection.

Specified by:
destroy in interface PoolHandler
Parameters:
o - the object to be destroyed
See Also:
PoolHandler.destroy(java.lang.Object)

verify

public boolean verify(java.lang.Object o)
Description copied from interface: PoolHandler
Called by a Pooler to verify that the object is in a consistent and useable state.

Specified by:
verify in interface PoolHandler
Parameters:
o - the object to be tested
See Also:
PoolHandler.verify(java.lang.Object)

postCreate

protected void postCreate(java.net.Socket s)
                   throws CreateException
This method should be overridden by subclasses that need to perform connection setup prior to having the Socket used. By default, this class does not perform any connection setup.

Parameters:
s - the Socket to setup
Throws:
CreateException

preDestroy

protected void preDestroy(java.net.Socket s)
This method should be overridden by subclasses that need to perform connection cleanup after it is no longer used and to be garbage- collected. By default, this class does not perform any connection cleanup.

Parameters:
s - the Socket to cleanup.

PooliT v2.0

Copyright © 2005 Ascent Phase Corp.