java类javax.management.modelmbean.ModelMBeanOperationInfo的实例源码

ServerFunction.java 文件源码 项目:SamaGamesCore 阅读 19 收藏 0 点赞 0 评论 0
@RemoteMethod(description = "Get current server tps", impact = ModelMBeanOperationInfo.ACTION)
public double tps()
{
    try
    {
        double result = 0;
        double[] recentTps = (double[]) recentTpsField.get(getServerMethod.invoke(null));

        for(double one : recentTps)
            result += one;

        return result / recentTps.length;
    }
    catch (IllegalAccessException | InvocationTargetException e)
    {
        e.printStackTrace();
    }

    return 0;
}
AbstractJmxAssemblerTests.java 文件源码 项目:spring4-understanding 阅读 19 收藏 0 点赞 0 评论 0
@Test
public void testAttributeHasCorrespondingOperations() throws Exception {
    ModelMBeanInfo info = getMBeanInfoFromAssembler();

    ModelMBeanOperationInfo get = info.getOperation("getName");
    assertNotNull("get operation should not be null", get);
    assertEquals("get operation should have visibility of four",
            get.getDescriptor().getFieldValue("visibility"),
            new Integer(4));
    assertEquals("get operation should have role \"getter\"", "getter", get.getDescriptor().getFieldValue("role"));

    ModelMBeanOperationInfo set = info.getOperation("setName");
    assertNotNull("set operation should not be null", set);
    assertEquals("set operation should have visibility of four",
            set.getDescriptor().getFieldValue("visibility"),
            new Integer(4));
    assertEquals("set operation should have role \"setter\"", "setter", set.getDescriptor().getFieldValue("role"));
}
AbstractJmxAssemblerTests.java 文件源码 项目:class-guard 阅读 24 收藏 0 点赞 0 评论 0
@Test
public void testAttributeHasCorrespondingOperations() throws Exception {
    ModelMBeanInfo info = getMBeanInfoFromAssembler();

    ModelMBeanOperationInfo get = info.getOperation("getName");
    assertNotNull("get operation should not be null", get);
    assertEquals("get operation should have visibility of four",
            get.getDescriptor().getFieldValue("visibility"),
            new Integer(4));
    assertEquals("get operation should have role \"getter\"", "getter", get.getDescriptor().getFieldValue("role"));

    ModelMBeanOperationInfo set = info.getOperation("setName");
    assertNotNull("set operation should not be null", set);
    assertEquals("set operation should have visibility of four",
            set.getDescriptor().getFieldValue("visibility"),
            new Integer(4));
    assertEquals("set operation should have role \"setter\"", "setter", set.getDescriptor().getFieldValue("role"));
}
TestModelMBean.java 文件源码 项目:wildfly-core 阅读 22 收藏 0 点赞 0 评论 0
@Override
public MBeanInfo getMBeanInfo() {
    try {
        ModelMBeanAttributeInfo[] attributes = new ModelMBeanAttributeInfo[0];
        ModelMBeanConstructorInfo[] constructors = new ModelMBeanConstructorInfo[] {
                new ModelMBeanConstructorInfo("-", this.getClass().getConstructor())
        };
        ModelMBeanOperationInfo[] operations = new ModelMBeanOperationInfo[] {
                new ModelMBeanOperationInfo("info", "-", new MBeanParameterInfo[0], Void.class.getName(), ModelMBeanOperationInfo.INFO),
                new ModelMBeanOperationInfo("action", "-", new MBeanParameterInfo[0], Void.class.getName(), ModelMBeanOperationInfo.ACTION),
                new ModelMBeanOperationInfo("actionInfo", "-", new MBeanParameterInfo[0], Void.class.getName(), ModelMBeanOperationInfo.ACTION_INFO),
                new ModelMBeanOperationInfo("unknown", "-", new MBeanParameterInfo[0], Void.class.getName(), ModelMBeanOperationInfo.UNKNOWN)
        };
        ModelMBeanNotificationInfo[] notifications = new ModelMBeanNotificationInfo[0];
        return new ModelMBeanInfoSupport(this.getClass().getName(), "-", attributes, constructors, operations, notifications);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
InvocationTest.java 文件源码 项目:freeVM 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Verify that returned value of invoked method never retrieves value from
 * cache if currencyTimeLimit is not defended in descriptor of
 * ModelMBeanOperationInfo.
 * <p>
 * Instructions are the same as in testNegative.
 */
public Result testNotPresent() throws Exception {
    Method method = class1.getDeclaredMethod("simpleMethod", null);
    ModelMBeanOperationInfo operationInfo1 = new ModelMBeanOperationInfo(
        "description", method);
    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();
}
DefaultDescriptorTest.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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();
}
JmxUtils.java 文件源码 项目:iaf 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Builds an operationInfor for getter purposes.
 * @param name
 * @param klass 
 * @param description
 * @param signature
 */
public static ModelMBeanOperationInfo buildGetterModelMBeanOperationInfo(
    String name,
    String klass,
    String description,
    String signature) {

    Descriptor theDescriptor = buildGetterDescriptor(name, klass);
    return new ModelMBeanOperationInfo(
        name,
        description,
        null,
        signature,
        ModelMBeanOperationInfo.INFO,
        theDescriptor);

}
AbstractReflectiveMBeanInfoAssembler.java 文件源码 项目:lams 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Creates an instance of {@code ModelMBeanOperationInfo} for the
 * given method. Populates the parameter info for the operation.
 * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for
 * @param name the logical name for the operation (method name or property name);
 * not used by the default implementation but possibly by subclasses
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the {@code ModelMBeanOperationInfo}
 */
protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) {
    MBeanParameterInfo[] params = getOperationParameters(method, beanKey);
    if (params.length == 0) {
        return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method);
    }
    else {
        return new ModelMBeanOperationInfo(method.getName(),
            getOperationDescription(method, beanKey),
            getOperationParameters(method, beanKey),
            method.getReturnType().getName(),
            MBeanOperationInfo.UNKNOWN);
    }
}
WhitelistFunction.java 文件源码 项目:SamaGamesCore 阅读 19 收藏 0 点赞 0 评论 0
@RemoteMethod(description = "Add a player to the whitelist", impact = ModelMBeanOperationInfo.ACTION)
public void addPlayer(UUID player)
{
    Bukkit.getWhitelistedPlayers().add(Bukkit.getOfflinePlayer(player));
    Bukkit.reloadWhitelist();
    Bukkit.getLogger().info("Added player " + player + " to whitelist");
}
WhitelistFunction.java 文件源码 项目:SamaGamesCore 阅读 18 收藏 0 点赞 0 评论 0
@RemoteMethod(description = "Remove a player to the whitelist", impact = ModelMBeanOperationInfo.ACTION)
public void removePlayer(UUID player)
{
    Bukkit.getWhitelistedPlayers().add(Bukkit.getOfflinePlayer(player));
    Bukkit.reloadWhitelist();
    Bukkit.getLogger().info("Added player " + player + " to whitelist");
}
AbstractReflectiveMBeanInfoAssembler.java 文件源码 项目:spring4-understanding 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Creates an instance of {@code ModelMBeanOperationInfo} for the
 * given method. Populates the parameter info for the operation.
 * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for
 * @param name the logical name for the operation (method name or property name);
 * not used by the default implementation but possibly by subclasses
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the {@code ModelMBeanOperationInfo}
 */
protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) {
    MBeanParameterInfo[] params = getOperationParameters(method, beanKey);
    if (params.length == 0) {
        return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method);
    }
    else {
        return new ModelMBeanOperationInfo(method.getName(),
            getOperationDescription(method, beanKey),
            getOperationParameters(method, beanKey),
            method.getReturnType().getName(),
            MBeanOperationInfo.UNKNOWN);
    }
}
AbstractMetadataAssemblerTests.java 文件源码 项目:spring4-understanding 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void testOperationParameterMetadata() throws Exception {
    ModelMBeanInfo info = getMBeanInfoFromAssembler();
    ModelMBeanOperationInfo oper = info.getOperation("add");
    MBeanParameterInfo[] params = oper.getSignature();

    assertEquals("Invalid number of params", 2, params.length);
    assertEquals("Incorrect name for x param", "x", params[0].getName());
    assertEquals("Incorrect type for x param", int.class.getName(), params[0].getType());

    assertEquals("Incorrect name for y param", "y", params[1].getName());
    assertEquals("Incorrect type for y param", int.class.getName(), params[1].getType());
}
AbstractMetadataAssemblerTests.java 文件源码 项目:spring4-understanding 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void testMetricDescription() throws Exception {
    ModelMBeanInfo inf = getMBeanInfoFromAssembler();
    ModelMBeanAttributeInfo metric = inf.getAttribute(QUEUE_SIZE_METRIC);
    ModelMBeanOperationInfo operation = inf.getOperation("getQueueSize");
    assertEquals("The description for the queue size metric is incorrect",
            "The QueueSize metric", metric.getDescription());
    assertEquals("The description for the getter operation of the queue size metric is incorrect",
            "The QueueSize metric", operation.getDescription());
}
AbstractReflectiveMBeanInfoAssembler.java 文件源码 项目:my-spring-cache-redis 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Creates an instance of {@code ModelMBeanOperationInfo} for the
 * given method. Populates the parameter info for the operation.
 * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for
 * @param name the logical name for the operation (method name or property name);
 * not used by the default implementation but possibly by subclasses
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the {@code ModelMBeanOperationInfo}
 */
protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) {
    MBeanParameterInfo[] params = getOperationParameters(method, beanKey);
    if (params.length == 0) {
        return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method);
    }
    else {
        return new ModelMBeanOperationInfo(method.getName(),
            getOperationDescription(method, beanKey),
            getOperationParameters(method, beanKey),
            method.getReturnType().getName(),
            MBeanOperationInfo.UNKNOWN);
    }
}
AbstractReflectiveMBeanInfoAssembler.java 文件源码 项目:spring 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Creates an instance of {@code ModelMBeanOperationInfo} for the
 * given method. Populates the parameter info for the operation.
 * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for
 * @param name the logical name for the operation (method name or property name);
 * not used by the default implementation but possibly by subclasses
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the {@code ModelMBeanOperationInfo}
 */
protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) {
    MBeanParameterInfo[] params = getOperationParameters(method, beanKey);
    if (params.length == 0) {
        return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method);
    }
    else {
        return new ModelMBeanOperationInfo(method.getName(),
            getOperationDescription(method, beanKey),
            getOperationParameters(method, beanKey),
            method.getReturnType().getName(),
            MBeanOperationInfo.UNKNOWN);
    }
}
MBeanInfoAssembler.java 文件源码 项目:flowable-engine 阅读 24 收藏 0 点赞 0 评论 0
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);
    }
}
MBeanInfoAssembler.java 文件源码 项目:Camel 阅读 24 收藏 0 点赞 0 评论 0
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);
    }
}
AbstractReflectiveMBeanInfoAssembler.java 文件源码 项目:class-guard 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Creates an instance of {@code ModelMBeanOperationInfo} for the
 * given method. Populates the parameter info for the operation.
 * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for
 * @param name the logical name for the operation (method name or property name);
 * not used by the default implementation but possibly by subclasses
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the {@code ModelMBeanOperationInfo}
 */
protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) {
    MBeanParameterInfo[] params = getOperationParameters(method, beanKey);
    if (params.length == 0) {
        return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method);
    }
    else {
        return new ModelMBeanOperationInfo(method.getName(),
            getOperationDescription(method, beanKey),
            getOperationParameters(method, beanKey),
            method.getReturnType().getName(),
            MBeanOperationInfo.UNKNOWN);
    }
}
AbstractMetadataAssemblerTests.java 文件源码 项目:class-guard 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void testOperationParameterMetadata() throws Exception {
    ModelMBeanInfo info = getMBeanInfoFromAssembler();
    ModelMBeanOperationInfo oper = info.getOperation("add");
    MBeanParameterInfo[] params = oper.getSignature();

    assertEquals("Invalid number of params", 2, params.length);
    assertEquals("Incorrect name for x param", "x", params[0].getName());
    assertEquals("Incorrect type for x param", int.class.getName(), params[0].getType());

    assertEquals("Incorrect name for y param", "y", params[1].getName());
    assertEquals("Incorrect type for y param", int.class.getName(), params[1].getType());
}
AbstractMetadataAssemblerTests.java 文件源码 项目:class-guard 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void testMetricDescription() throws Exception {
    ModelMBeanInfo inf = getMBeanInfoFromAssembler();
    ModelMBeanAttributeInfo metric = inf.getAttribute(QUEUE_SIZE_METRIC);
    ModelMBeanOperationInfo operation = inf.getOperation("getQueueSize");
    assertEquals("The description for the queue size metric is incorrect",
            "The QueueSize metric", metric.getDescription());
    assertEquals("The description for the getter operation of the queue size metric is incorrect",
            "The QueueSize metric", operation.getDescription());
}
UserDefinedDescriptorTest.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Do 1-6 steps.
 */
private ModelMBeanInfoSupport constractModelMBeanInfoSupport()
    throws Exception {
    ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo(
        "description", class1.getMethod("simpleOperartion", null));
    setDescriptor(operationInfo);
    ModelMBeanConstructorInfo constructorInfo = new ModelMBeanConstructorInfo(
        "description", class1.getConstructor(null));
    setDescriptor(constructorInfo);
    ModelMBeanAttributeInfo attributeInfo = new ModelMBeanAttributeInfo(
        "name", "description", class1.getMethod("getH", null), class1
            .getMethod("setH", new Class[] { int.class }));
    setDescriptor(attributeInfo);
    ModelMBeanNotificationInfo notificationInfo = new ModelMBeanNotificationInfo(
        new String[] { "specific notification tepes" }, "name",
        "description");
    setDescriptor(notificationInfo);
    ModelMBeanInfoSupport beanInfoSupport = new ModelMBeanInfoSupport(
        class1.getName(), "description",
        new ModelMBeanAttributeInfo[] { attributeInfo },
        new ModelMBeanConstructorInfo[] { constructorInfo },
        new ModelMBeanOperationInfo[] { operationInfo },
        new ModelMBeanNotificationInfo[] { notificationInfo });
    Descriptor descriptor = beanInfoSupport.getMBeanDescriptor();
    String[] strings = getSpesific(beanInfoSupport.getClass());
    descriptor.setField(strings[0], strings[1]);
    map.put(beanInfoSupport.getClass().getName(), descriptor);
    beanInfoSupport.setMBeanDescriptor(descriptor);
    return beanInfoSupport;
}
InvocationTest.java 文件源码 项目:freeVM 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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();
}
InvocationTest.java 文件源码 项目:freeVM 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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();
}
JmxUtils.java 文件源码 项目:voldemort 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Extract all operations and attributes from the given object that have
 * been annotated with the Jmx annotation. Operations are all methods that
 * are marked with the JmxOperation annotation.
 * 
 * @param object The object to process
 * @return An array of operations taken from the object
 */
