Package org.ringojs.engine
Class RingoConfig
- java.lang.Object
-
- org.ringojs.engine.RingoConfig
-
public class RingoConfig extends java.lang.Object
This class describes the configuration for a RingoJS application or shell session.
-
-
Constructor Summary
Constructors Constructor Description RingoConfig(Repository ringoHome)
Create a new Ringo configuration and sets up its module search path.RingoConfig(Repository ringoHome, java.lang.String[] userModules, java.lang.String[] systemModules)
Create a new Ringo configuration and sets up its module search path.RingoConfig(Repository ringoHome, Repository appHome, java.lang.String[] userModules, java.lang.String[] systemModules)
Create a new Ringo configuration and sets up its module search path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addModuleRepository(Repository repository)
Add a repository to the module search path.java.lang.String[]
getArguments()
java.util.List<java.lang.String>
getBootstrapScripts()
java.lang.String
getCharset()
org.mozilla.javascript.ClassShutter
getClassShutter()
boolean
getDebug()
java.lang.Class<org.mozilla.javascript.Scriptable>[]
getHostClasses()
Get the host classes to be added to the Rhino engine.int
getLanguageVersion()
Get the desired JavaScript langauge versionjava.lang.String
getMainModule()
Get the module name of the main resource of the configuration.Resource
getMainResource()
Get the main script resource resolved by callingsetMainScript(String)
.int
getOptLevel()
Get the Rhino optimization leveljava.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.Repository
getRepository(java.lang.String path)
Get a resource from our script repositoryResource
getResource(java.lang.String path)
Get a resource from our script repositoryResource
getResource(java.lang.String path, ModuleLoader[] loaders)
Get a resource from our script repositoryjava.util.List<Resource>
getResources(java.lang.String path, boolean recursive)
Get a list of all child resources for the given path relative to our script repository.Repository
getRingoHome()
Return the ringo install directoryboolean
getStrictVars()
org.mozilla.javascript.WrapFactory
getWrapFactory()
boolean
hasParentProtoProperties()
Get the flag to enable __parent__ and __proto__ properties on JS objectsboolean
isReloading()
boolean
isSealed()
boolean
isVerbose()
Repository
resolveRepository(java.lang.String path, boolean system)
Resolve a module repository path.void
setArguments(java.lang.String[] arguments)
void
setBootstrapScripts(java.util.List<java.lang.String> bootstrapScripts)
void
setCharset(java.lang.String charset)
void
setClassShutter(org.mozilla.javascript.ClassShutter classShutter)
void
setDebug(boolean debug)
void
setHostClasses(java.lang.Class<org.mozilla.javascript.Scriptable>[] classes)
Set the host classes to be added to the Rhino engine.void
setMainScript(java.lang.String scriptName)
Set the main script for this configuration.void
setOptLevel(int optlevel)
Set the Rhino optimization levelvoid
setParentProtoProperties(boolean flag)
Set the flag to enable __parent__ and __proto__ properties on JS objectsvoid
setReloading(boolean reloading)
void
setSealed(boolean sealed)
void
setStrictVars(boolean strictVars)
void
setVerbose(boolean verbose)
void
setWrapFactory(org.mozilla.javascript.WrapFactory wrapFactory)
-
-
-
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 existjava.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 directoryuserModules
- the module search path as list of pathssystemModules
- system module path to append to module path, or null- Throws:
java.io.FileNotFoundException
- if a module path item does not existjava.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 directoryappHome
- the path to resolve application against, pass null for current working directoryuserModules
- the module search path as list of pathssystemModules
- system module path to append to module path, or null- Throws:
java.io.FileNotFoundException
- if a module path item does not existjava.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 pathsystem
- 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 existjava.io.IOException
-
getMainResource
public Resource getMainResource()
Get the main script resource resolved by callingsetMainScript(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 pathloaders
- 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 pathrecursive
- 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)
-
-