3.0.1: 2011-11-10

net.sf.basedb.util.uri.http
Class HttpConnectionManager

java.lang.Object
  extended by net.sf.basedb.util.uri.http.HttpConnectionManager
All Implemented Interfaces:
ConnectionManager

public class HttpConnectionManager
extends Object
implements ConnectionManager

Connection manager implementation that support HTTP and HTTPS URI:s. It supports Basic and Digest authentication schemes. When HTTPS is used it provides support for validation of both server- and client-side certificates.

Since:
3.0
Author:
Nicklas
Last modified
$Date: 2011-03-15 13:55:59 +0100 (Tue, 15 Mar 2011) $

Nested Class Summary
static class HttpConnectionManager.CloseableHttpClient
          Closable implementation that closes the given HttpClient when the close() method is called.
 
Field Summary
private  UriMetadata metadata
           
private  ConnectionParameters parameters
           
private  URI uri
           
 
Constructor Summary
HttpConnectionManager(URI uri, ConnectionParameters parameters)
           
 
Method Summary
 org.apache.http.client.HttpClient createHttpClient(URI uri, ConnectionParameters parameters)
          Get a HttpClient object that has been configured to access the given URI.
 UriMetadata createMetadata(URI uri, org.apache.http.HttpResponse response)
          Read metadata from the given http response and put the information in a UriMetadata object.
 InputStream getInputStream()
          Get an InputStream for reading the contents of the resource.
 UriMetadata getMetadata()
          Get metadata about the resource.
 URI getURI()
          Get the URI of the resource we are interested in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uri

private final URI uri

parameters

private final ConnectionParameters parameters

metadata

private UriMetadata metadata
Constructor Detail

HttpConnectionManager

public HttpConnectionManager(URI uri,
                             ConnectionParameters parameters)
Method Detail

getURI

public URI getURI()
Description copied from interface: ConnectionManager
Get the URI of the resource we are interested in.

Specified by:
getURI in interface ConnectionManager
Returns:
An URI

getInputStream

public InputStream getInputStream()
                           throws IOException
Description copied from interface: ConnectionManager
Get an InputStream for reading the contents of the resource.

Specified by:
getInputStream in interface ConnectionManager
Returns:
An InputStream object, or null if the no data is available
Throws:
IOException - If there is an error creating the stream

getMetadata

public UriMetadata getMetadata()
                        throws IOException
Description copied from interface: ConnectionManager
Get metadata about the resource. If no metadata can be obtained the handler should still create an empty UriMetadata object.

Specified by:
getMetadata in interface ConnectionManager
Returns:
A metadata object
Throws:
IOException - If there is an error getting the metadata

createHttpClient

public org.apache.http.client.HttpClient createHttpClient(URI uri,
                                                          ConnectionParameters parameters)
                                                   throws IOException
Get a HttpClient object that has been configured to access the given URI.

Throws:
IOException

createMetadata

public UriMetadata createMetadata(URI uri,
                                  org.apache.http.HttpResponse response)
Read metadata from the given http response and put the information in a UriMetadata object. This method uses whatever information that is in the response headers:


3.0.1: 2011-11-10