public static ModelMBeanOperationInfo[] extractOperationInfo(Object object) {
    ArrayList<ModelMBeanOperationInfo> infos = new ArrayList<ModelMBeanOperationInfo>();
    for(Method m: object.getClass().getMethods()) {
        JmxOperation jmxOperation = m.getAnnotation(JmxOperation.class);
        JmxGetter jmxGetter = m.getAnnotation(JmxGetter.class);
        JmxSetter jmxSetter = m.getAnnotation(JmxSetter.class);
        if(jmxOperation != null || jmxGetter != null || jmxSetter != null) {
            String description = "";
            int visibility = 1;
            int impact = MBeanOperationInfo.UNKNOWN;
            if(jmxOperation != null) {
                description = jmxOperation.description();
                impact = jmxOperation.impact();
            } else if(jmxGetter != null) {
                description = jmxGetter.description();
                impact = MBeanOperationInfo.INFO;
                visibility = 4;
            } else if(jmxSetter != null) {
                description = jmxSetter.description();
                impact = MBeanOperationInfo.ACTION;
                visibility = 4;
            }
            ModelMBeanOperationInfo info = new ModelMBeanOperationInfo(m.getName(),
                                                                       description,
                                                                       extractParameterInfo(m),
                                                                       m.getReturnType()
                                                                        .getName(),
                                                                       impact);
            info.getDescriptor().setField("visibility", Integer.toString(visibility));
            infos.add(info);
        }
    }

    return infos.toArray(new ModelMBeanOperationInfo[infos.size()]);
}
WhitelistFunction.java 文件源码 项目:SamaGamesCore 阅读 19 收藏 0 点赞 0 评论 0
@RemoteMethod(description = "Get the whitelist", impact = ModelMBeanOperationInfo.ACTION)
public ArrayList<UUID> getWhiteList()
{
    return Bukkit.getWhitelistedPlayers().stream().map(OfflinePlayer::getUniqueId).collect(Collectors.toCollection(ArrayList::new));
}
WhitelistFunction.java 文件源码 项目:SamaGamesCore 阅读 20 收藏 0 点赞 0 评论 0
@RemoteMethod(description = "Know if the whitelist is actived", impact = ModelMBeanOperationInfo.INFO)
public boolean isWhiteListActived()
{
    return Bukkit.hasWhitelist();
}
WhitelistFunction.java 文件源码 项目:SamaGamesCore 阅读 18 收藏 0 点赞 0 评论 0
@RemoteMethod(description = "Set if the whitelist is actived", impact = ModelMBeanOperationInfo.ACTION)
public void setWhiteListActived(boolean actived)
{
    Bukkit.setWhitelist(actived);
}
StopFunction.java 文件源码 项目:SamaGamesCore 阅读 21 收藏 0 点赞 0 评论 0
@RemoteMethod(description = "Shutdown a server", impact = ModelMBeanOperationInfo.ACTION)
public void stop()
{
    Bukkit.getServer().shutdown();
}
AnnotationMetadataAssemblerTests.java 文件源码 项目:spring4-understanding 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void testOperationFromInterface() throws Exception {
    ModelMBeanInfo inf = getMBeanInfoFromAssembler();
    ModelMBeanOperationInfo op = inf.getOperation("fromInterface");
    assertNotNull(op);
}
AnnotationMetadataAssemblerTests.java 文件源码 项目:spring4-understanding 阅读 25 收藏 0 点赞 0 评论 0
@Test
public void testOperationOnGetter() throws Exception {
    ModelMBeanInfo inf = getMBeanInfoFromAssembler();
    ModelMBeanOperationInfo op = inf.getOperation("getExpensiveToCalculate");
    assertNotNull(op);
}


问题


面经


文章

微信
公众号

扫码关注公众号