java.lang.Objectorg.mozilla.javascript.ScriptableObject
org.wso2.mashup.hostobjects.system.SystemHostObject
public class SystemHostObject
This is a JavaScript Rhino host object aimed to provide a set of system specific utility functions to the javascript service developers. For more information refer to JavaScript System Host Object.
| Field Summary |
|---|
| Fields inherited from class org.mozilla.javascript.ScriptableObject |
|---|
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST |
| Fields inherited from interface org.mozilla.javascript.Scriptable |
|---|
NOT_FOUND |
| Constructor Summary | |
|---|---|
SystemHostObject()
|
|
| Method Summary | |
|---|---|
java.lang.String |
getClassName()
Type to be used for this object inside the javascript. |
void |
jsConstructor()
|
static void |
jsFunction_clearInterval(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
Removes a JavaScript function scheduled for periodic execution using the job id system.clearInterval(id); |
static void |
jsFunction_include(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
Imports the external scripts given as the arguments, to the java script run time. |
static void |
jsFunction_notifyMonitor(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
Sends notification to a monitoring software via JMX. |
static java.lang.String |
jsFunction_setInterval(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
This method allows the scheduling of a JavaScript function periodically. |
static void |
jsFunction_wait(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
Waits the execution of the script for the given time in miliseconds or waits for 10 miliseconds when the time is not given. |
java.lang.String |
jsGet_localHostName()
Get the string defining the hostname of the system. |
| Methods inherited from class org.mozilla.javascript.ScriptableObject |
|---|
associateValue, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, get, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SystemHostObject()
| Method Detail |
|---|
public void jsConstructor()
public java.lang.String getClassName()
getClassName in interface org.mozilla.javascript.ScriptablegetClassName in class org.mozilla.javascript.ScriptableObject
public static void jsFunction_wait(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.apache.axis2.AxisFault
system.wait(); system.wait(1000);
org.apache.axis2.AxisFault
public java.lang.String jsGet_localHostName()
throws org.wso2.mashup.MashupFault
var hostname = system.localhostname;
org.wso2.mashup.MashupFault
public static void jsFunction_include(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws java.io.IOException
system.include("include.js");
system.include("version?stub&lang=e4x", "lib2.js");
system.include("http://tempuri.org/js/temp.js");
java.io.IOException
public static java.lang.String jsFunction_setInterval(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws java.io.IOException
function myJavaScriptFunction(function-parameter)
{
print("The parameter value is " + function-parameter);
}
example 1:
//Setting up 'myJavaScriptFunction' to be executed in 2000 millisecond intervals, starting now and continuing forever.
var id = system.setInterval(myJavaScriptFunction, 2000, 'I am a parameter value');
example 2:
//Setting up 'myJavaScriptFunction' to be executed in 2000 millisecond intervals, starting now and continuing forever.
//But passing the function as a javascript expression.
var id = system.setInterval('myJavaScriptFunction("I am a parameter value");', 2000);
example 3:
//Setting to start in 2 minutes from now
var startTime = new Date();
startTime.setMinutes(startTime.getMinutes() + 2);
var id = system.setInterval(myJavaScriptFunction, 2000, 'I am a parameter value', startTime);
or
var id = system.setInterval('myJavaScriptFunction("I am a parameter value");', 2000, null, startTime);
example 4:
//Setting to start in 2 minutes from now
var startTime = new Date();
startTime.setMinutes(startTime.getMinutes() + 2);
//Setting to end in 4 minutes after starting
var endtime = new Date();
endtime.setMinutes(startTime.getMinutes() + 4);
var id = system.setInterval(myJavaScriptFunction, 2000, 'I am a parameter value', startTime, endtime);
or
var id = system.setInterval('myJavaScriptFunction("I am a parameter value");', 2000, null, startTime, endtime);
cx - - The Rhino context which is created for each invocation of a functionthisObj - arguments - The expected arguments are; the JavaScript function to execute and
the frequency of execution. Optionally you can provide a start and end time.
The default start time is 'after given number of milliseconds in the frequency parameter' and end time is 'indefinitely'.funObj -
java.io.IOException
public static void jsFunction_clearInterval(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws java.io.IOException
system.clearInterval(id);
cx - thisObj - arguments - The expected argument is a string representing the ID of the scheduled functionfunObj -
java.io.IOException
public static void jsFunction_notifyMonitor(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.apache.axis2.AxisFault
Sends notification to a monitoring software via JMX. A single parameter is assumed to be the message, while if another string is provided it is the title. A third parameter , if integer, is assumed to be the message severity (info = 0, error = 1, warning = 2 and none = 3).
system.notifyMonitor("Message");
system.notifyMonitor("Title", "Message");
system.notifyMonitor("Title", "Message", 3);
org.apache.axis2.AxisFault