本文整理汇总了Java中javax.management.MBeanOperationInfo.getDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java MBeanOperationInfo.getDescriptor方法的具体用法?Java MBeanOperationInfo.getDescriptor怎么用?Java MBeanOperationInfo.getDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.MBeanOperationInfo
的用法示例。
在下文中一共展示了MBeanOperationInfo.getDescriptor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printOperation
import javax.management.MBeanOperationInfo; //导入方法依赖的package包/类
static void printOperation(MBeanOperationInfo info) {
System.out.println("Name: "+info.getName());
System.out.println("Description: "+info.getDescription());
System.out.println("Return Type: "+info.getReturnType());
System.out.println("Impact: "+info.getImpact());
Descriptor desc = info.getDescriptor();
System.out.println("Descriptor");
for(int i=0; i<desc.getFieldNames().length; i++) {
if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
System.out.println("\t"+desc.getFieldNames()[i]+":");
Descriptor desc2 =
(Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
for(int j=0; j<desc2.getFieldNames().length; j++) {
System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
Descriptor desc3 =
(Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
for(int k=0; k<desc3.getFieldNames().length; k++) {
System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
+desc3.getFieldValue(desc3.getFieldNames()[k]));
}
}
} else {
System.out.println("\t"+desc.getFieldNames()[i]+"="
+desc.getFieldValue(desc.getFieldNames()[i]));
}
}
}
示例2: testOperation
import javax.management.MBeanOperationInfo; //导入方法依赖的package包/类
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
ObjectName on, MBeanOperationInfo opInfo) {
System.out.println("Testing " + opInfo.getName());
Descriptor desc = opInfo.getDescriptor();
if (desc.getFieldValue("dcmd.permissionClass") == null) {
// No special permission required, execution should not trigger
// any security exception
if (invokeOperation(mbs, on, opInfo)) {
throw new RuntimeException("TEST FAILED");
}
} else {
// Building the required permission
Permission reqPerm = createPermission(
(String)desc.getFieldValue("dcmd.permissionClass"),
(String)desc.getFieldValue("dcmd.permissionName"),
(String)desc.getFieldValue("dcmd.permissionAction"));
// Paranoid mode: check that the SecurityManager has not already
// been granted the permission
sm.denyPermission(reqPerm);
// A special permission is required for this operation,
// invoking it without the permission granted must trigger
// a security exception
if(!invokeOperation(mbs, on, opInfo)) {
throw new RuntimeException("TEST FAILED");
}
// grant the permission and re-try invoking the operation
sm.grantPermission(reqPerm);
if(invokeOperation(mbs, on, opInfo)) {
throw new RuntimeException("TEST FAILED");
}
// Clean up
sm.denyPermission(reqPerm);
}
}