Class AbstractNioFetcher<C extends BaseFetcherConfig>
java.lang.Object
com.norconex.crawler.core.fetch.AbstractFetcher<C>
com.norconex.crawler.fs.fetch.impl.AbstractNioFetcher<C>
- Type Parameters:
C- configuration type
- All Implemented Interfaces:
Configurable<C>,EventListener<Event>,Fetcher,EventListener,Consumer<Event>
- Direct Known Subclasses:
AdlsGen2Fetcher,ArchiveFetcher,AzureBlobFetcher,CmisFetcher,FtpFetcher,GcsFetcher,HdfsFetcher,LocalFetcher,S3Fetcher,SftpFetcher,SmbFetcher,WebDavFetcher
Base class for fetchers relying on Java NIO.2 (java.nio.file),
either via the JDK's built-in providers or third-party
FileSystemProvider implementations found on the
classpath.
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanfetch(FetchRequest fetchRequest) protected FolderPathsFetchResponseprotected booleanfetchContent(Doc doc, @NonNull Path path) protected voidfetcherShutdown(CrawlerSession crawler) Invoked once per fetcher when the crawler ends.protected FileFetchResponseprotected voidfetchMetadata(Doc doc, @NonNull Path path, @NonNull BasicFileAttributes attrs) protected FileSystemgetOrOpenFileSystem(URI referenceUri, Map<String, ?> env) Gets theFileSystemfor the given URI's host and port, opening and caching a new one on first use.inthashCode()protected abstract PathresolvePath(String reference) Resolves a crawler reference (as found onDoc.getReference()) into a NIO.2Path.toString()Methods inherited from class com.norconex.crawler.core.fetch.AbstractFetcher
accept, accept, acceptRequest, fetcherStartupMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.norconex.commons.lang.config.Configurable
getConfiguration
-
Constructor Details
-
AbstractNioFetcher
public AbstractNioFetcher()
-
-
Method Details
-
fetcherShutdown
Description copied from class:AbstractFetcherInvoked once per fetcher when the crawler ends. Default implementation does nothing.- Overrides:
fetcherShutdownin classAbstractFetcher<C extends BaseFetcherConfig>- Parameters:
crawler- crawler
-
fetch
- Throws:
FetchException
-
resolvePath
Resolves a crawler reference (as found onDoc.getReference()) into a NIO.2Path.- Parameters:
reference- the reference to resolve- Returns:
- the resolved path
- Throws:
IOException- if the reference cannot be resolved
-
getOrOpenFileSystem
Gets theFileSystemfor the given URI's host and port, opening and caching a new one on first use. Credentials always come from the supplied environment, never from the URI: some providers (e.g., sftp-fs/ftp-fs) echo the connected username back into the user-info component of paths obtained from a listing (viaPath.toUri()), yet reject that same user-info component if it is fed back intoFileSystems.newFileSystem(URI, Map). Any user-info on the given URI is therefore ignored.- Parameters:
referenceUri- a URI identifying the target file system (only its scheme, host and port are used)env- environment used only the first time a given host/port is resolved- Returns:
- the file system for that host and port
- Throws:
IOException- if the file system could not be opened
-
fetchFileObject
- Throws:
FetchException
-
fetchChildPaths
protected FolderPathsFetchResponse fetchChildPaths(FolderPathsFetchRequest req) throws FetchException - Throws:
FetchException
-
fetchMetadata
protected void fetchMetadata(Doc doc, @NonNull @NonNull Path path, @NonNull @NonNull BasicFileAttributes attrs) throws IOException - Throws:
IOException
-
fetchContent
- Throws:
IOException
-
equals
- Overrides:
equalsin classAbstractFetcher<C extends BaseFetcherConfig>
-
canEqual
- Overrides:
canEqualin classAbstractFetcher<C extends BaseFetcherConfig>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractFetcher<C extends BaseFetcherConfig>
-
toString
- Overrides:
toStringin classAbstractFetcher<C extends BaseFetcherConfig>
-