Class RingoConfig


  • public class RingoConfig
    extends java.lang.Object
    This class describes the configuration for a RingoJS application or shell session.
    • Constructor Detail

      • RingoConfig

        public RingoConfig​(Repository ringoHome)
                    throws java.io.IOException
        Create a new Ringo configuration and sets up its module search path.
        Parameters:
        ringoHome - the ringo installation directory
        Throws:
        java.io.FileNotFoundException - if a module path item does not exist
        java.io.IOException
      • RingoConfig

        public RingoConfig​(Repository ringoHome,
                           java.lang.String[] userModules,
                           java.lang.String[] systemModules)
                    throws java.io.IOException
        Create a new Ringo configuration and sets up its module search path.
        Parameters:
        ringoHome - the ringo installation directory
        userModules - the module search path as list of paths
        systemModules - system module path to append to module path, or null
        Throws:
        java.io.FileNotFoundException - if a module path item does not exist
        java.io.IOException
      • RingoConfig

        public RingoConfig​(Repository ringoHome,
                           Repository appHome,
                           java.lang.String[] userModules,
                           java.lang.String[] systemModules)
                    throws java.io.IOException
        Create a new Ringo configuration and sets up its module search path.
        Parameters:
        ringoHome - the ringo installation directory
        appHome - the path to resolve application against, pass null for current working directory
        userModules - the module search path as list of paths
        systemModules - system module path to append to module path, or null
        Throws:
        java.io.FileNotFoundException - if a module path item does not exist
        java.io.IOException
    • Method Detail

      • addModuleRepository

        public void addModuleRepository​(Repository repository)
        Add a repository to the module search path.
        Parameters:
        repository - the repository to add.
      • resolveRepository

        public Repository resolveRepository​(java.lang.String path,
                                            boolean system)
                                     throws java.io.IOException
        Resolve a module repository path.
        Parameters:
        path - the path
        system - whether repository should be resolved as system repository
        Returns:
        a repository
        Throws:
        java.io.IOException - if an I/O error happened while resolving
      • setMainScript

        public void setMainScript​(java.lang.String scriptName)
                           throws java.io.IOException
        Set the main script for this configuration. If the scriptName argument is not null, we check whether the script is already contained in the ringo module path. If not, the script's parent repository is prepended to the module path. If scriptName is null, we prepend the current working directory to the module path.
        Parameters:
        scriptName - the name of the script, or null.
        Throws:
        java.io.FileNotFoundException - if the script repository does not exist
        java.io.IOException
      • getMainResource

        public Resource getMainResource()
        Get the main script resource resolved by calling setMainScript(String).
        Returns:
        the main script resource, or null
      • getRingoHome

        public Repository getRingoHome()
        Return the ringo install directory
        Returns:
        the ringo home directory
      • getRepositories

        public java.util.List<Repository> getRepositories()
        Get a list of repositoris from the given ringoHome and ringoPath settings using the ringo.home and ringo.path system properties as fallback.
        Returns:
        a list of repositories matching the arguments and/or system properties
      • getMainModule

        public java.lang.String getMainModule()
        Get the module name of the main resource of the configuration.
        Returns:
        the name of the main module
      • setHostClasses

        public void setHostClasses​(java.lang.Class<org.mozilla.javascript.Scriptable>[] classes)
        Set the host classes to be added to the Rhino engine.
        Parameters:
        classes - a list of Rhino host classes
      • getHostClasses

        public java.lang.Class<org.mozilla.javascript.Scriptable>[] getHostClasses()
        Get the host classes to be added to the Rhino engine.
        Returns:
        a list of Rhino host classes
      • getOptLevel

        public int getOptLevel()
        Get the Rhino optimization level
        Returns:
        int value between -1 and 9
      • setOptLevel

        public void setOptLevel​(int optlevel)
        Set the Rhino optimization level
        Parameters:
        optlevel - int value between -1 and 9
      • getDebug

        public boolean getDebug()
      • setDebug

        public void setDebug​(boolean debug)
      • isVerbose

        public boolean isVerbose()
      • setVerbose

        public void setVerbose​(boolean verbose)
      • getStrictVars

        public boolean getStrictVars()
      • setStrictVars

        public void setStrictVars​(boolean strictVars)
      • getLanguageVersion

        public int getLanguageVersion()
        Get the desired JavaScript langauge version
        Returns:
        int value between 0 and 180
      • hasParentProtoProperties

        public boolean hasParentProtoProperties()
        Get the flag to enable __parent__ and __proto__ properties on JS objects
        Returns:
        true if __parent__ and __proto__ properties should be enabled
      • setParentProtoProperties

        public void setParentProtoProperties​(boolean flag)
        Set the flag to enable __parent__ and __proto__ properties on JS objects
        Parameters:
        flag - true to enable __parent__ and __proto__ properties
      • getResource

        public Resource getResource​(java.lang.String path)
                             throws java.io.IOException
        Get a resource from our script repository
        Parameters:
        path - the resource path
        Returns:
        the resource
        Throws:
        java.io.IOException - an I/O error occurred
      • getResource

        public Resource getResource​(java.lang.String path,
                                    ModuleLoader[] loaders)
                             throws java.io.IOException
        Get a resource from our script repository
        Parameters:
        path - the resource path
        loaders - optional list of module loaders
        Returns:
        the resource
        Throws:
        java.io.IOException - an I/O error occurred
      • getRepository

        public Repository getRepository​(java.lang.String path)
                                 throws java.io.IOException
        Get a resource from our script repository
        Parameters:
        path - the resource path
        Returns:
        the resource
        Throws:
        java.io.IOException - an I/O error occurred
      • getResources

        public java.util.List<Resource> getResources​(java.lang.String path,
                                                     boolean recursive)
                                              throws java.io.IOException
        Get a list of all child resources for the given path relative to our script repository.
        Parameters:
        path - the repository path
        recursive - whether to include nested resources
        Returns:
        a list of all contained child resources
        Throws:
        java.io.IOException - an I/O error occurred
      • getCharset

        public java.lang.String getCharset()
      • setCharset

        public void setCharset​(java.lang.String charset)
      • getClassShutter

        public org.mozilla.javascript.ClassShutter getClassShutter()
      • setClassShutter

        public void setClassShutter​(org.mozilla.javascript.ClassShutter classShutter)
      • getWrapFactory

        public org.mozilla.javascript.WrapFactory getWrapFactory()
      • setWrapFactory

        public void setWrapFactory​(org.mozilla.javascript.WrapFactory wrapFactory)
      • isSealed

        public boolean isSealed()
      • setSealed

        public void setSealed​(boolean sealed)
      • isReloading

        public boolean isReloading()
      • setReloading

        public void setReloading​(boolean reloading)
      • getBootstrapScripts

        public java.util.List<java.lang.String> getBootstrapScripts()
      • getArguments

        public java.lang.String[] getArguments()
      • setArguments

        public void setArguments​(java.lang.String[] arguments)
      • setBootstrapScripts

        public void setBootstrapScripts​(java.util.List<java.lang.String> bootstrapScripts)