Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b803c8a4
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b803c8a4
编写于
8月 05, 2013
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8016531: jconsole-plugin script demo does not work with nashorn
Reviewed-by: lagergren, hannesw Contributed-by: rieberandreas@gmail.com
上级
844b1b1f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
155 addition
and
92 deletion
+155
-92
src/share/demo/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java
...src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java
+2
-2
src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js
.../demo/scripting/jconsole-plugin/src/resources/jconsole.js
+104
-40
src/share/demo/scripting/jconsole-plugin/src/scripts/invoke.js
...hare/demo/scripting/jconsole-plugin/src/scripts/invoke.js
+2
-2
src/share/demo/scripting/jconsole-plugin/src/scripts/jstack.js
...hare/demo/scripting/jconsole-plugin/src/scripts/jstack.js
+5
-5
src/share/demo/scripting/jconsole-plugin/src/scripts/jtop.js
src/share/demo/scripting/jconsole-plugin/src/scripts/jtop.js
+6
-6
src/share/demo/scripting/jconsole-plugin/src/scripts/sysprops.js
...re/demo/scripting/jconsole-plugin/src/scripts/sysprops.js
+5
-5
src/share/sample/scripting/scriptpad/README.txt
src/share/sample/scripting/scriptpad/README.txt
+1
-1
src/share/sample/scripting/scriptpad/src/resources/conc.js
src/share/sample/scripting/scriptpad/src/resources/conc.js
+2
-2
src/share/sample/scripting/scriptpad/src/resources/mm.js
src/share/sample/scripting/scriptpad/src/resources/mm.js
+28
-29
未找到文件。
src/share/demo/scripting/jconsole-plugin/src/com/sun/demo/scripting/jconsole/ScriptShellPanel.java
浏览文件 @
b803c8a4
/*
* Copyright (c) 2006, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -54,7 +54,7 @@ import javax.swing.text.*;
* jconsole's script console.
*/
class
ScriptShellPanel
extends
JPanel
{
public
class
ScriptShellPanel
extends
JPanel
{
private
static
final
long
serialVersionUID
=
4116273141148726319L
;
...
...
src/share/demo/scripting/jconsole-plugin/src/resources/jconsole.js
浏览文件 @
b803c8a4
/*
* Copyright (c) 2006, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -77,12 +77,37 @@
function
jcontext
()
{
return
plugin
.
getContext
();
}
jcontext
.
docString
=
"
returns JConsoleContext for the current jconsole plugin
"
jcontext
.
docString
=
"
returns JConsoleContext for the current jconsole plugin
"
;
function
mbeanConnection
()
{
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
...
...
@@ -188,22 +213,12 @@ queryMBeans.docString = "return MBeans using given ObjectName and optional query
// wraps a script array as java.lang.Object[]
function
objectArray
(
array
)
{
var
len
=
array
.
length
;
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
;
return
Java
.
to
(
array
,
"
java.lang.Object[]
"
);
}
// wraps a script (string) array as java.lang.String[]
function
stringArray
(
array
)
{
var
len
=
array
.
length
;
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
;
return
Java
.
to
(
array
,
"
java.lang.String[]
"
);
}
// 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.
*/
function
mbean
(
objName
,
async
)
{
var
index
;
objName
=
objectName
(
objName
);
var
info
=
mbeanInfo
(
objName
);
var
attrs
=
info
.
attributes
;
var
attrMap
=
new
Object
;
for
(
var
index
in
attrs
)
{
for
(
index
in
attrs
)
{
attrMap
[
attrs
[
index
].
name
]
=
attrs
[
index
];
}
var
opers
=
info
.
operations
;
var
operMap
=
new
Object
;
for
(
var
index
in
opers
)
{
for
(
index
in
opers
)
{
operMap
[
opers
[
index
].
name
]
=
opers
[
index
];
}
...
...
@@ -318,21 +335,30 @@ function mbean(objName, async) {
}
else
{
return
getMBeanAttribute
(
objName
,
name
);
}
}
else
if
(
isOperation
(
name
))
{
}
else
{
return
undefined
;
}
},
__call__
:
function
(
name
)
{
if
(
isOperation
(
name
))
{
var
oper
=
operMap
[
name
];
return
function
()
{
var
params
=
objectArray
(
arguments
);
var
sigs
=
oper
.
signature
;
var
sigNames
=
new
Array
(
sigs
.
length
);
for
(
var
index
in
sigs
)
{
sigNames
[
index
]
=
sigs
[
index
].
getType
();
}
if
(
async
)
{
return
invokeMBean
.
future
(
objName
,
name
,
params
,
sigNames
);
}
else
{
return
invokeMBean
(
objName
,
name
,
params
,
sigNames
);
}
var
params
=
[];
for
(
var
j
=
1
;
j
<
arguments
.
length
;
j
++
)
{
params
[
j
-
1
]
=
arguments
[
j
];
}
var
sigs
=
oper
.
signature
;
var
sigNames
=
new
Array
(
sigs
.
length
);
for
(
var
index
in
sigs
)
{
sigNames
[
index
]
=
sigs
[
index
].
getType
();
}
if
(
async
)
{
return
invokeMBean
.
future
(
objName
,
name
,
params
,
sigNames
);
}
else
{
return
invokeMBean
(
objName
,
name
,
params
,
sigNames
);
}
}
else
{
return
undefined
;
...
...
@@ -520,7 +546,7 @@ Function.prototype.sync = function (lock) {
}
finally
{
lock
.
unlock
();
}
}
}
;
/**
* Causes current thread to sleep for specified
...
...
@@ -534,8 +560,7 @@ function sleep(interval) {
sleep
.
docString
=
"
wrapper for java.lang.Thread.sleep method
"
;
/**
* Schedules a task to be executed once in
* every N milliseconds specified.
* Schedules a task to be executed once in N milliseconds specified.
*
* @param callback function or expression to evaluate
* @param interval in milliseconds to sleep
...
...
@@ -549,22 +574,61 @@ function setTimeout(callback, interval) {
// start a new thread that sleeps given time
// and calls callback in an infinite loop
return
(
function
()
{
while
(
true
)
{
try
{
sleep
(
interval
);
}
catch
(
x
)
{
}
callback
();
}).
daemon
();
}
setTimeout
.
docString
=
"
calls given callback once after specified interval
"
;
/**
* Cancels a timeout set earlier.
* @param tid timeout ID returned from setTimeout
*/
function
clearTimeout
(
tid
)
{
// we just interrupt the timer thread
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
();
}
set
Timeout
.
docString
=
"
calls given callback once after specified interval
"
set
Interval
.
docString
=
"
calls given callback every specified interval
"
;
/**
/**
* Cancels a timeout set earlier.
* @param tid timeout ID returned from setTimeout
*/
function
clear
Timeout
(
tid
)
{
function
clear
Interval
(
tid
)
{
// we just interrupt the timer thread
tid
.
interrupt
();
}
clearInterval
.
docString
=
"
interrupt a setInterval timer
"
;
/**
* Simple access to thread local storage.
...
...
@@ -680,7 +744,7 @@ function msgBox(msg, title, msgType) {
if
(
msg
===
undefined
)
msg
=
"
undefined
"
;
if
(
msg
===
null
)
msg
=
"
null
"
;
if
(
title
==
undefined
)
title
=
msg
;
if
(
msgType
==
undefined
)
t
ype
=
JOptionPane
.
INFORMATION_MESSAGE
;
if
(
msgType
==
undefined
)
msgT
ype
=
JOptionPane
.
INFORMATION_MESSAGE
;
JOptionPane
.
showMessageDialog
(
window
,
msg
,
title
,
msgType
);
}
if
(
isEventThread
())
{
...
...
@@ -800,7 +864,7 @@ echo.docString = "echoes arguments to interactive console screen";
* Clear the screen
*/
function
clear
()
{
(
function
()
{
window
.
clear
(
false
)
}).
invokeLater
();
(
function
()
{
window
.
clear
(
false
)
;
}).
invokeLater
();
}
clear
.
docString
=
"
clears interactive console screen
"
;
...
...
src/share/demo/scripting/jconsole-plugin/src/scripts/invoke.js
浏览文件 @
b803c8a4
/*
* Copyright (c) 2006, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -53,6 +53,6 @@
*
*/
function
resetPeakThreadCount
()
{
return
invokeMBean
(
"
java.lang:type=Threading
"
,
"
resetPeakThreadCount
"
,
[],
""
);
return
invokeMBean
(
"
java.lang:type=Threading
"
,
"
resetPeakThreadCount
"
,
[],
{}
);
}
src/share/demo/scripting/jconsole-plugin/src/scripts/jstack.js
浏览文件 @
b803c8a4
/*
* Copyright (c) 2006, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -43,16 +43,16 @@
* threads.'jstack' function which can be called once or periodically
* from a timer thread (calling it periodically would slow down the target
* application). To call this once, just call 'jstack()' in script
* console prompt. To call j
top
in a timer thread, you can use
* console prompt. To call j
stack
in a timer thread, you can use
*
* var t = set
Timeout(function () { jstack(print); }, 5000);
* var t = set
Interval(function () { jstack(print); }, 5000);
*
* The above call prints threads in sorted order for every 5 seconds.
* The print output goes to OS console window from which jconsole was
* started. The timer can be cancelled later by clearTimeout() function
* as shown below:
*
* clear
Timeout(t);
* clear
Interval(t);
*/
...
...
@@ -87,7 +87,7 @@ function jstack(printFunc, maxFrames) {
var
tmbean
=
newPlatformMXBeanProxy
(
"
java.lang:type=Threading
"
,
java
.
lang
.
management
.
ThreadMXBean
);
java
.
lang
.
management
.
ThreadMXBean
.
class
);
var
tids
=
tmbean
.
allThreadIds
;
var
tinfos
=
tmbean
[
"
getThreadInfo(long[],int)
"
](
tids
,
maxFrames
);
...
...
src/share/demo/scripting/jconsole-plugin/src/scripts/jtop.js
浏览文件 @
b803c8a4
/*
* Copyright (c) 2006, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* 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 jtop in a timer thread, you can use
*
* var t = set
Timeout
(function () { jtop(print); }, 2000);
* var t = set
Interval
(function () { jtop(print); }, 2000);
*
* The above call prints threads in sorted order for every 2 seconds.
* The print output goes to OS console window from which jconsole was
* started. The timer can be cancelled later by clearTimeout() function
* as shown below:
*
* clear
Timeout(t);
*
* clear
Interval(t);
*/
/**
...
...
@@ -62,10 +62,10 @@
function
getThreadList
()
{
var
tmbean
=
newPlatformMXBeanProxy
(
"
java.lang:type=Threading
"
,
java
.
lang
.
management
.
ThreadMXBean
);
java
.
lang
.
management
.
ThreadMXBean
.
class
);
if
(
!
tmbean
.
isThreadCpuTimeSupported
())
{
return
;
return
java
.
util
.
Collections
.
EMPTY_LIST
;
}
tmbean
.
setThreadCpuTimeEnabled
(
true
);
...
...
src/share/demo/scripting/jconsole-plugin/src/scripts/sysprops.js
浏览文件 @
b803c8a4
/*
* Copyright (c) 2006, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -43,16 +43,16 @@
* properties.'sysprops' function which can be called once or periodically
* from a timer thread (calling it periodically would slow down the target
* 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 = set
Timeout(function () { sysprops(print); }, 5000);
* var t = set
Interval(function () { sysprops(print); }, 5000);
*
* The above call prints threads in sorted order for every 5 seconds.
* The print output goes to OS console window from which jconsole was
* started. The timer can be cancelled later by clearTimeout() function
* as shown below:
*
* clear
Timeout(t);
* clear
Interval(t);
*/
...
...
@@ -62,7 +62,7 @@
function
getSystemProps
()
{
var
runtimeBean
=
newPlatformMXBeanProxy
(
"
java.lang:type=Runtime
"
,
java
.
lang
.
management
.
RuntimeMXBean
);
java
.
lang
.
management
.
RuntimeMXBean
.
class
);
return
runtimeBean
.
systemProperties
;
}
...
...
src/share/sample/scripting/scriptpad/README.txt
浏览文件 @
b803c8a4
...
...
@@ -108,7 +108,7 @@ under the ./src/scripts directory.
java -Dcom.sun.management.jmxremote.port=1090 \
-Dcom.sun.management.jmxremote.ssl=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.
In the prompt, enter "localhost:1090" to connect to the above
...
...
src/share/sample/scripting/scriptpad/src/resources/conc.js
浏览文件 @
b803c8a4
...
...
@@ -221,7 +221,7 @@ sleep.docString = "wrapper for java.lang.Thread.sleep method";
* @return timeout ID (which is nothing but Thread instance)
*/
function
setTimeout
(
callback
,
interval
)
{
if
(
!
(
callback
instanceof
Function
)
&&
typeof
callback
!==
"
function
"
)
{
if
(
!
(
callback
instanceof
Function
))
{
callback
=
new
Function
(
callback
);
}
...
...
@@ -255,7 +255,7 @@ clearTimeout.docString = "interrupt a setTimeout timer";
* @return timeout ID (which is nothing but Thread instance)
*/
function
setInterval
(
callback
,
interval
)
{
if
(
!
(
callback
instanceof
Function
)
&&
typeof
callback
!==
"
function
"
)
{
if
(
!
(
callback
instanceof
Function
))
{
callback
=
new
Function
(
callback
);
}
...
...
src/share/sample/scripting/scriptpad/src/resources/mm.js
浏览文件 @
b803c8a4
...
...
@@ -159,22 +159,12 @@ queryMBeans.docString = "return MBeans using given ObjectName and optional query
// wraps a script array as java.lang.Object[]
function
objectArray
(
array
)
{
var
len
=
array
.
length
;
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
;
return
Java
.
to
(
array
,
"
java.lang.Object[]
"
);
}
// wraps a script (string) array as java.lang.String[]
function
stringArray
(
array
)
{
var
len
=
array
.
length
;
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
;
return
Java
.
to
(
array
,
"
java.lang.String[]
"
);
}
// script array to Java List
...
...
@@ -284,26 +274,35 @@ function mbean(objName, async) {
__get__
:
function
(
name
)
{
if
(
isAttribute
(
name
))
{
if
(
async
)
{
return
getMBeanAttribute
.
future
(
objName
,
name
);
return
getMBeanAttribute
.
future
(
objName
,
name
);
}
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
];
return
function
()
{
var
params
=
objectArray
(
arguments
);
var
sigs
=
oper
.
signature
;
var
sigNames
=
new
Array
(
sigs
.
length
);
for
(
var
index
in
sigs
)
{
sigNames
[
index
]
=
sigs
[
index
].
getType
();
}
if
(
async
)
{
return
invokeMBean
.
future
(
objName
,
name
,
params
,
sigNames
);
}
else
{
return
invokeMBean
(
objName
,
name
,
params
,
sigNames
);
}
};
var
params
=
[];
for
(
var
j
=
1
;
j
<
arguments
.
length
;
j
++
)
{
params
[
j
-
1
]
=
arguments
[
j
];
}
var
sigs
=
oper
.
signature
;
var
sigNames
=
new
Array
(
sigs
.
length
);
for
(
var
index
in
sigs
)
{
sigNames
[
index
]
=
sigs
[
index
].
getType
();
}
if
(
async
)
{
return
invokeMBean
.
future
(
objName
,
name
,
params
,
sigNames
);
}
else
{
return
invokeMBean
(
objName
,
name
,
params
,
sigNames
);
}
}
else
{
return
undefined
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录