本文整理匯總了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);
}
}