|
OpenAPI 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface AQSystem
This interface provides access to low-level system functionality.
An instance of this interface is available to aquascripts via aqua.system alias.
Method Summary | |
---|---|
void |
forceGC()
Force garbage collection. |
long |
getCurrentTime()
Returns current time in milliseconds as reported by System.currentTimeMillis() . |
String |
getenv(String name)
Gets the value of the specified environment variable. |
long |
getMaxMemory()
Returns the maximum amount of memory (in bytes) which may be requested by the virtual machine from the OS. |
String |
getProperty(String key)
Gets the system property indicated by the specified key. |
String |
getProperty(String key,
String def)
Gets the system property indicated by the specified key. |
long |
getTotalMemory()
Returns the amount of memory (in bytes) currently allocated by the virtual machine. |
long |
getUsedMemory()
Returns the amount of memory (in bytes) currently in use by the virtual machine. |
boolean |
isLowMemory()
Returns true if the memory is almost full. |
byte[] |
newByteArray(int length)
Creates an empty byte array. |
Process |
runCommand(String commandLine)
Executes an external process. |
Process |
runCommand(String commandLine,
String folder)
Executes an external process in the specified folder. |
Object |
runScript(String path)
Execute another script. |
Object |
runScript(String path,
Object args)
Execute another script with additional parameter. |
Object |
runScript(String path,
Object argument,
boolean shareContext)
Executes another script with an additional parameter and enables a shared global context. |
Method Detail |
---|
Process runCommand(String commandLine) throws Exception
Runtime.exec(String)
call. A script may call Process.waitFor()
method on the returned value to wait for the process to finish.
commandLine
- Command line.
Exception
Process runCommand(String commandLine, String folder) throws Exception
Runtime.exec(String, String[], java.io.File)
call.
A script may call Process.waitFor()
method on the returned value to wait for the process to finish.
commandLine
- Command line.folder
- Directory to start the process in.
Exception
Object runScript(String path) throws Exception
path
- Local path to the script in the project's AquaScripts folder.
Exception
Object runScript(String path, Object args) throws Exception
// Parent Script:
//creates an AquaScript object with an attribute title and a function greet
var greeting = {
title : "Hello",
greet : function (name) {
return this.title + " " + name;
}
};
// executes script with argument greeting object
aqua.system.runScript("script.xjs", greeting);
// Script Being Called (script.xjs):
// A variable with the name 'argument' contains an object passed from the parent script
var name = "aqua data user";
// invoking greet method defined in greeting object of the parent script.
print(argument.greet(name));
The new script shares the instance of aqua object but gets its own global context. This means, among other things, that
variables and functions will not be shared.
path
- Local path to the script in the project's AquaScripts folder.args
- Script arguments.
Exception
Object runScript(String path, Object argument, boolean shareContext) throws Exception
runScript(String, Object)
, this method allows for global context sharing among parent and child scripts.
Once the global shared context is set to true, the parent and child scripts can use each others variables and functions.
Note: In case of child script using parent script's function or variables, the child script can be only be executed
from the parent script unless you handle the undefined errors.
Example:
// Parent Script:
//defines a simple function toUpperCase to convert any string to upper case.
function toUpperCase(str) {
return (str) ? str.toUpperCase() : "";
}
// executes script with sharedContext set to true
aqua.system.runScript("script.xjs", null, true);
// invoking greet method defined in script.xjs.
print(greet("Hello", "aqua data user"));
// Script Being Called (script.xjs):
function greet(greeting, name) {
// invoking toUpperCase method defined in parent script.
return greeting + " " + toUpperCase(name);
}
path
- Local path to the script in the project's AquaScripts folder.argument
- Script arguments.shareContext
- Determines whether to share the parent global context or create a separate one.
Exception
boolean isLowMemory()
void forceGC()
System.gc()
, this method actually tries to collect in
the calling thread.
long getCurrentTime()
System.currentTimeMillis()
.
long getUsedMemory()
long getTotalMemory()
long getMaxMemory()
String getProperty(String key)
System.getProperty(String)
.
key
- the name of the system property.
null
if there is no property with that key.String getProperty(String key, String def)
System.getProperty(String, String)
.
key
- the name of the system property.def
- a default value.
String getenv(String name)
System.getenv(String)
.
name
- the name of the environment variable
null
if the variable is not defined in the system environmentbyte[] newByteArray(int length)
length
- Array length.
|
OpenAPI 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |