Interface SecuredJsCache

  • All Known Implementing Classes:
    LinkedHashMapSecuredJsCache

    public interface SecuredJsCache
    A cache used to store pre-processed javascript strings, which can be used to share these among different NashornSandboxes. The interface provides a facility to implement concurrent caches, but the actual thread safety is at the implementor's discretion.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getOrCreate​(java.lang.String js, boolean allowNoBraces, java.util.function.Supplier<java.lang.String> producer)
      Gets a value from the cache and tries to create it if it couldn't be found.
    • Method Detail

      • getOrCreate

        java.lang.String getOrCreate​(java.lang.String js,
                                     boolean allowNoBraces,
                                     java.util.function.Supplier<java.lang.String> producer)
        Gets a value from the cache and tries to create it if it couldn't be found.
        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.