[mashup-dev] svn commit r14416 -
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system
svn at wso2.org
svn at wso2.org
Sun Mar 2 19:45:44 PST 2008
Author: tyrell
Date: Sun Mar 2 19:45:40 2008
New Revision: 14416
Log:
Fixing MASHUP-625
Modified:
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system/SystemHostObject.java
Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system/SystemHostObject.java
==============================================================================
--- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system/SystemHostObject.java (original)
+++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/system/SystemHostObject.java Sun Mar 2 19:45:40 2008
@@ -318,7 +318,6 @@
* or
* var id = system.setInterval('myJavaScriptFunction("I am a parameter value");', 2000, null, startTime, endtime);
* </pre>
- *
*/
public static String jsFunction_setInterval(Context cx, Scriptable thisObj, Object[] arguments,
Function funObj) throws IOException {
@@ -642,7 +641,6 @@
* <pre>
* system.clearInterval(id);
* </pre>
- *
*/
public static void jsFunction_clearInterval(Context cx, Scriptable thisObj, Object[] arguments,
Function funObj) throws IOException {
@@ -813,7 +811,7 @@
startInMilliSeconds = ((Number) arguments[1]).longValue();
} catch (NumberFormatException e) {
throw new AxisFault(
- "Invalid parameter. The second parameter must be the start time from now in milliseconds.");
+ "Invalid parameter. The second parameter must be the start time from now in milliseconds.");
}
//Storing the function meta-data to be used by the job at execution time
@@ -835,18 +833,17 @@
return jobId;
}
-
+
/**
* Sometimes it's useful to be able to cancel a timer before it goes off. The clearTimeout() method lets us do exactly that.
* <p/>
- *
+ * <p/>
* <pre>
* ex: clearTimeout ( timeoutId );
* </pre>
- *
+ * <p/>
* <p/>
* where timeoutId is the ID of the timeout as returned from the setTimeout() method call.
- *
*/
public static void jsFunction_clearTimeout(Context cx, Scriptable thisObj, Object[] arguments,
Function funObj) throws IOException {
@@ -880,4 +877,55 @@
throw new MashupFault("Failed to remove job id from the scheduler", e);
}
}
+
+ /**
+ * Allows printing to the system log from a Mashup.
+ * <p/>
+ * <p>
+ * <pre>
+ * ex: system.log(logmessage, loglevel);
+ * </pre>
+ * </p>
+ * <p/>
+ * 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.
+ */
+ public static void jsFunction_log(Context cx, Scriptable thisObj, Object[] arguments,
+ Function funObj) throws IOException {
+ String logMessage;
+ String logLevel;
+
+ if (arguments[0] instanceof String) {
+ logMessage = (String) arguments[0];
+ } else {
+ throw new MashupFault("The first argument should contain a message to log");
+ }
+
+ if (arguments.length > 1) {
+ if (arguments[1] instanceof String) {
+ logLevel = (String) arguments[1];
+
+ if (logLevel.equalsIgnoreCase("info")) {
+ log.info(logMessage);
+ } else if (logLevel.equalsIgnoreCase("warn")) {
+ log.warn(logMessage);
+ } else if (logLevel.equalsIgnoreCase("debug")) {
+ log.debug(logMessage);
+ } else if (logLevel.equalsIgnoreCase("error")) {
+ log.error(logMessage);
+ } else if (logLevel.equalsIgnoreCase("fatal")) {
+ log.fatal(logMessage);
+ } else {
+ throw new MashupFault(
+ "Unsupported log level. Please refer documentation for this function.");
+ }
+
+ } else {
+ throw new MashupFault(
+ "The second argument should contain a String indicating the log level");
+ }
+ }else{
+ log.info(logMessage);
+ }
+ }
}
More information about the Mashup-dev
mailing list