Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
8b5d3f94
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8b5d3f94
编写于
7月 31, 2008
作者:
D
dfuchs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
Reviewed-by: emcmanus
上级
be479f20
变更
5
展开全部
显示空白变更内容
内联
并排
Showing
5 changed file
with
693 addition
and
19 deletion
+693
-19
src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
...om/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
+39
-14
src/share/classes/javax/management/MBeanRegistration.java
src/share/classes/javax/management/MBeanRegistration.java
+24
-1
src/share/classes/javax/management/MBeanServer.java
src/share/classes/javax/management/MBeanServer.java
+19
-0
src/share/classes/javax/management/MBeanServerConnection.java
...share/classes/javax/management/MBeanServerConnection.java
+95
-4
test/javax/management/MBeanServer/PostExceptionTest.java
test/javax/management/MBeanServer/PostExceptionTest.java
+516
-0
未找到文件。
src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
浏览文件 @
8b5d3f94
...
...
@@ -453,12 +453,13 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
final
ResourceContext
context
=
unregisterFromRepository
(
resource
,
instance
,
name
);
try
{
if
(
instance
instanceof
MBeanRegistration
)
postDeregisterInvoke
(
(
MBeanRegistration
)
instance
);
postDeregisterInvoke
(
name
,
(
MBeanRegistration
)
instance
);
}
finally
{
context
.
done
();
}
}
public
ObjectInstance
getObjectInstance
(
ObjectName
name
)
throws
InstanceNotFoundException
{
...
...
@@ -989,10 +990,12 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
registerFailed
=
false
;
registered
=
true
;
}
finally
{
postRegister
(
mbean
,
registered
,
registerFailed
);
try
{
postRegister
(
logicalName
,
mbean
,
registered
,
registerFailed
);
}
finally
{
if
(
registered
)
context
.
done
();
}
}
context
.
done
();
return
new
ObjectInstance
(
logicalName
,
classname
);
}
...
...
@@ -1051,7 +1054,8 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
}
private
static
void
postRegister
(
DynamicMBean
mbean
,
boolean
registrationDone
,
boolean
registerFailed
)
{
ObjectName
logicalName
,
DynamicMBean
mbean
,
boolean
registrationDone
,
boolean
registerFailed
)
{
if
(
registerFailed
&&
mbean
instanceof
DynamicMBean2
)
((
DynamicMBean2
)
mbean
).
registerFailed
();
...
...
@@ -1059,11 +1063,19 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
if
(
mbean
instanceof
MBeanRegistration
)
((
MBeanRegistration
)
mbean
).
postRegister
(
registrationDone
);
}
catch
(
RuntimeException
e
)
{
MBEANSERVER_LOGGER
.
fine
(
"While registering MBean ["
+
logicalName
+
"]: "
+
"Exception thrown by postRegister: "
+
"rethrowing <"
+
e
+
">, but keeping the MBean registered"
);
throw
new
RuntimeMBeanException
(
e
,
"RuntimeException thrown in postRegister method"
);
"RuntimeException thrown in postRegister method: "
+
"rethrowing <"
+
e
+
">, but keeping the MBean registered"
);
}
catch
(
Error
er
)
{
MBEANSERVER_LOGGER
.
fine
(
"While registering MBean ["
+
logicalName
+
"]: "
+
"Error thrown by postRegister: "
+
"rethrowing <"
+
er
+
">, but keeping the MBean registered"
);
throw
new
RuntimeErrorException
(
er
,
"Error thrown in postRegister method"
);
"Error thrown in postRegister method: "
+
"rethrowing <"
+
er
+
">, but keeping the MBean registered"
);
}
}
...
...
@@ -1076,15 +1088,28 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
}
}
private
static
void
postDeregisterInvoke
(
MBeanRegistration
moi
)
{
private
static
void
postDeregisterInvoke
(
ObjectName
mbean
,
MBeanRegistration
moi
)
{
try
{
moi
.
postDeregister
();
}
catch
(
RuntimeException
e
)
{
MBEANSERVER_LOGGER
.
fine
(
"While unregistering MBean ["
+
mbean
+
"]: "
+
"Exception thrown by postDeregister: "
+
"rethrowing <"
+
e
+
">, although the MBean is succesfully "
+
"unregistered"
);
throw
new
RuntimeMBeanException
(
e
,
"RuntimeException thrown in postDeregister method"
);
"RuntimeException thrown in postDeregister method: "
+
"rethrowing <"
+
e
+
">, although the MBean is sucessfully unregistered"
);
}
catch
(
Error
er
)
{
MBEANSERVER_LOGGER
.
fine
(
"While unregistering MBean ["
+
mbean
+
"]: "
+
"Error thrown by postDeregister: "
+
"rethrowing <"
+
er
+
">, although the MBean is succesfully "
+
"unregistered"
);
throw
new
RuntimeErrorException
(
er
,
"Error thrown in postDeregister method"
);
"Error thrown in postDeregister method: "
+
"rethrowing <"
+
er
+
">, although the MBean is sucessfully unregistered"
);
}
}
...
...
src/share/classes/javax/management/MBeanRegistration.java
浏览文件 @
8b5d3f94
...
...
@@ -158,7 +158,19 @@ public interface MBeanRegistration {
/**
* Allows the MBean to perform any operations needed after having been
* registered in the MBean server or after the registration has failed.
*
* <p>If the implementation of this method throws a {@link RuntimeException}
* or an {@link Error}, the MBean Server will rethrow those inside
* a {@link RuntimeMBeanException} or {@link RuntimeErrorException},
* respectively. However, throwing an exception in {@code postRegister}
* will not change the state of the MBean:
* if the MBean was already registered ({@code registrationDone} is
* {@code true}), the MBean will remain registered. </p>
* <p>This might be confusing for the code calling {@code createMBean()}
* or {@code registerMBean()}, as such code might assume that MBean
* registration has failed when such an exception is raised.
* Therefore it is recommended that implementations of
* {@code postRegister} do not throw Runtime Exceptions or Errors if it
* can be avoided.</p>
* @param registrationDone Indicates whether or not the MBean has
* been successfully registered in the MBean server. The value
* false means that the registration phase has failed.
...
...
@@ -178,6 +190,17 @@ public interface MBeanRegistration {
/**
* Allows the MBean to perform any operations needed after having been
* unregistered in the MBean server.
* <p>If the implementation of this method throws a {@link RuntimeException}
* or an {@link Error}, the MBean Server will rethrow those inside
* a {@link RuntimeMBeanException} or {@link RuntimeErrorException},
* respectively. However, throwing an excepption in {@code postDeregister}
* will not change the state of the MBean:
* the MBean was already successfully deregistered and will remain so. </p>
* <p>This might be confusing for the code calling
* {@code unregisterMBean()}, as it might assume that MBean deregistration
* has failed. Therefore it is recommended that implementations of
* {@code postDeregister} do not throw Runtime Exceptions or Errors if it
* can be avoided.</p>
*/
public
void
postDeregister
();
...
...
src/share/classes/javax/management/MBeanServer.java
浏览文件 @
8b5d3f94
...
...
@@ -328,11 +328,30 @@ public interface MBeanServer extends MBeanServerConnection {
* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
* interface) method of the MBean has thrown an exception. The
* MBean will not be registered.
* @exception RuntimeMBeanException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a
* <CODE>RuntimeException</CODE>, the <CODE>registerMBean<CODE> method will
* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean
* registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>registerMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception RuntimeErrorException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an
* <CODE>Error</CODE>, the <CODE>registerMBean<CODE> method will
* throw a <CODE>RuntimeErrorException</CODE>, although the MBean
* registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>registerMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception NotCompliantMBeanException This object is not a JMX
* compliant MBean
* @exception RuntimeOperationsException Wraps a
* <CODE>java.lang.IllegalArgumentException</CODE>: The object
* passed in parameter is null or no object name is specified.
* @see javax.management.MBeanRegistration
*/
public
ObjectInstance
registerMBean
(
Object
object
,
ObjectName
name
)
throws
InstanceAlreadyExistsException
,
MBeanRegistrationException
,
...
...
src/share/classes/javax/management/MBeanServerConnection.java
浏览文件 @
8b5d3f94
...
...
@@ -75,6 +75,24 @@ public interface MBeanServerConnection {
* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
* interface) method of the MBean has thrown an exception. The
* MBean will not be registered.
* @exception RuntimeMBeanException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a
* <CODE>RuntimeException</CODE>, the <CODE>createMBean<CODE> method will
* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation
* and registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>createMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception RuntimeErrorException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an
* <CODE>Error</CODE>, the <CODE>createMBean<CODE> method will
* throw a <CODE>RuntimeErrorException</CODE>, although the MBean creation
* and registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>createMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception MBeanException The constructor of the MBean has
* thrown an exception
* @exception NotCompliantMBeanException This class is not a JMX
...
...
@@ -86,7 +104,7 @@ public interface MBeanServerConnection {
* is specified for the MBean.
* @exception IOException A communication problem occurred when
* talking to the MBean server.
*
*
@see javax.management.MBeanRegistration
*/
public
ObjectInstance
createMBean
(
String
className
,
ObjectName
name
)
throws
ReflectionException
,
InstanceAlreadyExistsException
,
...
...
@@ -129,6 +147,24 @@ public interface MBeanServerConnection {
* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
* interface) method of the MBean has thrown an exception. The
* MBean will not be registered.
* @exception RuntimeMBeanException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a
* <CODE>RuntimeException</CODE>, the <CODE>createMBean<CODE> method will
* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation
* and registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>createMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception RuntimeErrorException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an
* <CODE>Error</CODE>, the <CODE>createMBean<CODE> method will
* throw a <CODE>RuntimeErrorException</CODE>, although the MBean creation
* and registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>createMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception MBeanException The constructor of the MBean has
* thrown an exception
* @exception NotCompliantMBeanException This class is not a JMX
...
...
@@ -142,6 +178,7 @@ public interface MBeanServerConnection {
* is specified for the MBean.
* @exception IOException A communication problem occurred when
* talking to the MBean server.
* @see javax.management.MBeanRegistration
*/
public
ObjectInstance
createMBean
(
String
className
,
ObjectName
name
,
ObjectName
loaderName
)
...
...
@@ -185,6 +222,24 @@ public interface MBeanServerConnection {
* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
* interface) method of the MBean has thrown an exception. The
* MBean will not be registered.
* @exception RuntimeMBeanException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a
* <CODE>RuntimeException</CODE>, the <CODE>createMBean<CODE> method will
* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation
* and registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>createMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception RuntimeErrorException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an
* <CODE>Error</CODE>, the <CODE>createMBean<CODE> method will
* throw a <CODE>RuntimeErrorException</CODE>, although the MBean creation
* and registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>createMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception MBeanException The constructor of the MBean has
* thrown an exception
* @exception NotCompliantMBeanException This class is not a JMX
...
...
@@ -196,7 +251,7 @@ public interface MBeanServerConnection {
* is specified for the MBean.
* @exception IOException A communication problem occurred when
* talking to the MBean server.
*
*
@see javax.management.MBeanRegistration
*/
public
ObjectInstance
createMBean
(
String
className
,
ObjectName
name
,
Object
params
[],
String
signature
[])
...
...
@@ -239,6 +294,24 @@ public interface MBeanServerConnection {
* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
* interface) method of the MBean has thrown an exception. The
* MBean will not be registered.
* @exception RuntimeMBeanException If the <CODE>postRegister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a
* <CODE>RuntimeException</CODE>, the <CODE>createMBean<CODE> method will
* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation
* and registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>createMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception RuntimeErrorException If the <CODE>postRegister</CODE> method
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an
* <CODE>Error</CODE>, the <CODE>createMBean<CODE> method will
* throw a <CODE>RuntimeErrorException</CODE>, although the MBean creation
* and registration succeeded. In such a case, the MBean will be actually
* registered even though the <CODE>createMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can
* also be thrown by <CODE>preRegister</CODE>, in which case the MBean
* will not be registered.
* @exception MBeanException The constructor of the MBean has
* thrown an exception
* @exception NotCompliantMBeanException This class is not a JMX
...
...
@@ -252,7 +325,7 @@ public interface MBeanServerConnection {
* is specified for the MBean.
* @exception IOException A communication problem occurred when
* talking to the MBean server.
*
*
@see javax.management.MBeanRegistration
*/
public
ObjectInstance
createMBean
(
String
className
,
ObjectName
name
,
ObjectName
loaderName
,
Object
params
[],
...
...
@@ -275,6 +348,24 @@ public interface MBeanServerConnection {
* @exception MBeanRegistrationException The preDeregister
* ((<CODE>MBeanRegistration</CODE> interface) method of the MBean
* has thrown an exception.
* @exception RuntimeMBeanException If the <CODE>postDeregister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a
* <CODE>RuntimeException</CODE>, the <CODE>unregisterMBean<CODE> method
* will throw a <CODE>RuntimeMBeanException</CODE>, although the MBean
* unregistration succeeded. In such a case, the MBean will be actually
* unregistered even though the <CODE>unregisterMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can
* also be thrown by <CODE>preDeregister</CODE>, in which case the MBean
* will remain registered.
* @exception RuntimeErrorException If the <CODE>postDeregister</CODE>
* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an
* <CODE>Error</CODE>, the <CODE>unregisterMBean<CODE> method will
* throw a <CODE>RuntimeErrorException</CODE>, although the MBean
* unregistration succeeded. In such a case, the MBean will be actually
* unregistered even though the <CODE>unregisterMBean<CODE> method
* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can
* also be thrown by <CODE>preDeregister</CODE>, in which case the MBean
* will remain registered.
* @exception RuntimeOperationsException Wraps a
* <CODE>java.lang.IllegalArgumentException</CODE>: The object
* name in parameter is null or the MBean you are when trying to
...
...
@@ -282,7 +373,7 @@ public interface MBeanServerConnection {
* MBeanServerDelegate} MBean.
* @exception IOException A communication problem occurred when
* talking to the MBean server.
*
*
@see javax.management.MBeanRegistration
*/
public
void
unregisterMBean
(
ObjectName
name
)
throws
InstanceNotFoundException
,
MBeanRegistrationException
,
...
...
test/javax/management/MBeanServer/PostExceptionTest.java
0 → 100644
浏览文件 @
8b5d3f94
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录