org.globus.wsrf.container
Class ServiceThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.globus.wsrf.container.ServiceThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
GSIServiceThread

public class ServiceThread
extends java.lang.Thread

This class is responsible for reading the request from the request queue, format it, and pass it through the Axis engine.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private static byte[] ACTION_HEADER
           
private  java.lang.String baseURL
           
private  byte[] buf
           
private static int BUFSIZ
           
private  boolean chunked
           
private static byte[] CHUNKED
           
private static byte[] CLOSE
           
private static byte[] CONNECTION_CLOSE
           
private static byte[] CONNECTION_HEADER
           
protected  boolean connectionClose
           
protected static byte[] CONTENT_LENGTH
           
private static byte[] CONTENT_LOCATION_HEADER
           
protected static java.lang.String CONTENT_TYPE
           
private static byte[] CONTENT_TYPE_HEADER
           
private  long contentLength
           
private  java.lang.StringBuffer contentLocation
           
private  java.lang.StringBuffer contentType
           
protected  ServiceDispatcher dispatcher
           
private static byte[] ENCODING_HEADER
           
protected  org.apache.axis.AxisEngine engine
           
private static java.lang.String FILE_NOT_FOUND
           
private static byte[] FILE_NOT_FOUND_MSG
           
private  java.lang.StringBuffer fileName
           
private static byte[] GET_HEADER
           
private static byte[] HEAD_HEADER
           
private static byte[] HEADER_ENDER
           
protected static byte[] HTML_MIME_STUFF
           
protected static byte[] HTTP_10
           
protected static byte[] HTTP_11
           
private static byte[] HTTP_BASE_VERSION
           
private static int HTTP_GET
           
private static int HTTP_HEAD
           
private static int HTTP_POST
           
private  boolean http11
           
private  int httpRequest
           
private static org.globus.util.I18n i18n
           
private  java.io.InputStream in
           
private static byte[] ISE
           
protected static byte[] JAR_MIME_STUFF
           
protected static byte[] JNLP_MIME_STUFF
           
private static byte[] LENGTH_HEADER
           
private static org.apache.commons.logging.Log logger
           
protected  org.apache.axis.MessageContext msgContext
           
private static byte[] OK
           
(package private) static PerformanceLog performanceLogger
           
(package private) static PerformanceLog performanceProcessLogger
           
private static byte[] POST_HEADER
           
private  boolean processing
           
protected  ServiceRequestQueue queue
           
private  java.nio.ByteBuffer readBuffer
           
private  java.nio.channels.Selector readSelector
           
private static int RELOAD_END
           
private static int RELOAD_END_CLEAN
           
private static int RELOAD_START
           
private  int reloadState
           
private  org.apache.axis.Message responseMsg
           
protected static byte[] SEPARATOR
           
private static byte[] SERVER_FAULT
           
private  java.lang.StringBuffer soapAction
           
private static byte[] SU
           
protected  ServiceThreadPool threadPool
           
private static byte[] toLower
           
private static byte[] TRANSFER_ENCODING_CHUNKED
           
protected static byte[] UNAUTH
           
private static org.apache.axis.components.uuid.UUIDGen uuidGen
           
private  boolean webStartEnabled
           
private  java.nio.ByteBuffer writeBuffer
           
private  java.nio.channels.Selector writeSelector
           
protected static byte[] XML_MIME_STUFF
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServiceThread(ServiceDispatcher dispatcher)
           
 
Method Summary
private static void clearCache(javax.naming.Context context, java.lang.String name)
           
private  byte[] createHeaderReply(byte[] code, byte[] contentType, long length)
           
 void dispose()
           
protected  byte[] doFault(java.lang.Exception e, org.apache.axis.MessageContext msgContext, java.lang.String filepart)
           
protected  void doGet(org.apache.axis.AxisEngine engine, org.apache.axis.MessageContext msgContext, java.io.OutputStream out, java.lang.String filePart, boolean returnContent)
           
protected  void doGetSub(org.apache.axis.AxisEngine engine, org.apache.axis.MessageContext msgContext, java.io.OutputStream out, java.lang.String filePart, boolean returnContent)
           
protected  void doPost(org.apache.axis.AxisEngine engine, org.apache.axis.MessageContext msgContext)
           
protected  void doWSDL(org.apache.axis.AxisEngine engine, org.apache.axis.MessageContext msgContext, java.io.OutputStream out, java.lang.String filePart)
           
 void endReload(boolean deepClean)
           
private static java.lang.String exceptionToHTML(java.lang.String errorMsg, java.lang.Throwable e)
           
protected  void finishProcessing(int timeout)
          Waits until the thread is done processing the request or the specified timeout expires.
static java.lang.String getConfigRootPath(org.apache.axis.AxisEngine engine)
           
private static java.lang.String getHost(org.apache.axis.AxisEngine engine)
           
protected  java.lang.String getProtocol()
           
static java.lang.String getWebRootPath(org.apache.axis.AxisEngine engine)
           
