Class JSScriptProcessor

    • Constructor Detail

      • JSScriptProcessor

        public JSScriptProcessor()
    • Method Detail

      • setConfigService

        public void setConfigService​(org.springframework.extensions.config.ConfigService configService)
        Sets the config service.
        Parameters:
        configService - The ConfigService
      • setCompile

        public void setCompile​(boolean compile)
        Parameters:
        compile - the compile flag to set
      • setShareSealedScopes

        public void setShareSealedScopes​(boolean shareSealedScopes)
        Parameters:
        shareSealedScopes - true to allow sharing of sealed scopes between script executions - set to false to disable this feature and ensure that a new scope is created for each executed script.
      • getExtension

        public java.lang.String getExtension()
        Description copied from interface: Processor
        The file extension that the processor is associated with, null if none.
        Specified by:
        getExtension in interface Processor
        Returns:
        the extension
      • getName

        public java.lang.String getName()
        Description copied from interface: Processor
        Get the name of the processor
        Specified by:
        getName in interface Processor
        Returns:
        the name of the processor
      • findScript

        public ScriptContent findScript​(java.lang.String path)
        Description copied from interface: ScriptProcessor
        Find a script at the specified path (within registered Web Script stores)
        Specified by:
        findScript in interface ScriptProcessor
        Parameters:
        path - script path
        Returns:
        script location (or null, if not found)
      • executeScript

        public java.lang.Object executeScript​(java.lang.String path,
                                              java.util.Map<java.lang.String,​java.lang.Object> model)
        Description copied from interface: ScriptProcessor
        Execute script
        Specified by:
        executeScript in interface ScriptProcessor
        Parameters:
        path - script path
        model - model
        Returns:
        script result
      • executeScript

        public java.lang.Object executeScript​(ScriptContent location,
                                              java.util.Map<java.lang.String,​java.lang.Object> model)
        Description copied from interface: ScriptProcessor
        Execute script
        Specified by:
        executeScript in interface ScriptProcessor
        Parameters:
        location - script location
        model - model
        Returns:
        script result
      • loadScriptResource

        public java.lang.String loadScriptResource​(java.lang.String resource)
        Load a script content from the specific resource path.
        Specified by:
        loadScriptResource in interface ScriptResourceLoader
        Parameters:
        resource - Script resource to load. Supports either classpath: prefix syntax or a resource path within the webscript stores.
        Returns:
        the content from the resource, null if not recognised format
      • unwrapValue

        public java.lang.Object unwrapValue​(java.lang.Object value)
        Description copied from interface: ScriptProcessor
        Unwrap value returned by script TODO: Remove this method when value conversion is truly hidden within script engine
        Specified by:
        unwrapValue in interface ScriptProcessor
        Parameters:
        value - value to unwrap
        Returns:
        unwrapped value
      • initProcessor

        protected void initProcessor()
        Inits the processor.
      • initScope

        protected org.mozilla.javascript.Scriptable initScope​(org.mozilla.javascript.Context cx,
                                                              boolean secure,
                                                              boolean sealed)
        Initializes a scope for script execution. The easiest way to embed Rhino is just to create a new scope this way whenever you need one. However, initStandardObjects() is an expensive method to call and it allocates a fair amount of memory.
        Parameters:
        cx - the thread execution context
        secure - Do we consider the script secure? When false this ensures the script may not access insecure java.* libraries or import any other classes for direct access - only the configured root host objects will be available to the script writer.
        sealed - Should the scope be sealed, making it immutable? This should be true if a scope is to be reused.
        Returns:
        the scope object
      • isDebugMode

        protected boolean isDebugMode()