Class Plugins


  • @Singleton
    public class Plugins
    extends Object
    Class for invoking plugins. The methods in this class are invoked from the Crawljax Core.
    • 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)
      • 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 current CrawlerContext for 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 current CrawlerContext for 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 invariants
        context - the current CrawlerContext for 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 current CrawlSession for 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 current CrawlerContext for 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 current CrawlerContext for this crawler.
        candidateElements - the elements which crawljax is about to crawl
        state - The state being violated.
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • pluginNames

        public com.google.common.collect.ImmutableSet<String> pluginNames()
        Returns:
        A ImmutableSet of the Plugin names that are installed.
      • runOnUrlFirstLoadPlugins

        public void runOnUrlFirstLoadPlugins​(CrawlerContext context)
      • runOnBrowserClosingPlugins

        public void runOnBrowserClosingPlugins​(CrawlerContext context)