Package org.apache.nutch.protocol
Class ProtocolFactory
- java.lang.Object
-
- org.apache.nutch.protocol.ProtocolFactory
-
public class ProtocolFactory extends Object
Creates and cachesProtocol
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 constantProtocol.X_POINT_ID
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,String>
defaultProtocolImplMapping
protected Map<String,String>
hostProtocolMapping
-
Constructor Summary
Constructors Constructor Description ProtocolFactory(Configuration conf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Protocol
getProtocol(String urlString)
Returns the appropriateProtocol
implementation for a url.Protocol
getProtocol(URL url)
Returns the appropriateProtocol
implementation for a url.Protocol
getProtocolById(String id)
-
-
-
Constructor Detail
-
ProtocolFactory
public ProtocolFactory(Configuration conf)
-
-
Method Detail
-
getProtocol
public Protocol getProtocol(String urlString) throws ProtocolNotFound
Returns the appropriateProtocol
implementation for a url.- Parameters:
urlString
- Url String- Returns:
- The appropriate
Protocol
implementation for a givenURL
. - Throws:
ProtocolNotFound
- when Protocol can not be found for urlString or urlString is not a valid URL
-
getProtocol
public Protocol getProtocol(URL url) throws ProtocolNotFound
Returns the appropriateProtocol
implementation for a url.- Parameters:
url
- URL to be fetched by returnedProtocol
implementation- Returns:
- The appropriate
Protocol
implementation for a givenURL
. - Throws:
ProtocolNotFound
- when Protocol can not be found for 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
-
-