Reputation: 5758
I want to know what is the difference between the
scraper.exitExecution() and
scraper.stopExecution() and
scraper.finishExecutingProcessor()
I have tried looking in to the java doc, I could not find anything over there. There seems to be no proper documentation for this. Please help.
I need a method to stop the execution of the scraper after some timeout, How can I do this?
Upvotes: 0
Views: 59
Reputation: 34900
Why not just download sourses
of the library and look inside it?
Source code analyze shows, that the difference is only in statuses which these functions are set.
STATUS_STOPPED
is interpreted as that configuration was aborted by user.
STATUS_EXIT
is interpreted as configuration was just exited.
I.e. they are almost equal.
Let's do it together:
One:
public void exitExecution(String message) {
setStatus(STATUS_EXIT);
this.message = message;
}
Two:
public void stopExecution() {
setStatus(STATUS_STOPPED);
}
Next, going to BaseProcessor
class, this is one of the two places where STATUS_EXIT
or STATUS_STOPPED
statuses are used:
public Variable run(Scraper scraper, ScraperContext context) {
int scraperStatus = scraper.getStatus();
if (scraperStatus == Scraper.STATUS_STOPPED || scraperStatus == Scraper.STATUS_EXIT) {
return EmptyVariable.INSTANCE;
}
...
}
Another one in class ConfigPanel
:
public void onExecutionEnd(Scraper scraper) {
...
} else if (status == Scraper.STATUS_STOPPED) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
GuiUtils.showWarningMessage("Configuration \"" + configDocument.getName() + "\" aborted by user!");
ide.setTabIcon(ConfigPanel.this, ResourceManager.SMALL_FINISHED_ICON);
}
});
} else if ( status == Scraper.STATUS_EXIT && message != null && !"".equals(message.trim()) ) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
GuiUtils.showWarningMessage("Configuration exited: " + message);
ide.setTabIcon(ConfigPanel.this, ResourceManager.SMALL_FINISHED_ICON);
}
});
}
...
}
Upvotes: 1