CADI.Proxy.Core
Class ProxyWorker

java.lang.Object
  extended by java.lang.Thread
      extended by CADI.Proxy.Core.ProxyWorker
All Implemented Interfaces:
java.lang.Runnable

public class ProxyWorker
extends java.lang.Thread

Version:
1.0 2009/08/22
Author:
Group on Interactive Coding of Images (GICI)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  boolean busy
          Indicates if the thread is carrying out a task.
private  boolean finish
          Indicates whether the thread has to finish when it is working with a request with the keep-alive mode set.
private  HTTPRequest httpRequest
          Definition in HTTPRequest.
private  HTTPResponseSender httpResponseSender
           
private  int keepAliveTimeout
          Definition in Scheduler.keepAliveTimeout.
private  CADILog log
          It is an object that will be used to log the server process
private  java.io.OutputStream os
          Is an output stream that will be used to send the server response to the client.
private  ProxyCacheLogicalTargets proxyCacheLogicalTargets
          Definition in CADI.Proxy.Proxy#logicalTargetList.
private  ProxyMutex proxyMutex
          Definition in Proxy.proxyMutex
private  ProxyRequestedWOIs proxyRequestedWOIs
          Definition in CADI.Proxy.Proxy#proxyRequestedWOIs.
private  int proxyType
          Indicates the type of proxy that will be run.
private  RequestQueue requestQueue
          Definition in Proxy.requestQueue.
private  java.net.Socket socket
          Contains the client socket of which request is being processed.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ProxyWorker(java.lang.String threadName, RequestQueue requestQueue, ProxyCacheLogicalTargets proxyCacheLogicalTargets, ProxyRequestedWOIs proxyRequestedWOIs, ProxyMutex proxyMutex, CADILog log)
          Constructor.
 
Method Summary
 void finish()
          This method is used to indicate that the thread has to finish.
 java.lang.Thread.State getState()
           
 boolean isBusy()
          This method is used to indicate if the thread is or no busy processing a task.
 void list(java.io.PrintStream out)
          Prints this ProxyWorker out to the specified output stream.
private  void listenNewRequest()
           
private  void processCachedProxy()
           
private  void processRequest()
           
private  void processTransparentProxy()
           
 void run()
           
private  void sendHTTPResponseError(int statusCode, java.lang.String reasonPhrase)
           
 void setKeepAliveTimeout(int keepAliveTimeout)
          Sets the keepAliveTimeout attribute.
 void setProxyType(int proxyType)
          Sets the proxyType attribute.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

requestQueue

private RequestQueue requestQueue
Definition in Proxy.requestQueue.


proxyCacheLogicalTargets

private ProxyCacheLogicalTargets proxyCacheLogicalTargets
Definition in CADI.Proxy.Proxy#logicalTargetList.


proxyRequestedWOIs

private ProxyRequestedWOIs proxyRequestedWOIs
Definition in CADI.Proxy.Proxy#proxyRequestedWOIs.


log

private CADILog log
It is an object that will be used to log the server process


finish

private boolean finish
Indicates whether the thread has to finish when it is working with a request with the keep-alive mode set.

See Also:
finish()

busy

private boolean busy
Indicates if the thread is carrying out a task. If the thread is waiting for a new task, the busy attribute is false.


socket

private java.net.Socket socket
Contains the client socket of which request is being processed.


httpRequest

private HTTPRequest httpRequest
Definition in HTTPRequest.


keepAliveTimeout

private int keepAliveTimeout
Definition in Scheduler.keepAliveTimeout.


proxyType

private int proxyType
Indicates the type of proxy that will be run.

Further information, see ProxyDefaultValues.PROXY_TYPE.


proxyMutex

private ProxyMutex proxyMutex
Definition in Proxy.proxyMutex


os

private java.io.OutputStream os
Is an output stream that will be used to send the server response to the client.


httpResponseSender

private HTTPResponseSender httpResponseSender
Constructor Detail

ProxyWorker

public ProxyWorker(java.lang.String threadName,
                   RequestQueue requestQueue,
                   ProxyCacheLogicalTargets proxyCacheLogicalTargets,
                   ProxyRequestedWOIs proxyRequestedWOIs,
                   ProxyMutex proxyMutex,
                   CADILog log)
Constructor.

Parameters:
threadName - is a string with the name of the thread.
requestQueue - definition in requestQueue.
logicalTargetList - definition in #logicalTargetList.
log - definition in log.
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

setProxyType

public void setProxyType(int proxyType)
Sets the proxyType attribute.

Parameters:
proxyType - definition in proxyType attribute.

finish

public void finish()
This method is used to indicate that the thread has to finish.


isBusy

public boolean isBusy()
This method is used to indicate if the thread is or no busy processing a task.

Returns:
true if the thread is processing a task. Otherwise, it returns false.

getState

public java.lang.Thread.State getState()
Overrides:
getState in class java.lang.Thread

setKeepAliveTimeout

public void setKeepAliveTimeout(int keepAliveTimeout)
Sets the keepAliveTimeout attribute.

Parameters:
keepAliveTimeout - definition in keepAliveTimeout.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Thread

list

public void list(java.io.PrintStream out)
Prints this ProxyWorker out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.

processRequest

private void processRequest()
                     throws WarningException,
                            ErrorException
Throws:
WarningException
ErrorException

listenNewRequest

private void listenNewRequest()
                       throws WarningException,
                              ErrorException
Throws:
WarningException
ErrorException

sendHTTPResponseError

private void sendHTTPResponseError(int statusCode,
                                   java.lang.String reasonPhrase)

processTransparentProxy

private void processTransparentProxy()
                              throws ErrorException
Throws:
ErrorException

processCachedProxy

private void processCachedProxy()
                         throws ErrorException
Throws:
ErrorException


CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)