Class ProxyConnection

java.lang.Object
  |
  +--ProxyConnection
All Implemented Interfaces:
java.lang.Runnable

public class ProxyConnection
extends java.lang.Object
implements java.lang.Runnable

Represents a connection between a client and a server; a static thread manager manages the number of active and existing threads, and a static ServerSocket waits for connections.


Field Summary
(package private)  java.io.InputStream clientSideIn
          inputstream from the client
(package private)  java.io.OutputStream clientSideOut
          outputstream to the client
(package private)  java.net.Socket clientSideSocket
          the interface with the client
(package private) static ThreadManager man
          manages the number of active and existing threads
(package private)  boolean mustCloseConnection
          to verify if the connection must be closed
(package private)  java.io.InputStream serverSideIn
          inputstream from the server
(package private)  java.io.OutputStream serverSideOut
          outputstream to the server
(package private)  java.net.Socket serverSideSocket
          the interface with the server
(package private) static java.net.ServerSocket serverSocket
          all the connection are catched on this ServerSocket
 
Constructor Summary
(package private) ProxyConnection()
          Default constructor, used by the ThreadManager.
(package private) ProxyConnection(int port)
          Starts the proxy on the port passed as parameter, or, if already used, on a free port.
 
Method Summary
(package private)  void launch()
          Asks the thread manager to create minThreads threads.
 void run()
          Waits for a connection and manages it until either the client or the server wants close it.
(package private)  void setAttributs(int maxThreads, int minThreads, int maxSpareThreads, int minSpareThreads)
          Changes the bounds for the number of threads.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

man

static ThreadManager man
manages the number of active and existing threads

serverSocket

static java.net.ServerSocket serverSocket
all the connection are catched on this ServerSocket

serverSideSocket

java.net.Socket serverSideSocket
the interface with the server

clientSideSocket

java.net.Socket clientSideSocket
the interface with the client

clientSideIn

java.io.InputStream clientSideIn
inputstream from the client

clientSideOut

java.io.OutputStream clientSideOut
outputstream to the client

serverSideIn

java.io.InputStream serverSideIn
inputstream from the server

serverSideOut

java.io.OutputStream serverSideOut
outputstream to the server

mustCloseConnection

boolean mustCloseConnection
to verify if the connection must be closed
Constructor Detail

ProxyConnection

ProxyConnection()
Default constructor, used by the ThreadManager.

ProxyConnection

ProxyConnection(int port)
          throws java.io.IOException
Starts the proxy on the port passed as parameter, or, if already used, on a free port.
Parameters:
port - the TCP port where waiting for connections
Method Detail

setAttributs

void setAttributs(int maxThreads,
                  int minThreads,
                  int maxSpareThreads,
                  int minSpareThreads)
            throws IllegalValuesException
Changes the bounds for the number of threads. It asks the thread manager to do it.
Parameters:
maxThreads - maximum number of existing Threads
minThreads - minimum number of existing Threads
maxSpareThreads - maximum number of disactivated Threads
minSpareThreads - minimum number of disactivated Threads
Throws:
IllegalValuesException -  

launch

void launch()
      throws java.io.IOException,
             java.lang.InstantiationException,
             java.lang.IllegalAccessException
Asks the thread manager to create minThreads threads.
Throws:
IOException, - InstantiationException, IllegalValuesException

run

public void run()
Waits for a connection and manages it until either the client or the server wants close it.
Specified by:
run in interface java.lang.Runnable