本文整理汇总了Java中javax.management.modelmbean.ModelMBeanOperationInfo类的典型用法代码示例。如果您正苦于以下问题:Java ModelMBeanOperationInfo类的具体用法?Java ModelMBeanOperationInfo怎么用?Java ModelMBeanOperationInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelMBeanOperationInfo类属于javax.management.modelmbean包,在下文中一共展示了ModelMBeanOperationInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tps
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
@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;
}
示例2: testAttributeHasCorrespondingOperations
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
@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"));
}
示例3: getMBeanInfo
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
@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);
}
}
示例4: testNotPresent
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
/**
* 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();
}
示例5: 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();
}
示例6: buildGetterModelMBeanOperationInfo
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
/**
* 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);
}
示例7: createModelMBeanOperationInfo
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
/**
* 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);
}
}
示例8: addPlayer
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
@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");
}
示例9: removePlayer
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
@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");
}
示例10: testOperationParameterMetadata
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
@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());
}
示例11: testMetricDescription
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
@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());
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: constractModelMBeanInfoSupport
import javax.management.modelmbean.ModelMBeanOperationInfo; //导入依赖的package包/类
/**
* 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;
}
示例15: 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();
}