private static void handleOutOfMemoryError()
           
 void initialize()
           
protected  boolean isProcessing()
           
 boolean matches(byte[] buf, byte[] target)
          does tolower[buf] match the target byte array, up to the target's length?
 boolean matches(byte[] buf, int bufIdx, byte[] target)
          Case-insensitive match of a target byte [] to a source byte [], starting from a particular offset into the source.
private  void parseHeaders(java.io.InputStream is)
          Read all mime headers, returning the value of Content-Length and SOAPAction.
private  void parseRequest(byte[] buf, int n, int offset)
           
protected  void postProcess(ServiceRequest request, java.io.OutputStream out, java.io.InputStream in)
           
protected  void preProcess(ServiceRequest request)
           
protected  void process(ServiceRequest request)
           
private  void processReloadState()
           
private  int readLine(java.io.InputStream is, byte[] b, int off, int len)
          Read a single line from the input stream
private  void reset()
           
 void run()
           
protected  void setProcessing(boolean processing)
           
 void startReload()
           
private  void writeResponse(java.io.OutputStream out, byte[] status, byte[] contentType, byte[] message)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uuidGen

private static final org.apache.axis.components.uuid.UUIDGen uuidGen

logger

private static org.apache.commons.logging.Log logger

i18n

private static org.globus.util.I18n i18n

performanceLogger

static PerformanceLog performanceLogger

performanceProcessLogger

static PerformanceLog performanceProcessLogger

dispatcher

protected ServiceDispatcher dispatcher

queue

protected ServiceRequestQueue queue

threadPool

protected ServiceThreadPool threadPool

engine

protected org.apache.axis.AxisEngine engine

msgContext

protected org.apache.axis.MessageContext msgContext

in

private java.io.InputStream in

responseMsg

private org.apache.axis.Message responseMsg

soapAction

private java.lang.StringBuffer soapAction

fileName

private java.lang.StringBuffer fileName

contentType

private java.lang.StringBuffer contentType

contentLocation

private java.lang.StringBuffer contentLocation

httpRequest

private int httpRequest

http11

private boolean http11

chunked

private boolean chunked

contentLength

private long contentLength

connectionClose

protected boolean connectionClose

HTTP_10

protected static final byte[] HTTP_10

HTTP_11

protected static final byte[] HTTP_11

OK

private static final byte[] OK

UNAUTH

protected static final byte[] UNAUTH

ISE

private static final byte[] ISE

SU

private static final byte[] SU

FILE_NOT_FOUND

private static final java.lang.String FILE_NOT_FOUND
See Also:
Constant Field Values

FILE_NOT_FOUND_MSG

private static final byte[] FILE_NOT_FOUND_MSG

XML_MIME_STUFF

protected static final byte[] XML_MIME_STUFF

HTML_MIME_STUFF

protected static final byte[] HTML_MIME_STUFF

JNLP_MIME_STUFF

protected static final byte[] JNLP_MIME_STUFF

JAR_MIME_STUFF

protected static final byte[] JAR_MIME_STUFF

CONTENT_TYPE

protected static final java.lang.String CONTENT_TYPE
See Also:
Constant Field Values

CONTENT_LENGTH

protected static final byte[] CONTENT_LENGTH

CONNECTION_CLOSE

private static final byte[] CONNECTION_CLOSE

TRANSFER_ENCODING_CHUNKED

private static final byte[] TRANSFER_ENCODING_CHUNKED

SERVER_FAULT

private static final byte[] SERVER_FAULT

SEPARATOR

protected static final byte[] SEPARATOR

toLower

private static final byte[] toLower

LENGTH_HEADER

private static final byte[] LENGTH_HEADER

CONTENT_TYPE_HEADER

private static final byte[] CONTENT_TYPE_HEADER

CONTENT_LOCATION_HEADER

private static final byte[] CONTENT_LOCATION_HEADER

ACTION_HEADER

private static final byte[] ACTION_HEADER

CONNECTION_HEADER

private static final byte[] CONNECTION_HEADER

GET_HEADER

private static final byte[] GET_HEADER

HEAD_HEADER

private static final byte[] HEAD_HEADER

POST_HEADER

private static final byte[] POST_HEADER

HEADER_ENDER

private static final byte[] HEADER_ENDER

ENCODING_HEADER

private static final byte[] ENCODING_HEADER

CHUNKED

private static final byte[] CHUNKED

CLOSE

private static final byte[] CLOSE

HTTP_BASE_VERSION

private static final byte[] HTTP_BASE_VERSION

HTTP_GET

private static final int HTTP_GET
See Also:
Constant Field Values

HTTP_HEAD

private static final int HTTP_HEAD
See Also:
Constant Field Values

HTTP_POST

private static final int HTTP_POST
See Also:
Constant Field Values

BUFSIZ

private static final int BUFSIZ
See Also:
Constant Field Values

buf

private byte[] buf

webStartEnabled

