org.apache.nutch.protocol

## Class ProtocolFactory

- java.lang.Object
- - org.apache.nutch.protocol.ProtocolFactory

-     public class ProtocolFactory
      extends java.lang.Object

  Creates and caches `Protocol` plugins. Protocol plugins should define the attribute "protocolName" with the name of the protocol that they implement. Configuration object is used for caching. Cache key is constructed from appending protocol name (eg. http) to constant `Protocol.X_POINT_ID`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Map<java.lang.String,java.lang.String>` | `defaultProtocolImplMapping`
    `protected java.util.Map<java.lang.String,java.lang.String>` | `hostProtocolMapping`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProtocolFactory(Configuration conf)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Protocol` | `getProtocol(java.lang.String urlString)` Returns the appropriate `Protocol` implementation for a url.
    `Protocol` | `getProtocol(java.net.URL url)` Returns the appropriate `Protocol` implementation for a url.
    `Protocol` | `getProtocolById(java.lang.String id)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### defaultProtocolImplMapping

          protected java.util.Map<java.lang.String,java.lang.String> defaultProtocolImplMapping

    - #### hostProtocolMapping

          protected java.util.Map<java.lang.String,java.lang.String> hostProtocolMapping

  - ### Constructor Detail

    - #### ProtocolFactory

          public ProtocolFactory(Configuration conf)

  - ### Method Detail

    - #### getProtocol

          public Protocol getProtocol(java.lang.String urlString)
                               throws ProtocolNotFound

      Returns the appropriate `Protocol` implementation for a url.
      Parameters:
        `urlString` - Url String
      Returns:
        The appropriate `Protocol` implementation for a given `URL`.
      Throws:
        `ProtocolNotFound` - when Protocol can not be found for urlString or urlString is not a valid URL

    - #### getProtocol

          public Protocol getProtocol(java.net.URL url)
                               throws ProtocolNotFound

      Returns the appropriate `Protocol` implementation for a url.
      Parameters:
        `url` - URL to be fetched by returned `Protocol` implementation
      Returns:
        The appropriate `Protocol` implementation for a given `URL`.
      Throws:
        `ProtocolNotFound` - when Protocol can not be found for url

    - #### getProtocolById

          public Protocol getProtocolById(java.lang.String id)
                                   throws PluginRuntimeException

      Parameters:
        `id` - protocol plugin ID, e.g., `org.apache.nutch.protocol.http`
      Returns:
        protocol instance for the given ID
      Throws:
        `PluginRuntimeException` - if plugin not found or failed to instantiate

Copyright © 2019 The Apache Software Foundation