Package com.crawljax.core.plugin
Class Plugins
- java.lang.Object
-
- com.crawljax.core.plugin.Plugins
-
@Singleton public class Plugins extends Object
Class for invoking plugins. The methods in this class are invoked from the Crawljax Core.
-
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.ImmutableMap<Class<? extends Plugin>,com.codahale.metrics.Counter>counters(package private) static com.google.common.collect.ImmutableSet<Class<? extends Plugin>>KNOWN_PLUGINSprivate static org.slf4j.LoggerLOGGERprivate com.google.common.collect.ImmutableListMultimap<Class<? extends Plugin>,Plugin>pluginsprivate com.codahale.metrics.MetricRegistryregistry
-
Constructor Summary
Constructors Constructor Description Plugins(CrawljaxConfiguration config, com.codahale.metrics.MetricRegistry registry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddPlugins(List<? extends Plugin> plugins, com.google.common.collect.ImmutableListMultimap.Builder<Class<? extends Plugin>,Plugin> builder)booleanequals(Object object)inthashCode()private voidincrementFailCounterFor(Plugin plugin)com.google.common.collect.ImmutableSet<String>pluginNames()private com.google.common.collect.ImmutableMap<Class<? extends Plugin>,com.codahale.metrics.Counter>registerCounters(com.codahale.metrics.MetricRegistry registry)private voidreportFailingPlugin(Plugin plugin, RuntimeException e)voidrunOnBrowserClosingPlugins(CrawlerContext context)voidrunOnBrowserCreatedPlugins(EmbeddedBrowser newBrowser)Load and run the OnBrowserCreatedPlugins, this call has been made from the browser pool when a new browser has been created and ready to be used by the Crawler.voidrunOnFireEventFailedPlugins(CrawlerContext context, Eventable eventable, List<Eventable> path)Load and run the OnFireEventFailedPlugins, this call has been made from the fireEvent when the event is not fireable.voidrunOnInvariantViolationPlugins(Invariant invariant, CrawlerContext context)Run the OnInvariantViolation plugins when an Invariant is violated.voidrunOnNewStatePlugins(CrawlerContext context, StateVertex newState)load and run the OnNewStatePlugins.voidrunOnRevisitStatePlugins(CrawlerContext context, StateVertex currentState)load and run the onRevisitStateValidator.voidrunOnUrlFirstLoadPlugins(CrawlerContext context)voidrunOnUrlLoadPlugins(CrawlerContext context)load and run the OnUrlLoadPlugins.voidrunPostCrawlingPlugins(CrawlSession session, ExitNotifier.ExitStatus exitReason)load and run the postCrawlingPlugins.voidrunPreCrawlingPlugins(CrawljaxConfiguration config)Run thePreCrawlingPlugins.voidrunPreStateCrawlingPlugins(CrawlerContext context, com.google.common.collect.ImmutableList<CandidateElement> candidateElements, StateVertex state)load and run the PreStateCrawlingPlugins.StringtoString()
-
-
-
Field Detail
-
KNOWN_PLUGINS
static final com.google.common.collect.ImmutableSet<Class<? extends Plugin>> KNOWN_PLUGINS
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
plugins
private final com.google.common.collect.ImmutableListMultimap<Class<? extends Plugin>,Plugin> plugins
-
counters
private final com.google.common.collect.ImmutableMap<Class<? extends Plugin>,com.codahale.metrics.Counter> counters
-
registry
private final com.codahale.metrics.MetricRegistry registry
-
-
Constructor Detail
-
Plugins
@Inject public Plugins(CrawljaxConfiguration config, com.codahale.metrics.MetricRegistry registry)
-
-
Method Detail
-
registerCounters
private com.google.common.collect.ImmutableMap<Class<? extends Plugin>,com.codahale.metrics.Counter> registerCounters(com.codahale.metrics.MetricRegistry registry)
-
addPlugins
private void addPlugins(List<? extends Plugin> plugins, com.google.common.collect.ImmutableListMultimap.Builder<Class<? extends Plugin>,Plugin> builder)
-
reportFailingPlugin
private void reportFailingPlugin(Plugin plugin, RuntimeException e)
-
incrementFailCounterFor
private void incrementFailCounterFor(Plugin plugin)
-
runOnUrlLoadPlugins
public void runOnUrlLoadPlugins(CrawlerContext context)
load and run the OnUrlLoadPlugins. The OnUrlLoadPlugins are run just after the Browser has gone to the initial url. Not only the first time but also every time the Core navigates back. Warning the instance of the browser offered is not a clone but the current and after wards used browser instance, changes and operations may cause 'strange' behaviour.This method can be called from multiple threads with different
CrawlerContext- Parameters:
context- the currentCrawlerContextfor this crawler.
-
runOnNewStatePlugins
public void runOnNewStatePlugins(CrawlerContext context, StateVertex newState)
load and run the OnNewStatePlugins. OnNewStatePlugins are plugins that are ran when a new state was found. This also happens for the Index State. Warning the session is not a clone, changing the session can cause strange behaviour of Crawljax.This method can be called from multiple threads with different
CrawlerContext- Parameters:
context- the currentCrawlerContextfor this crawler.newState- The new state
-
runOnInvariantViolationPlugins
public void runOnInvariantViolationPlugins(Invariant invariant, CrawlerContext context)
Run the OnInvariantViolation plugins when an Invariant is violated. Invariant are checked when the state machine is updated that is when the dom is changed after a click on a clickable. When a invariant fails this kind of plugins are executed. Warning the session is not a clone, changing the session can cause strange behaviour of Crawljax.- Parameters:
invariant- the failed invariantscontext- the currentCrawlerContextfor this crawler.
-
runPostCrawlingPlugins
public void runPostCrawlingPlugins(CrawlSession session, ExitNotifier.ExitStatus exitReason)
load and run the postCrawlingPlugins. PostCrawlingPlugins are executed after the crawling is finished Warning: changing the session can change the behavior of other post crawl plugins. It is not a clone!- Parameters:
exitReason- The reason Crawljax has stopped.session- the currentCrawlSessionfor this crawler.
-
runOnRevisitStatePlugins
public void runOnRevisitStatePlugins(CrawlerContext context, StateVertex currentState)
load and run the onRevisitStateValidator. As a difference to other SessionPlugins this plugin needs an explicit current state because the session.getCurrentState() does not contain the correct current state because we are in back-tracking- Parameters:
context- the currentCrawlerContextfor this crawler.currentState- the state the 'back tracking' operation is currently in
-
runPreStateCrawlingPlugins
public void runPreStateCrawlingPlugins(CrawlerContext context, com.google.common.collect.ImmutableList<CandidateElement> candidateElements, StateVertex state)
load and run the PreStateCrawlingPlugins. Method that is called before the current state is crawled (before firing events on the current DOM state). Example: filter candidate elements. Warning the session and candidateElements are not clones, changes will result in changed behaviour.- Parameters:
context- the currentCrawlerContextfor this crawler.candidateElements- the elements which crawljax is about to crawlstate- The state being violated.
-
runPreCrawlingPlugins
public void runPreCrawlingPlugins(CrawljaxConfiguration config)
Run thePreCrawlingPlugins. NoCrawlerContextis available at this stage.- Parameters:
config- The givenCrawljaxConfiguration.
-
runOnFireEventFailedPlugins
public void runOnFireEventFailedPlugins(CrawlerContext context, Eventable eventable, List<Eventable> path)
Load and run the OnFireEventFailedPlugins, this call has been made from the fireEvent when the event is not fireable. the Path is the Path leading TO this eventable (not included).- Parameters:
eventable- the eventable not able to fire.path- the path TO this eventable.
-
runOnBrowserCreatedPlugins
public void runOnBrowserCreatedPlugins(EmbeddedBrowser newBrowser)
Load and run the OnBrowserCreatedPlugins, this call has been made from the browser pool when a new browser has been created and ready to be used by the Crawler. The PreCrawling plugins are executed before these plugins are executed except that the pre-crawling plugins are only executed on the first created browser.- Parameters:
newBrowser- the new created browser object
-
pluginNames
public com.google.common.collect.ImmutableSet<String> pluginNames()
- Returns:
- A
ImmutableSetof thePluginnames that are installed.
-
runOnUrlFirstLoadPlugins
public void runOnUrlFirstLoadPlugins(CrawlerContext context)
-
runOnBrowserClosingPlugins
public void runOnBrowserClosingPlugins(CrawlerContext context)
-
-