Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.archive.crawler.fetcher
Class HeritrixProtocolSocketFactory

    java.lang.Object
      org.archive.crawler.fetcher.HeritrixProtocolSocketFactory

All Implemented Interfaces:
  org.apache.commons.httpclient.protocol.ProtocolSocketFactory

    public class HeritrixProtocolSocketFactory

extends java.lang.Object
implements org.apache.commons.httpclient.protocol.ProtocolSocketFactory

Version of protocol socket factory that tries to get IP from heritrix IP cache -- if its been set into the HttpConnectionParameters. Copied the guts of DefaultProtocolSocketFactory. This factory gets setup by `FetchHTTP`.

Version:
  $Date: 2006-08-29 22:47:03 +0000 (Tue, 29 Aug 2006) $, $Revision: 4553 $
Author:
  stack

Constructor Summary
`HeritrixProtocolSocketFactory()` Constructor.

Method Summary
`java.net.Socket` | `createSocket(java.lang.String host, int port)`
`java.net.Socket` | `createSocket(java.lang.String host, int port, java.net.InetAddress localAddress, int localPort)`
`java.net.Socket` | `createSocket(java.lang.String host, int port, java.net.InetAddress localAddress, int localPort, org.apache.commons.httpclient.params.HttpConnectionParams params)` Attempts to get a new socket connection to the given host within the given time limit.
`boolean` | `equals(java.lang.Object obj)` All instances of DefaultProtocolSocketFactory are the same.
`(package private) static java.net.InetAddress` | `getHostAddress(ServerCache cache, java.lang.String host)` Get host address using first the heritrix cache of addresses, then, failing that, go to the dnsjava cache.
`int` | `hashCode()` All instances of DefaultProtocolSocketFactory have the same hash code.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### HeritrixProtocolSocketFactory

    public HeritrixProtocolSocketFactory()

  Constructor.

Method Detail

### createSocket

    public java.net.Socket createSocket(java.lang.String host,
                                        int port,
                                        java.net.InetAddress localAddress,
                                        int localPort)
                                 throws java.io.IOException,
                                        java.net.UnknownHostException

  Specified by:
    `createSocket` in interface `org.apache.commons.httpclient.protocol.ProtocolSocketFactory`
  Throws:
    `java.io.IOException`
    `java.net.UnknownHostException`
  See Also:
    `createSocket(java.lang.String,int,java.net.InetAddress,int)`

### createSocket

    public java.net.Socket createSocket(java.lang.String host,
                                        int port,
                                        java.net.InetAddress localAddress,
                                        int localPort,
                                        org.apache.commons.httpclient.params.HttpConnectionParams params)
                                 throws java.io.IOException,
                                        java.net.UnknownHostException,
                                        org.apache.commons.httpclient.ConnectTimeoutException

  Attempts to get a new socket connection to the given host within the given time limit.

  This method employs several techniques to circumvent the limitations of older JREs that do not support connect timeout. When running in JRE 1.4 or above reflection is used to call Socket#connect(SocketAddress endpoint, int timeout) method. When executing in older JREs a controller thread is executed. The controller thread attempts to create a new socket within the given limit of time. If socket constructor does not return until the timeout expires, the controller terminates and throws an `ConnectTimeoutException`

  Specified by:
    `createSocket` in interface `org.apache.commons.httpclient.protocol.ProtocolSocketFactory`
  Parameters:
    `host` - the host name/IP
    `port` - the port on the host
    `localAddress` - the local host name/IP to bind the socket to
    `localPort` - the port on the local machine
    `params` - `Http connection parameters`
  Returns:
    Socket a new socket
  Throws:
    `java.io.IOException` - if an I/O error occurs while creating the socket
    `java.net.UnknownHostException` - if the IP address of the host cannot be
    `java.io.IOException` - if an I/O error occurs while creating the socket
    `java.net.UnknownHostException` - if the IP address of the host cannot be determined
    `org.apache.commons.httpclient.ConnectTimeoutException` - if socket cannot be connected within the given time limit
  Since:
    3.0

### getHostAddress

    static java.net.InetAddress getHostAddress(ServerCache cache,
                                               java.lang.String host)
                                        throws java.io.IOException

  Get host address using first the heritrix cache of addresses, then, failing that, go to the dnsjava cache. Default access and static so can be used by other classes in this package.

  Parameters:
    `host` - Host whose address we're to fetch.
  Returns:
    an IP address for this host or null if one can't be found in caches.
  Throws:
    `java.io.IOException` - If we fail to get host IP from ServerCache.

### createSocket

    public java.net.Socket createSocket(java.lang.String host,
                                        int port)
                                 throws java.io.IOException,
                                        java.net.UnknownHostException

  Specified by:
    `createSocket` in interface `org.apache.commons.httpclient.protocol.ProtocolSocketFactory`
  Throws:
    `java.io.IOException`
    `java.net.UnknownHostException`
  See Also:
    `ProtocolSocketFactory.createSocket(java.lang.String,int)`

### equals

    public boolean equals(java.lang.Object obj)

  All instances of DefaultProtocolSocketFactory are the same.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `obj` - Object to compare.
  Returns:
    True if equal

### hashCode

    public int hashCode()

  All instances of DefaultProtocolSocketFactory have the same hash code.

  Overrides:
    `hashCode` in class `java.lang.Object`
  Returns:
    Hash code for this object.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2008 Internet Archive. All Rights Reserved.