com.quadrique.jbuildingblocks.core.io.socket.client
Class JbbSocketHandler

java.lang.Object
  extended by com.quadrique.jbuildingblocks.core.io.socket.client.JbbSocketHandler

public class JbbSocketHandler
extends Object

This class implements a synchronized pool of connection handler threads. Each thread is blocked waiting for a new connection request to handle. This is the base class that defines the common behavior of all connection handlers and it has to be overridden in a derived class that implements the connection handling itself.

Version:
1.0.0
Author:
Hervé Rivere

Method Summary
 void closeConnection()
          to releaseConnection the connection
 void newConnection(String zHostName, int zPortNb)
          to establish a socket connection to the given server
static JbbSocketHandler newInstance()
           
 String performHttp11Query(String zQuery, int zNbOfLoops)
          to perform a HTTP 1.1 query: this method analysis the http header of the response and reads as many as "content-length" bytes for the body (unless the connection is closed or any other i/o exception occurs or time-out occurs)
 String performRawQuery(String zQuery, int zNbOfLoops)
          to perform a raw query: this method doesn't know anything about the underlying protocol and the length of the data to be received.
 String readFileContent(String zFileName)
          Read the content of the given file in a string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static JbbSocketHandler newInstance()
Returns:
a new instance

newConnection

public void newConnection(String zHostName,
                          int zPortNb)
                   throws Exception
to establish a socket connection to the given server

Throws:
Exception

readFileContent

public String readFileContent(String zFileName)
                       throws Exception
Read the content of the given file in a string

Throws:
Exception

performRawQuery

public String performRawQuery(String zQuery,
                              int zNbOfLoops)
                       throws Exception
to perform a raw query: this method doesn't know anything about the underlying protocol and the length of the data to be received. As a result, the method keeps on trying to pump data from the socket until the connection is closed by the server or the maximum number of loops (i.e. timeout) is reached

Throws:
Exception

performHttp11Query

public String performHttp11Query(String zQuery,
                                 int zNbOfLoops)
                          throws Exception
to perform a HTTP 1.1 query: this method analysis the http header of the response and reads as many as "content-length" bytes for the body (unless the connection is closed or any other i/o exception occurs or time-out occurs)

Throws:
Exception

closeConnection

public void closeConnection()
                     throws Exception
to releaseConnection the connection

Throws:
Exception


Copyright © 2001-2008 Quadrique Corporation. All Rights Reserved.