java.lang.Objectorg.mozilla.javascript.ScriptableObject
org.wso2.mashup.hostobjects.system.SystemHostObject
public class SystemHostObject
| 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_clearTimeout(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)Sometimes it's useful to be able to cancel a timer before it goes off. |
static java.lang.Object |
jsFunction_getXML(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)Utility function to get an XML file over the network var history = system.getXML('http://wso2.org/repos/wso2/trunk/mashup/java/modules/samples/upgradeChecker/upgradeChecker.resources/history.xml'); You can also do basic authentication by giving a username/password var history = system.getXML('http://wso2.org/repos/wso2/trunk/mashup/java/modules/samples/upgradeChecker/upgradeChecker.resources/history.xml', 'username', 'password'); |
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_log(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)Allows printing to the system log from a Mashup. |
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 java.lang.String |
jsFunction_setTimeout(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)setTimeout() allows you to specify that a piece of JavaScript code (called an expression) will be run a specified number of milliseconds from when the setTimeout() method was called. |
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.wso2.mashup.MashupFault
system.wait(); system.wait(1000);
org.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
public java.lang.String jsGet_localHostName()
throws org.wso2.mashup.MashupFault
var hostname = system.localHostName;
org.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
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 org.wso2.mashup.MashupFault
system.include("include.js");
system.include("version?stub&lang=e4x", "lib2.js");
system.include("http://tempuri.org/js/temp.js");
org.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
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 org.wso2.mashup.MashupFault
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);
org.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
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 org.wso2.mashup.MashupFault
system.clearInterval(id);
org.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
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.wso2.mashup.MashupFault
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.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
public static java.lang.Object jsFunction_getXML(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.wso2.mashup.MashupFault
Utility function to get an XML file over the network
var history = system.getXML('http://wso2.org/repos/wso2/trunk/mashup/java/modules/samples/upgradeChecker/upgradeChecker.resources/history.xml');
You can also do basic authentication by giving a username/password
var history = system.getXML('http://wso2.org/repos/wso2/trunk/mashup/java/modules/samples/upgradeChecker/upgradeChecker.resources/history.xml', 'username', 'password');
org.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
public static java.lang.String jsFunction_setTimeout(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.wso2.mashup.MashupFault
ex: setTimeout (expression, timeout);
where expression is the JavaScript code to run after timeout
milliseconds have elapsed. setTimeout() also returns a numeric
timeout ID that can be used to track the timeout. This is most
commonly used with the clearTimeout() methodorg.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
public static void jsFunction_clearTimeout(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.wso2.mashup.MashupFault
ex: clearTimeout ( timeoutId );
where timeoutId is the ID of the timeout as returned from the
setTimeout() method call.org.wso2.mashup.MashupFault - Thrown in case any
exceptions occur
public static void jsFunction_log(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable thisObj,
java.lang.Object[] arguments,
org.mozilla.javascript.Function funObj)
throws org.wso2.mashup.MashupFault
ex: system.log(logmessage, loglevel);
Where logmessage contains a string to be written to the system log
and (optional) loglevel indicates the logging level as 'info',
'warn', 'debug', 'error' or 'fatal'. The logging level defaults to
'info' when one is not provided.org.wso2.mashup.MashupFault - Thrown in case any
exceptions occur