Package com.norconex.crawler.core
Class CrawlerCallbacks
java.lang.Object
com.norconex.crawler.core.CrawlerCallbacks
- All Implemented Interfaces:
EventListener<Event>,EventListener,Consumer<Event>
Optional callbacks invoked at specific times in the crawler life-cycle. The flow of execution for a crawl is as follow (callbacks are bold):
- Launch crawler.
- Invoke beforeSession.
- Initialize crawl session.
- For each command:
- Invoke beforeCommand.
- Execute command.
- For each document:
- Invoke beforeDocumentProcessing.
- Process document (fetch, parse, transform, etc.)
- Invoke afterDocumentProcessing.
- Invoke beforeDocumentFinalizing.
- Finalize document (upsert/delete, close resources, etc.)
- Invoke afterDocumentFinalizing.
- Invoke afterCommand
- Invoke afterSession
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfaceConvenience interface providing a default implementation of execute that ignores all commands butCrawlerCommandand offers an overloadedacceptmethod with a single argument. -
Method Summary
Modifier and TypeMethodDescriptionvoidDispatches crawler lifecycle events to the appropriate hook.builder()BiConsumer<CrawlerSession, Class<? extends Command>> Invoked after a command has been executed, but before resources are closed.Invoked after a crawl session has been destroyed and resources closed.BiConsumer<CrawlerSession, Class<? extends Command>> Invoked before a command is executed, after the session and crawl context have been initialized.Invoked before the crawl session gets initialized (which is also before any command gets executed).
-
Method Details
-
accept
Dispatches crawler lifecycle events to the appropriate hook. This method is called automatically when this instance is registered as anEventListeneron the crawler'sEventManager. -
builder
-
getBeforeSession
Invoked before the crawl session gets initialized (which is also before any command gets executed). Modifying the CrawlerConfig is generally safe here. -
getAfterSession
Invoked after a crawl session has been destroyed and resources closed. -
getBeforeCommand
Invoked before a command is executed, after the session and crawl context have been initialized. Rely on the supplied command class to know which command.- See Also:
-
getAfterCommand
Invoked after a command has been executed, but before resources are closed. Rely on the supplied command class to know which command.- See Also:
-
getBeforeDocumentProcessing
-
getAfterDocumentProcessing
-
getBeforeDocumentFinalizing
-
getAfterDocumentFinalizing
-