Class ProtocolFactory


  • public class ProtocolFactory
    extends 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 Detail

      • defaultProtocolImplMapping

        protected Map<String,​String> defaultProtocolImplMapping
    • Constructor Detail

      • ProtocolFactory

        public ProtocolFactory​(Configuration conf)
    • Method Detail

      • getProtocol

        public Protocol getProtocol​(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
      • getProtocolById

        public Protocol getProtocolById​(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