8016531: jconsole-plugin script demo does not work with nashorn
Reviewed-by: lagergren, hannesw
This commit is contained in:
parent
2be7768ab0
commit
bdc36d78a1
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -54,7 +54,7 @@ import javax.swing.text.*;
|
|||||||
* jconsole's script console.
|
* jconsole's script console.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ScriptShellPanel extends JPanel {
|
public class ScriptShellPanel extends JPanel {
|
||||||
|
|
||||||
private static final long serialVersionUID = 4116273141148726319L;
|
private static final long serialVersionUID = 4116273141148726319L;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -77,12 +77,37 @@
|
|||||||
function jcontext() {
|
function jcontext() {
|
||||||
return plugin.getContext();
|
return plugin.getContext();
|
||||||
}
|
}
|
||||||
jcontext.docString = "returns JConsoleContext for the current jconsole plugin"
|
jcontext.docString = "returns JConsoleContext for the current jconsole plugin";
|
||||||
|
|
||||||
function mbeanConnection() {
|
function mbeanConnection() {
|
||||||
return jcontext().getMBeanServerConnection();
|
return jcontext().getMBeanServerConnection();
|
||||||
}
|
}
|
||||||
mbeanConnection.docString = "returns current MBeanServer connection"
|
mbeanConnection.docString = "returns current MBeanServer connection";
|
||||||
|
|
||||||
|
// check if there is a build in sync function, define one if missing
|
||||||
|
if (typeof sync === "undefined") {
|
||||||
|
var sync = function(func, obj) {
|
||||||
|
if (arguments.length < 1 || arguments.length > 2 ) {
|
||||||
|
throw "sync(function [,object]) parameter count mismatch";
|
||||||
|
}
|
||||||
|
|
||||||
|
var syncobj = (arguments.length == 2 ? obj : this);
|
||||||
|
|
||||||
|
if (!syncobj._syncLock) {
|
||||||
|
syncobj._syncLock = new Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return function() {
|
||||||
|
syncobj._syncLock.lock();
|
||||||
|
try {
|
||||||
|
func.apply(null, arguments);
|
||||||
|
} finally {
|
||||||
|
syncobj._syncLock.unlock();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
sync.docString = "synchronize a function, optionally on an object";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints one liner help message for each function exposed here
|
* Prints one liner help message for each function exposed here
|
||||||
@ -188,22 +213,12 @@ queryMBeans.docString = "return MBeans using given ObjectName and optional query
|
|||||||
|
|
||||||
// wraps a script array as java.lang.Object[]
|
// wraps a script array as java.lang.Object[]
|
||||||
function objectArray(array) {
|
function objectArray(array) {
|
||||||
var len = array.length;
|
return Java.to(array, "java.lang.Object[]");
|
||||||
var res = java.lang.reflect.Array.newInstance(java.lang.Object, len);
|
|
||||||
for (var i = 0; i < array.length; i++) {
|
|
||||||
res[i] = array[i];
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wraps a script (string) array as java.lang.String[]
|
// wraps a script (string) array as java.lang.String[]
|
||||||
function stringArray(array) {
|
function stringArray(array) {
|
||||||
var len = array.length;
|
return Java.to(array, "java.lang.String[]");
|
||||||
var res = java.lang.reflect.Array.newInstance(java.lang.String, len);
|
|
||||||
for (var i = 0; i < array.length; i++) {
|
|
||||||
res[i] = String(array[i]);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// script array to Java List
|
// script array to Java List
|
||||||
@ -286,16 +301,18 @@ invokeMBean.docString = "invokes MBean operation on given ObjectName";
|
|||||||
* will be of type FutureTask. When you need value, call 'get' on it.
|
* will be of type FutureTask. When you need value, call 'get' on it.
|
||||||
*/
|
*/
|
||||||
function mbean(objName, async) {
|
function mbean(objName, async) {
|
||||||
|
var index;
|
||||||
|
|
||||||
objName = objectName(objName);
|
objName = objectName(objName);
|
||||||
var info = mbeanInfo(objName);
|
var info = mbeanInfo(objName);
|
||||||
var attrs = info.attributes;
|
var attrs = info.attributes;
|
||||||
var attrMap = new Object;
|
var attrMap = new Object;
|
||||||
for (var index in attrs) {
|
for (index in attrs) {
|
||||||
attrMap[attrs[index].name] = attrs[index];
|
attrMap[attrs[index].name] = attrs[index];
|
||||||
}
|
}
|
||||||
var opers = info.operations;
|
var opers = info.operations;
|
||||||
var operMap = new Object;
|
var operMap = new Object;
|
||||||
for (var index in opers) {
|
for (index in opers) {
|
||||||
operMap[opers[index].name] = opers[index];
|
operMap[opers[index].name] = opers[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,22 +335,31 @@ function mbean(objName, async) {
|
|||||||
} else {
|
} else {
|
||||||
return getMBeanAttribute(objName, name);
|
return getMBeanAttribute(objName, name);
|
||||||
}
|
}
|
||||||
} else if (isOperation(name)) {
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
__call__: function(name) {
|
||||||
|
if (isOperation(name)) {
|
||||||
var oper = operMap[name];
|
var oper = operMap[name];
|
||||||
return function() {
|
|
||||||
var params = objectArray(arguments);
|
var params = [];
|
||||||
|
for (var j = 1; j < arguments.length; j++) {
|
||||||
|
params[j-1]= arguments[j];
|
||||||
|
}
|
||||||
|
|
||||||
var sigs = oper.signature;
|
var sigs = oper.signature;
|
||||||
|
|
||||||
var sigNames = new Array(sigs.length);
|
var sigNames = new Array(sigs.length);
|
||||||
for (var index in sigs) {
|
for (var index in sigs) {
|
||||||
sigNames[index] = sigs[index].getType();
|
sigNames[index] = sigs[index].getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (async) {
|
if (async) {
|
||||||
return invokeMBean.future(objName, name,
|
return invokeMBean.future(objName, name, params, sigNames);
|
||||||
params, sigNames);
|
|
||||||
} else {
|
} else {
|
||||||
return invokeMBean(objName, name, params, sigNames);
|
return invokeMBean(objName, name, params, sigNames);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -520,7 +546,7 @@ Function.prototype.sync = function (lock) {
|
|||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes current thread to sleep for specified
|
* Causes current thread to sleep for specified
|
||||||
@ -534,8 +560,7 @@ function sleep(interval) {
|
|||||||
sleep.docString = "wrapper for java.lang.Thread.sleep method";
|
sleep.docString = "wrapper for java.lang.Thread.sleep method";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules a task to be executed once in
|
* Schedules a task to be executed once in N milliseconds specified.
|
||||||
* every N milliseconds specified.
|
|
||||||
*
|
*
|
||||||
* @param callback function or expression to evaluate
|
* @param callback function or expression to evaluate
|
||||||
* @param interval in milliseconds to sleep
|
* @param interval in milliseconds to sleep
|
||||||
@ -549,13 +574,13 @@ function setTimeout(callback, interval) {
|
|||||||
// start a new thread that sleeps given time
|
// start a new thread that sleeps given time
|
||||||
// and calls callback in an infinite loop
|
// and calls callback in an infinite loop
|
||||||
return (function() {
|
return (function() {
|
||||||
while (true) {
|
try {
|
||||||
sleep(interval);
|
sleep(interval);
|
||||||
|
} catch (x) { }
|
||||||
callback();
|
callback();
|
||||||
}
|
|
||||||
}).daemon();
|
}).daemon();
|
||||||
}
|
}
|
||||||
setTimeout.docString = "calls given callback once after specified interval"
|
setTimeout.docString = "calls given callback once after specified interval";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels a timeout set earlier.
|
* Cancels a timeout set earlier.
|
||||||
@ -565,6 +590,45 @@ function clearTimeout(tid) {
|
|||||||
// we just interrupt the timer thread
|
// we just interrupt the timer thread
|
||||||
tid.interrupt();
|
tid.interrupt();
|
||||||
}
|
}
|
||||||
|
clearTimeout.docString = "interrupt a setTimeout timer";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedules a task to be executed once in
|
||||||
|
* every N milliseconds specified.
|
||||||
|
*
|
||||||
|
* @param callback function or expression to evaluate
|
||||||
|
* @param interval in milliseconds to sleep
|
||||||
|
* @return timeout ID (which is nothing but Thread instance)
|
||||||
|
*/
|
||||||
|
function setInterval(callback, interval) {
|
||||||
|
if (! (callback instanceof Function)) {
|
||||||
|
callback = new Function(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// start a new thread that sleeps given time
|
||||||
|
// and calls callback in an infinite loop
|
||||||
|
return (function() {
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
sleep(interval);
|
||||||
|
} catch (x) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}).daemon();
|
||||||
|
}
|
||||||
|
setInterval.docString = "calls given callback every specified interval";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels a timeout set earlier.
|
||||||
|
* @param tid timeout ID returned from setTimeout
|
||||||
|
*/
|
||||||
|
function clearInterval(tid) {
|
||||||
|
// we just interrupt the timer thread
|
||||||
|
tid.interrupt();
|
||||||
|
}
|
||||||
|
clearInterval.docString = "interrupt a setInterval timer";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple access to thread local storage.
|
* Simple access to thread local storage.
|
||||||
@ -680,7 +744,7 @@ function msgBox(msg, title, msgType) {
|
|||||||
if (msg === undefined) msg = "undefined";
|
if (msg === undefined) msg = "undefined";
|
||||||
if (msg === null) msg = "null";
|
if (msg === null) msg = "null";
|
||||||
if (title == undefined) title = msg;
|
if (title == undefined) title = msg;
|
||||||
if (msgType == undefined) type = JOptionPane.INFORMATION_MESSAGE;
|
if (msgType == undefined) msgType = JOptionPane.INFORMATION_MESSAGE;
|
||||||
JOptionPane.showMessageDialog(window, msg, title, msgType);
|
JOptionPane.showMessageDialog(window, msg, title, msgType);
|
||||||
}
|
}
|
||||||
if (isEventThread()) {
|
if (isEventThread()) {
|
||||||
@ -800,7 +864,7 @@ echo.docString = "echoes arguments to interactive console screen";
|
|||||||
* Clear the screen
|
* Clear the screen
|
||||||
*/
|
*/
|
||||||
function clear() {
|
function clear() {
|
||||||
(function() { window.clear(false) }).invokeLater();
|
(function() { window.clear(false); }).invokeLater();
|
||||||
}
|
}
|
||||||
clear.docString = "clears interactive console screen";
|
clear.docString = "clears interactive console screen";
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -53,6 +53,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function resetPeakThreadCount() {
|
function resetPeakThreadCount() {
|
||||||
return invokeMBean("java.lang:type=Threading", "resetPeakThreadCount", [], "");
|
return invokeMBean("java.lang:type=Threading", "resetPeakThreadCount", [], {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -43,16 +43,16 @@
|
|||||||
* threads.'jstack' function which can be called once or periodically
|
* threads.'jstack' function which can be called once or periodically
|
||||||
* from a timer thread (calling it periodically would slow down the target
|
* from a timer thread (calling it periodically would slow down the target
|
||||||
* application). To call this once, just call 'jstack()' in script
|
* application). To call this once, just call 'jstack()' in script
|
||||||
* console prompt. To call jtop in a timer thread, you can use
|
* console prompt. To call jstack in a timer thread, you can use
|
||||||
*
|
*
|
||||||
* var t = setTimeout(function () { jstack(print); }, 5000);
|
* var t = setInterval(function () { jstack(print); }, 5000);
|
||||||
*
|
*
|
||||||
* The above call prints threads in sorted order for every 5 seconds.
|
* The above call prints threads in sorted order for every 5 seconds.
|
||||||
* The print output goes to OS console window from which jconsole was
|
* The print output goes to OS console window from which jconsole was
|
||||||
* started. The timer can be cancelled later by clearTimeout() function
|
* started. The timer can be cancelled later by clearTimeout() function
|
||||||
* as shown below:
|
* as shown below:
|
||||||
*
|
*
|
||||||
* clearTimeout(t);
|
* clearInterval(t);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ function jstack(printFunc, maxFrames) {
|
|||||||
|
|
||||||
var tmbean = newPlatformMXBeanProxy(
|
var tmbean = newPlatformMXBeanProxy(
|
||||||
"java.lang:type=Threading",
|
"java.lang:type=Threading",
|
||||||
java.lang.management.ThreadMXBean);
|
java.lang.management.ThreadMXBean.class);
|
||||||
|
|
||||||
var tids = tmbean.allThreadIds;
|
var tids = tmbean.allThreadIds;
|
||||||
var tinfos = tmbean["getThreadInfo(long[],int)"](tids, maxFrames);
|
var tinfos = tmbean["getThreadInfo(long[],int)"](tids, maxFrames);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -45,14 +45,14 @@
|
|||||||
* To call this once, just call 'jtop()' in script console prompt.
|
* To call this once, just call 'jtop()' in script console prompt.
|
||||||
* To call jtop in a timer thread, you can use
|
* To call jtop in a timer thread, you can use
|
||||||
*
|
*
|
||||||
* var t = setTimeout(function () { jtop(print); }, 2000);
|
* var t = setInterval(function () { jtop(print); }, 2000);
|
||||||
*
|
*
|
||||||
* The above call prints threads in sorted order for every 2 seconds.
|
* The above call prints threads in sorted order for every 2 seconds.
|
||||||
* The print output goes to OS console window from which jconsole was
|
* The print output goes to OS console window from which jconsole was
|
||||||
* started. The timer can be cancelled later by clearTimeout() function
|
* started. The timer can be cancelled later by clearTimeout() function
|
||||||
* as shown below:
|
* as shown below:
|
||||||
*
|
*
|
||||||
* clearTimeout(t);
|
* clearInterval(t);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,10 +62,10 @@
|
|||||||
function getThreadList() {
|
function getThreadList() {
|
||||||
var tmbean = newPlatformMXBeanProxy(
|
var tmbean = newPlatformMXBeanProxy(
|
||||||
"java.lang:type=Threading",
|
"java.lang:type=Threading",
|
||||||
java.lang.management.ThreadMXBean);
|
java.lang.management.ThreadMXBean.class);
|
||||||
|
|
||||||
if (!tmbean.isThreadCpuTimeSupported()) {
|
if (!tmbean.isThreadCpuTimeSupported()) {
|
||||||
return;
|
return java.util.Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmbean.setThreadCpuTimeEnabled(true);
|
tmbean.setThreadCpuTimeEnabled(true);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -43,16 +43,16 @@
|
|||||||
* properties.'sysprops' function which can be called once or periodically
|
* properties.'sysprops' function which can be called once or periodically
|
||||||
* from a timer thread (calling it periodically would slow down the target
|
* from a timer thread (calling it periodically would slow down the target
|
||||||
* application). To call this once, just call 'sysprops()' in script
|
* application). To call this once, just call 'sysprops()' in script
|
||||||
* console prompt. To call jtop in a timer thread, you can use
|
* console prompt. To call sysprops in a timer thread, you can use
|
||||||
*
|
*
|
||||||
* var t = setTimeout(function () { sysprops(print); }, 5000);
|
* var t = setInterval(function () { sysprops(print); }, 5000);
|
||||||
*
|
*
|
||||||
* The above call prints threads in sorted order for every 5 seconds.
|
* The above call prints threads in sorted order for every 5 seconds.
|
||||||
* The print output goes to OS console window from which jconsole was
|
* The print output goes to OS console window from which jconsole was
|
||||||
* started. The timer can be cancelled later by clearTimeout() function
|
* started. The timer can be cancelled later by clearTimeout() function
|
||||||
* as shown below:
|
* as shown below:
|
||||||
*
|
*
|
||||||
* clearTimeout(t);
|
* clearInterval(t);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -62,7 +62,7 @@
|
|||||||
function getSystemProps() {
|
function getSystemProps() {
|
||||||
var runtimeBean = newPlatformMXBeanProxy(
|
var runtimeBean = newPlatformMXBeanProxy(
|
||||||
"java.lang:type=Runtime",
|
"java.lang:type=Runtime",
|
||||||
java.lang.management.RuntimeMXBean);
|
java.lang.management.RuntimeMXBean.class);
|
||||||
return runtimeBean.systemProperties;
|
return runtimeBean.systemProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ under the ./src/scripts directory.
|
|||||||
java -Dcom.sun.management.jmxremote.port=1090 \
|
java -Dcom.sun.management.jmxremote.port=1090 \
|
||||||
-Dcom.sun.management.jmxremote.ssl=false \
|
-Dcom.sun.management.jmxremote.ssl=false \
|
||||||
-Dcom.sun.management.jmxremote.authenticate=false \
|
-Dcom.sun.management.jmxremote.authenticate=false \
|
||||||
-jar $JDK_HOME/demo/jfc/Java2D/Java2Demo.jar
|
-jar $JDK_HOME/demo/jfc/Font2DTest/Font2DTest.jar
|
||||||
|
|
||||||
(2) Start scriptpad and click on "Tools->JMX Connect" menu.
|
(2) Start scriptpad and click on "Tools->JMX Connect" menu.
|
||||||
In the prompt, enter "localhost:1090" to connect to the above
|
In the prompt, enter "localhost:1090" to connect to the above
|
||||||
|
@ -221,7 +221,7 @@ sleep.docString = "wrapper for java.lang.Thread.sleep method";
|
|||||||
* @return timeout ID (which is nothing but Thread instance)
|
* @return timeout ID (which is nothing but Thread instance)
|
||||||
*/
|
*/
|
||||||
function setTimeout(callback, interval) {
|
function setTimeout(callback, interval) {
|
||||||
if (! (callback instanceof Function) && typeof callback !== "function") {
|
if (! (callback instanceof Function)) {
|
||||||
callback = new Function(callback);
|
callback = new Function(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ clearTimeout.docString = "interrupt a setTimeout timer";
|
|||||||
* @return timeout ID (which is nothing but Thread instance)
|
* @return timeout ID (which is nothing but Thread instance)
|
||||||
*/
|
*/
|
||||||
function setInterval(callback, interval) {
|
function setInterval(callback, interval) {
|
||||||
if (! (callback instanceof Function) && typeof callback !== "function") {
|
if (! (callback instanceof Function)) {
|
||||||
callback = new Function(callback);
|
callback = new Function(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,22 +159,12 @@ queryMBeans.docString = "return MBeans using given ObjectName and optional query
|
|||||||
|
|
||||||
// wraps a script array as java.lang.Object[]
|
// wraps a script array as java.lang.Object[]
|
||||||
function objectArray(array) {
|
function objectArray(array) {
|
||||||
var len = array.length;
|
return Java.to(array, "java.lang.Object[]");
|
||||||
var res = java.lang.reflect.Array.newInstance(java.lang.Object, len);
|
|
||||||
for (var i = 0; i < array.length; i++) {
|
|
||||||
res[i] = array[i];
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wraps a script (string) array as java.lang.String[]
|
// wraps a script (string) array as java.lang.String[]
|
||||||
function stringArray(array) {
|
function stringArray(array) {
|
||||||
var len = array.length;
|
return Java.to(array, "java.lang.String[]");
|
||||||
var res = java.lang.reflect.Array.newInstance(java.lang.String, len);
|
|
||||||
for (var i = 0; i < array.length; i++) {
|
|
||||||
res[i] = String(array[i]);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// script array to Java List
|
// script array to Java List
|
||||||
@ -288,22 +278,31 @@ function mbean(objName, async) {
|
|||||||
} else {
|
} else {
|
||||||
return getMBeanAttribute(objName, name);
|
return getMBeanAttribute(objName, name);
|
||||||
}
|
}
|
||||||
} else if (isOperation(name)) {
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
__call__: function(name) {
|
||||||
|
if (isOperation(name)) {
|
||||||
var oper = operMap[name];
|
var oper = operMap[name];
|
||||||
return function() {
|
|
||||||
var params = objectArray(arguments);
|
var params = [];
|
||||||
|
for (var j = 1; j < arguments.length; j++) {
|
||||||
|
params[j-1]= arguments[j];
|
||||||
|
}
|
||||||
|
|
||||||
var sigs = oper.signature;
|
var sigs = oper.signature;
|
||||||
|
|
||||||
var sigNames = new Array(sigs.length);
|
var sigNames = new Array(sigs.length);
|
||||||
for (var index in sigs) {
|
for (var index in sigs) {
|
||||||
sigNames[index] = sigs[index].getType();
|
sigNames[index] = sigs[index].getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (async) {
|
if (async) {
|
||||||
return invokeMBean.future(objName, name,
|
return invokeMBean.future(objName, name, params, sigNames);
|
||||||
params, sigNames);
|
|
||||||
} else {
|
} else {
|
||||||
return invokeMBean(objName, name, params, sigNames);
|
return invokeMBean(objName, name, params, sigNames);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user