Class CommonsHTTPSender.BackgroundHTTPThread
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.manifoldcf.connectorcommon.common.CommonsHTTPSender.BackgroundHTTPThread
-
- All Implemented Interfaces:
java.lang.Runnable
- Enclosing class:
- CommonsHTTPSender
protected static class CommonsHTTPSender.BackgroundHTTPThread extends java.lang.ThreadThis thread does the actual socket communication with the server. It's set up so that it can be abandoned at shutdown time. The way it works is as follows: - it starts the transaction - it receives the response, and saves that for the calling class to inspect - it transfers the data part to an input stream provided to the calling class - it shuts the connection down If there is an error, the sequence is aborted, and an exception is recorded for the calling class to examine. The calling class basically accepts the sequence above. It starts the thread, and tries to get a response code. If instead an exception is seen, the exception is thrown up the stack.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanabortThreadprotected java.io.InputStreambodyStreamprotected java.nio.charset.CharsetcharSetprotected org.apache.http.client.methods.HttpRequestBaseexecuteMethodprotected java.lang.ThrowablegeneralExceptionprotected org.apache.http.client.HttpClienthttpClientClient and method, all preconfiguredprotected org.apache.http.HttpResponseresponseprotected java.lang.ThrowableresponseExceptionprotected java.lang.ThrowableshutdownExceptionprotected booleanstreamCreatedprotected java.lang.ThrowablestreamExceptionprotected XThreadInputStreamthreadStream
-
Constructor Summary
Constructors Constructor Description BackgroundHTTPThread(org.apache.http.client.HttpClient httpClient, org.apache.http.client.methods.HttpRequestBase executeMethod)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()protected voidcheckException(java.lang.Throwable exception)voidfinishUp()java.nio.charset.CharsetgetCharSet()java.lang.StringgetFirstHeader(java.lang.String headerName)intgetResponseCode()java.util.Map<java.lang.String,java.util.List<java.lang.String>>getResponseHeaders()java.lang.StringgetResponseStatus()java.io.InputStreamgetSafeInputStream()voidrun()-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
httpClient
protected final org.apache.http.client.HttpClient httpClient
Client and method, all preconfigured
-
executeMethod
protected final org.apache.http.client.methods.HttpRequestBase executeMethod
-
response
protected org.apache.http.HttpResponse response
-
responseException
protected java.lang.Throwable responseException
-
threadStream
protected XThreadInputStream threadStream
-
bodyStream
protected java.io.InputStream bodyStream
-
charSet
protected java.nio.charset.Charset charSet
-
streamCreated
protected boolean streamCreated
-
streamException
protected java.lang.Throwable streamException
-
abortThread
protected boolean abortThread
-
shutdownException
protected java.lang.Throwable shutdownException
-
generalException
protected java.lang.Throwable generalException
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
getResponseCode
public int getResponseCode() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getResponseStatus
public java.lang.String getResponseStatus() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getResponseHeaders
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getFirstHeader
public java.lang.String getFirstHeader(java.lang.String headerName) throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getSafeInputStream
public java.io.InputStream getSafeInputStream() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
getCharSet
public java.nio.charset.Charset getCharSet() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionorg.apache.http.HttpException
-
abort
public void abort()
-
finishUp
public void finishUp() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
checkException
protected void checkException(java.lang.Throwable exception) throws java.io.IOException, org.apache.http.HttpException- Throws:
java.io.IOExceptionorg.apache.http.HttpException
-
-