Class PluginPredicates

java.lang.Object
org.frontcache.plugin.host.PluginPredicates

public final class PluginPredicates extends Object
The ext: predicates the started plugins offer (decide, E3), and how a rule's ExtPredicate is answered by one.

Binding

The rules load before the plugins start and may be reloaded while they run, so an ext: predicate is bound late: the first time it is asked after the plugins (re)started - or when the engine checks the rules right after starting them - its plugin's GuardPredicateProvider.parse(String) compiles the argument, once per generation of the started set. A name no started plugin offers, or an argument the plugin refuses, is an ERROR (once per predicate and generation) and a predicate with no answer.

No answer is not false

A predicate with no answer - unbound, refused, threw, or its plugin switched off - throws PredicateUndecided, and the rule it is in does not match (negated or not). The core decides what a failure means, never the plugin.
  • Method Details

    • isRunning

      public static boolean isRunning()
      Whether the plugins have started - before, an unbound predicate is not an error yet.
    • test

      public static boolean test(ExtPredicate predicate, RequestContext context)
      ExtPredicate.test(RequestContext): asks the plugin, timed against its budget.
      Throws:
      PredicateUndecided - when there is no answer
    • check

      public static String check(ExtPredicate predicate, String rule)
      Binds a rule's predicate now - what the engine does for every rule right after the plugins start and after each reload of guard-rules.conf or bots.conf, so a mistake is in the log at once rather than at the first request.
      Parameters:
      rule - the rule's name and file, for the log line
      Returns:
      null when it is bound; else why it has no answer
    • validate

      public static String validate(ExtPredicate predicate)
      What set-config asks of a guard-rules.conf it is about to write: whether a started plugin offers the name and accepts the argument. Binds nothing. Null when it would bind, or when no plugin has started yet.