Class LinkedHashMapSecuredJsCache

java.lang.Object
delight.nashornsandbox.internal.LinkedHashMapSecuredJsCache
All Implemented Interfaces:
SecuredJsCache

class LinkedHashMapSecuredJsCache extends Object implements SecuredJsCache
Default implementation of SecuredJsCache, uses a LinkedHashMap as its cache and is not thread-safe. Also, mixing scripts with missing braces allowed and not allowed is forbidden.
  • Field Details

  • Constructor Details

    • LinkedHashMapSecuredJsCache

      public LinkedHashMapSecuredJsCache(LinkedHashMap<String,String> linkedHashMap, boolean allowNoBraces)
  • Method Details

    • getOrCreate

      public String getOrCreate(String js, boolean allowNoBraces, Supplier<String> producer)
      Description copied from interface: SecuredJsCache
      Gets a value from the cache and tries to create it if it couldn't be found.
      Specified by:
      getOrCreate in interface SecuredJsCache
      Parameters:
      js - the raw javascript code
      allowNoBraces - whether missing braces are allowed.
      producer - if no cached value could be found, this is used to create the value
      Returns:
      the cached or created value, or null if it could be neither found in the cache nor created.
    • assertConfiguration

      private void assertConfiguration(boolean allowNoBraces)