当前位置: 首页>>代码示例>>Java>>正文


Java ModelMBeanOperationInfo.getDescriptor方法代码示例

本文整理汇总了Java中javax.management.modelmbean.ModelMBeanOperationInfo.getDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java ModelMBeanOperationInfo.getDescriptor方法的具体用法?Java ModelMBeanOperationInfo.getDescriptor怎么用?Java ModelMBeanOperationInfo.getDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.modelmbean.ModelMBeanOperationInfo的用法示例。


在下文中一共展示了ModelMBeanOperationInfo.getDescriptor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testModelMBeanOperationInfo

import javax.management.modelmbean.ModelMBeanOperationInfo; //导入方法依赖的package包/类
/**
 * Verify default fields of descriptor from ModelMBeanOperationInfo:
 * name=nameOfMethod, displayName=nameOfMethod, role=operation and
 * descriptorType=operation.
 */
public Result testModelMBeanOperationInfo() throws Exception {
    Method method = sampleClass.getMethod("sayOk", null);
    ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo(
        "description", method);
    descriptor = operationInfo.getDescriptor();
    String name = (String)descriptor.getFieldValue("name");
    assertEquals(name, descriptor.getFieldValue("Name"));
    assertEquals(name, method.getName());
    assertEquals(descriptor.getFieldValue("displayName"), method.getName());
    assertEquals(descriptor.getFieldValue("role"), "operation");
    assertEquals(descriptor.getFieldValue("descriptorType"), "operation");
    assertEquals(descriptor.getFields().length, 4);
    commonCheck();
    return result();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:21,代码来源:DefaultDescriptorTest.java

示例2: extractMbeanOperations

import javax.management.modelmbean.ModelMBeanOperationInfo; //导入方法依赖的package包/类
private void extractMbeanOperations(Object managedBean, Set<ManagedOperationInfo> operations, Set<ModelMBeanOperationInfo> mBeanOperations) {
    for (ManagedOperationInfo info : operations) {
        ModelMBeanOperationInfo mbean = new ModelMBeanOperationInfo(info.getDescription(), info.getOperation());
        Descriptor opDesc = mbean.getDescriptor();
        mbean.setDescriptor(opDesc);
        mBeanOperations.add(mbean);
        LOGGER.trace("Assembled operation: {}", mbean);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:10,代码来源:MBeanInfoAssembler.java

示例3: extractMbeanOperations

import javax.management.modelmbean.ModelMBeanOperationInfo; //导入方法依赖的package包/类
private void extractMbeanOperations(Object managedBean, Set<ManagedOperationInfo> operations, Set<ModelMBeanOperationInfo> mBeanOperations) {
    for (ManagedOperationInfo info : operations) {
        ModelMBeanOperationInfo mbean = new ModelMBeanOperationInfo(info.getDescription(), info.getOperation());
        Descriptor opDesc = mbean.getDescriptor();
        opDesc.setField("mask", info.isMask() ? "true" : "false");
        mbean.setDescriptor(opDesc);
        mBeanOperations.add(mbean);
        LOG.trace("Assembled operation: {}", mbean);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:MBeanInfoAssembler.java

示例4: testException

import javax.management.modelmbean.ModelMBeanOperationInfo; //导入方法依赖的package包/类
/**
 * Verify that invoke method throws exception if target operation method
 * throws exception.
 * <ul>
 * Step by step:
 * <li>Create operation method with one string parameter which always
 * throws an exception with message=parameter of this method.
 * <li>Create ModelMBeanOperationInfo object for operation method.
 * <li>Set value currencyTimeLimit = 0 in descriptor for
 * ModelMBeanOperationInfo object.
 * <li>Create ModelMBeanInfoSupport object with default descriptor. All
 * ModelMBeanXXXInfo except ModelMBeanOperationInfo are default.
 * <li>Instance of class created in 1st step sets managed resource for
 * RequiredModelMBean using setManagedResource method.
 * <li>Create ObjectName object.
 * <li>Register RequiredModelMBean object in MBeanServer with above
 * ObjectName.
 * <li>Invoke operation methodThrowException method thru invoke method of
 * MBeanServer with specific msg.
 * <li>Verify that MBeanException was thrown with nested exception which
 * has message which specified in previous step.
 * </ul>
 */
public Result testException() throws Exception {
    Method method = class1.getMethod("methodThrowException",
        new Class[] { String.class });
    ModelMBeanOperationInfo operationInfo1 = new ModelMBeanOperationInfo(
        "description", method);
    Descriptor descriptor = operationInfo1.getDescriptor();
    descriptor.setField("currencyTimeLimit", "0");
    operationInfo1.setDescriptor(descriptor);
    ModelMBeanInfoSupport beanInfoSupport = new ModelMBeanInfoSupport(
        class1.getName(), "description", null, null,
        new ModelMBeanOperationInfo[] { operationInfo1 }, null);
    RequiredModelMBean requiredModelMBean = new RequiredModelMBean(
        beanInfoSupport);
    requiredModelMBean.setManagedResource(this, "ObjectReference");
    ObjectName objectName = new ObjectName("domain", "name", "simple name");
    MBeanServer server = MBeanServerFactory.createMBeanServer();
    server.registerMBean(requiredModelMBean, objectName);
    try {
        server.invoke(objectName, method.getName(),
            new Object[] { "message" }, new String[] { String.class
                .getName() });
        assertTrue(false);
    } catch (MBeanException e) {
        assertEquals(e.getCause().getMessage(), "message");
    }
    assertTrue(isInvokedMethod());
    return result();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:52,代码来源:InvocationTest.java

示例5: testNegative

import javax.management.modelmbean.ModelMBeanOperationInfo; //导入方法依赖的package包/类
/**
 * Verify that invoke method never caches returned value of method if
 * currencyTimeLimit < 0.
 * <ul>
 * Step by step:
 * <li>Create operation method without parameters which always returns the
 * same value.
 * <li>Create ModelMBeanOperationInfo object for operation method.
 * <li>Set value currencyTimeLimit <0 in descriptor for
 * ModelMBeanOperationInfo object.
 * <li>Create ModelMBeanInfoSupport object with default descriptor. All
 * ModelMBeanXXXInfo except ModelMBeanOperationInfo are default.
 * <li>Create RequiredModelMBean object.
 * <li>Instance of class created in 1st step sets managed resource for
 * RequiredModelMBean using setManagedResource method.
 * <li>Create ObjectName object.
 * <li>Register RequiredModelMBean object in MBeanServer with above
 * ObjectName.
 * <li>Invoke operation method thru invoke method of MBeanServer.
 * <li>Verify value which the invoke method returned is the same as value
 * which the operation method returned.
 * <li>Verify that operation method was invoked.
 * <li>Invoke again operation method thru invoke method of MBeanServer.
 * <li>Verify value which the invoke method returned is the same as value
 * which the operation method returned.
 * <li>Verify that operation method was invoked.
 * </ul>
 */
public Result testNegative() throws Exception {
    Method method = class1.getDeclaredMethod("simpleMethod", null);
    ModelMBeanOperationInfo operationInfo1 = new ModelMBeanOperationInfo(
        "description", method);
    Descriptor descriptor = operationInfo1.getDescriptor();
    descriptor.setField("currencyTimeLimit", "-1");
    operationInfo1.setDescriptor(descriptor);
    ModelMBeanInfoSupport beanInfoSupport = new ModelMBeanInfoSupport(
        class1.getName(), "description", null, null,
        new ModelMBeanOperationInfo[] { operationInfo1 }, null);
    RequiredModelMBean requiredModelMBean = new RequiredModelMBean(
        beanInfoSupport);
    requiredModelMBean.setManagedResource(this, "ObjectReference");
    ObjectName objectName = new ObjectName("domain", "name", "simple name");
    MBeanServer server = MBeanServerFactory.createMBeanServer();
    server.registerMBean(requiredModelMBean, objectName);
    Object value = server.invoke(objectName, method.getName(), null, null);
    assertEquals(value, returnedObject);
    assertTrue(isInvokedMethod());
    ModelMBeanOperationInfo operationInfo2 = (ModelMBeanOperationInfo)server
        .getMBeanInfo(objectName).getOperations()[0];
    assertTrue(operationInfo1 == operationInfo2);

    value = server.invoke(objectName, method.getName(), null, null);
    assertEquals(value, returnedObject);
    assertTrue(isInvokedMethod());
    return result();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:57,代码来源:InvocationTest.java

示例6: testPositive

import javax.management.modelmbean.ModelMBeanOperationInfo; //导入方法依赖的package包/类
/**
 * Verify that invoke method retrieves returned value of method from cache
 * or invoke operation depends on currencyTimeLimit > 0 and
 * lastUpdatedTimeStamp.
 * <ul>
 * Step by step:
 * <li>Create operation method without parameters which always returns
 * value.
 * <li>Create ModelMBeanOperationInfo object for operation method.
 * <li>Set value currencyTimeLimit = > 0 in descriptor for
 * ModelMBeanOperationInfo object.
 * <li>Create ModelMBeanInfoSupport object with default descriptor. All
 * ModelMBeanXXXInfo except ModelMBeanOperationInfo are default.
 * <li>Instance of class created in 1st step sets managed resource for
 * RequiredModelMBean using setManagedResource method.
 * <li>Create ObjectName object.
 * <li>Register RequiredModelMBean object in MBeanServer with above
 * ObjectName.
 * <li>Invoke operation method thru invoke method of MBeanServer.
 * <li>Verify value which the invoke method returned is the same as value
 * which the operation method returned.
 * <li>Verify that operation method was invoked.
 * <li>Verify value of field `value` in descriptor for
 * ModelMBeanOperationInfo object.
 * <li>Invoke again operation method thru invoke method of MBeanServer.
 * <li>Verify returned value is not changed.
 * <li>Verify that operation method wasn't invoked.
 * <li>Verify value of field `value` in descriptor for
 * ModelMBeanOperationInfo object is not changed.
 * <li>Change returned value of operation method.
 * <li> Wait currencyTimeLimit seconds.
 * <li>Invoke again operation method thru invoke method of MBeanServer.
 * <li>Verify value which the invoke method returned is the same as value
 * which the operation method returned.
 * <li>Verify that operation method was invoked.
 * <li>Verify value of field `value` in descriptor for
 * ModelMBeanOperationInfo object is changed and verify this value.
 * </ul>
 */
public Result testPositive() throws Exception {
    Method method = class1.getMethod("simpleMethod", null);
    ModelMBeanOperationInfo operationInfo1 = new ModelMBeanOperationInfo(
        "description", method);
    Descriptor descriptor = operationInfo1.getDescriptor();
    int currencyTimeLimit = 5;
    descriptor.setField("currencyTimeLimit", currencyTimeLimit + "");
    operationInfo1.setDescriptor(descriptor);
    ModelMBeanInfoSupport beanInfoSupport = new ModelMBeanInfoSupport(
        class1.getName(), "description", null, null,
        new ModelMBeanOperationInfo[] { operationInfo1 }, null);
    RequiredModelMBean requiredModelMBean = new RequiredModelMBean(
        beanInfoSupport);
    requiredModelMBean.setManagedResource(this, "ObjectReference");
    ObjectName objectName = new ObjectName("domain", "name", "simple name");
    MBeanServer server = MBeanServerFactory.createMBeanServer();
    server.registerMBean(requiredModelMBean, objectName);
    Object value = server.invoke(objectName, method.getName(), null, null);
    assertEquals(value, returnedObject);
    assertTrue(isInvokedMethod());
    printValue(server.getMBeanInfo(objectName));
    value = server.invoke(objectName, method.getName(), null, null);
    assertEquals(value, returnedObject);
    assertFalse(isInvokedMethod());
    printValue(server.getMBeanInfo(objectName));
    returnedObject = new Integer(10);
    Thread.sleep(1000 * currencyTimeLimit + latancy);
    value = server.invoke(objectName, method.getName(), null, null);
    assertEquals(value, returnedObject);
    printValue(server.getMBeanInfo(objectName));
    assertTrue(isInvokedMethod());
    return result();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:73,代码来源:InvocationTest.java


注:本文中的javax.management.modelmbean.ModelMBeanOperationInfo.getDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。