本文整理汇总了Java中javax.management.modelmbean.ModelMBean类的典型用法代码示例。如果您正苦于以下问题:Java ModelMBean类的具体用法?Java ModelMBean怎么用?Java ModelMBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelMBean类属于javax.management.modelmbean包,在下文中一共展示了ModelMBean类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerManagedResource
import javax.management.modelmbean.ModelMBean; //导入依赖的package包/类
@Override
public void registerManagedResource(Object managedResource, ObjectName objectName) throws MBeanExportException {
Assert.notNull(managedResource, "Managed resource must not be null");
Assert.notNull(objectName, "ObjectName must not be null");
try {
if (isMBean(managedResource.getClass())) {
doRegister(managedResource, objectName);
}
else {
ModelMBean mbean = createAndConfigureMBean(managedResource, managedResource.getClass().getName());
doRegister(mbean, objectName);
injectNotificationPublisherIfNecessary(managedResource, mbean, objectName);
}
}
catch (JMException ex) {
throw new UnableToRegisterMBeanException(
"Unable to register MBean [" + managedResource + "] with object name [" + objectName + "]", ex);
}
}
示例2: createMBean
import javax.management.modelmbean.ModelMBean; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>Connector</code> object.
*
* @param connector The Connector to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
public static ModelMBean createMBean(Connector connector)
throws Exception {
String mname = createManagedName(connector);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with "+mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ModelMBean mbean = managed.createMBean(connector);
ObjectName oname = createObjectName(domain, connector);
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例3: testHappyPath
import javax.management.modelmbean.ModelMBean; //导入依赖的package包/类
@Test
public void testHappyPath() throws MalformedObjectNameException, JMException {
TestMbean testMbean = new TestMbean();
ModelMBean mbean = defaultManagementMBeanAssembler.assemble(testMbean, new ObjectName("org.flowable.jmx.Mbeans:type=something"));
assertNotNull(mbean);
assertNotNull(mbean.getMBeanInfo());
assertNotNull(mbean.getMBeanInfo().getAttributes());
MBeanAttributeInfo[] attributes = mbean.getMBeanInfo().getAttributes();
assertEquals(2, attributes.length);
assertTrue((attributes[0].getName().equals("TestAttributeString") && attributes[1].getName().equals("TestAttributeBoolean") || (attributes[1].getName().equals("TestAttributeString") && attributes[0]
.getName().equals("TestAttributeBoolean"))));
assertNotNull(mbean.getMBeanInfo().getOperations());
MBeanOperationInfo[] operations = mbean.getMBeanInfo().getOperations();
assertNotNull(operations);
assertEquals(3, operations.length);
}
示例4: main
import javax.management.modelmbean.ModelMBean; //导入依赖的package包/类
public static void main(String[] args)
{
RemoteServiceStat rss = new RemoteServiceStat();
ModelMBean mmb = MBeanHelper.createModelMBean(rss);
MBeanAttributeInfo[] attrs= mmb.getMBeanInfo().getAttributes();
for(MBeanAttributeInfo inf:attrs)
{
String getMethodName = (String) inf.getDescriptor().getFieldValue("getMethod");
try
{
Method m= rss.getClass().getMethod(getMethodName);
AggregateAttribute aa= m.getAnnotation(AggregateAttribute.class);
System.out.println(inf.getName()+" "+aa.value()+" "+inf.getType() );
}
catch (NoSuchMethodException | SecurityException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
示例5: registerManagedResource
import javax.management.modelmbean.ModelMBean; //导入依赖的package包/类
public void registerManagedResource(Object managedResource, ObjectName objectName) throws MBeanExportException {
Assert.notNull(managedResource, "Managed resource must not be null");
Assert.notNull(objectName, "ObjectName must not be null");
try {
if (isMBean(managedResource.getClass())) {
doRegister(managedResource, objectName);
}
else {
ModelMBean mbean = createAndConfigureMBean(managedResource, managedResource.getClass().getName());
doRegister(mbean, objectName);
injectNotificationPublisherIfNecessary(managedResource, mbean, objectName);
}
}
catch (JMException ex) {
throw new UnableToRegisterMBeanException(
"Unable to register MBean [" + managedResource + "] with object name [" + objectName + "]", ex);
}
}