private boolean webStartEnabled

baseURL

private java.lang.String baseURL

readSelector

private java.nio.channels.Selector readSelector

writeSelector

private java.nio.channels.Selector writeSelector

readBuffer

private java.nio.ByteBuffer readBuffer

writeBuffer

private java.nio.ByteBuffer writeBuffer

processing

private boolean processing

RELOAD_START

private static final int RELOAD_START
See Also:
Constant Field Values

RELOAD_END

private static final int RELOAD_END
See Also:
Constant Field Values

RELOAD_END_CLEAN

private static final int RELOAD_END_CLEAN
See Also:
Constant Field Values

reloadState

private int reloadState
Constructor Detail

ServiceThread

public ServiceThread(ServiceDispatcher dispatcher)
Method Detail

startReload

public void startReload()

endReload

public void endReload(boolean deepClean)

initialize

public void initialize()
                throws java.lang.Exception
Throws:
java.lang.Exception

dispose

public void dispose()

getHost

private static java.lang.String getHost(org.apache.axis.AxisEngine engine)
                                 throws java.io.IOException
Throws:
java.io.IOException

getWebRootPath

public static java.lang.String getWebRootPath(org.apache.axis.AxisEngine engine)
                                       throws java.io.IOException
Throws:
java.io.IOException

getConfigRootPath

public static java.lang.String getConfigRootPath(org.apache.axis.AxisEngine engine)

setProcessing

protected void setProcessing(boolean processing)

isProcessing

protected boolean isProcessing()

finishProcessing

protected void finishProcessing(int timeout)
                         throws java.lang.InterruptedException
Waits until the thread is done processing the request or the specified timeout expires. If the thread is currently not processing any request, it returns immediately.

Throws:
java.lang.InterruptedException

processReloadState

private void processReloadState()

reset

private void reset()

clearCache

private static void clearCache(javax.naming.Context context,
                               java.lang.String name)
                        throws javax.naming.NamingException
Throws:
javax.naming.NamingException

handleOutOfMemoryError

private static void handleOutOfMemoryError()

run

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

getProtocol

protected java.lang.String getProtocol()

preProcess

protected void preProcess(ServiceRequest request)

postProcess

protected void postProcess(ServiceRequest request,
                           java.io.OutputStream out,
                           java.io.InputStream in)

process

protected void process(ServiceRequest request)

createHeaderReply

private byte[] createHeaderReply(byte[] code,
                                 byte[] contentType,
                                 long length)
                          throws java.io.IOException
Throws:
java.io.IOException

writeResponse

private void writeResponse(java.io.OutputStream out,
                           byte[] status,
                           byte[] contentType,
                           byte[] message)

exceptionToHTML

private static java.lang.String exceptionToHTML(java.lang.String errorMsg,
                                                java.lang.Throwable e)

doWSDL

protected void doWSDL(org.apache.axis.AxisEngine engine,
                      org.apache.axis.MessageContext msgContext,
                      java.io.OutputStream out,
                      java.lang.String filePart)
               throws java.io.IOException
Throws:
java.io.IOException

doGet

protected void doGet(org.apache.axis.AxisEngine engine,
                     org.apache.axis.MessageContext msgContext,
                     java.io.OutputStream out,
                     java.lang.String filePart,
                     boolean returnContent)

doGetSub

protected void doGetSub(org.apache.axis.AxisEngine engine,
                        org.apache.axis.MessageContext msgContext,
                        java.io.OutputStream out,
                        java.lang.String filePart,
                        boolean returnContent)
                 throws java.io.IOException
Throws:
java.io.IOException

doPost

protected void doPost(org.apache.axis.AxisEngine engine,
                      org.apache.axis.MessageContext msgContext)
               throws org.apache.axis.AxisFault
Throws:
org.apache.axis.AxisFault

doFault

protected byte[] doFault(java.lang.Exception e,
                         org.apache.axis.MessageContext msgContext,
                         java.lang.String filepart)

readLine

private int readLine(java.io.InputStream is,
                     byte[] b,
                     int off,
                     int len)
              throws java.io.IOException
Read a single line from the input stream

Parameters:
is - inputstream to read from
b - byte array to read into
off - starting offset into the byte array
len - maximum number of bytes to read
Throws:
java.io.IOException

parseRequest

private void parseRequest(byte[] buf,
                          int n,
                          int offset)
                   throws java.io.IOException
Throws:
java.io.IOException

parseHeaders

private void parseHeaders(java.io.InputStream is)
                   throws java.io.IOException
Read all mime headers, returning the value of Content-Length and SOAPAction.

Parameters:
is - InputStream to read from
Throws:
java.io.IOException

matches

public boolean matches(byte[] buf,
                       byte[] target)
does tolower[buf] match the target byte array, up to the target's length?


matches

public boolean matches(byte[] buf,
                       int bufIdx,
                       byte[] target)
Case-insensitive match of a target byte [] to a source byte [], starting from a particular offset into the source.