本文整理了Java中javax.management.ObjectName.toString()
方法的一些代码示例,展示了ObjectName.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectName.toString()
方法的具体详情如下:
包路径:javax.management.ObjectName
类名称:ObjectName
方法名:toString
暂无
代码示例来源:origin: mpusher/mpush
public HotSpotDiagnosticMXBean run() throws Exception {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> s = server.queryNames(new ObjectName(HOT_SPOT_BEAN_NAME), null);
Iterator<ObjectName> itr = s.iterator();
if (itr.hasNext()) {
ObjectName name = itr.next();
HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(server,
name.toString(), HotSpotDiagnosticMXBean.class);
return bean;
} else {
return null;
}
}
});
代码示例来源:origin: apache/activemq
public static ObjectName createNetworkInBoundDestinationObjectName(ObjectName networkName, ActiveMQDestination destination) throws MalformedObjectNameException {
String str = networkName.toString();
str += ",direction=inbound" + createDestinationProperties(destination);
return new ObjectName(str);
}
代码示例来源:origin: apache/activemq
public static ObjectName createNetworkOutBoundDestinationObjectName(ObjectName networkName, ActiveMQDestination destination) throws MalformedObjectNameException {
String str = networkName.toString();
str += ",direction=outbound" + createDestinationProperties(destination);
return new ObjectName(str);
}
代码示例来源:origin: apache/activemq
public static ObjectName createVirtualDestinationSelectorCacheName(ObjectName brokerObjectName, String type, String name) throws MalformedObjectNameException {
String objectNameStr = brokerObjectName.toString();
objectNameStr += ",service=" + type + ",virtualDestinationSelectoCache="+ JMXSupport.encodeObjectNamePart(name);
ObjectName objectName = new ObjectName(objectNameStr);
return objectName;
}
代码示例来源:origin: btraceio/btrace
@Override
public HotSpotDiagnosticMXBean run() throws Exception {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> s = server.queryNames(new ObjectName(HOTSPOT_BEAN_NAME), null);
Iterator<ObjectName> itr = s.iterator();
if (itr.hasNext()) {
ObjectName name = itr.next();
HotSpotDiagnosticMXBean bean =
ManagementFactory.newPlatformMXBeanProxy(server,
name.toString(), HotSpotDiagnosticMXBean.class);
return bean;
} else {
return null;
}
}
});
代码示例来源:origin: apache/activemq
public static ObjectName createConnectionViewByType(ObjectName connectorName, String type, String name) throws MalformedObjectNameException {
String objectNameStr = connectorName.toString();
objectNameStr += ",connectionViewType=" + JMXSupport.encodeObjectNamePart(type);
objectNameStr += ",connectionName="+ JMXSupport.encodeObjectNamePart(name);
return new ObjectName(objectNameStr);
}
代码示例来源:origin: apache/zookeeper
public static void dump() throws IOException {
LOG.info("JMXEnv.dump() follows");
Set<ObjectName> beans;
try {
beans = conn().queryNames(
new ObjectName(CommonNames.DOMAIN + ":*"), null);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
}
for (ObjectName bean : beans) {
LOG.info("bean:" + bean.toString());
}
}
代码示例来源:origin: apache/zookeeper
public static List<ObjectName> getServerBeans() throws IOException {
ArrayList<ObjectName> serverBeans = new ArrayList<>();
Set<ObjectName> beans;
try {
beans = conn().queryNames(
new ObjectName(CommonNames.DOMAIN + ":*"), null);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
}
for (ObjectName bean : beans) {
String name = bean.toString();
LOG.info("bean:" + name);
for (Pattern pattern : beanPatterns) {
if (pattern.matcher(name).find()) {
serverBeans.add(bean);
}
}
}
return serverBeans;
}
代码示例来源:origin: apache/zookeeper
new ObjectName(CommonNames.DOMAIN + ":*"), null);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
for (String name : expectedNames) {
for (ObjectName bean : beans) {
if (bean.toString().contains(name)) {
LOG.info("didntexpect:" + name);
foundUnexpected = true;
unexpectedName = name + " " + bean.toString();
break;
LOG.info("List of all beans follows:");
for (ObjectName bean : beans) {
LOG.info("bean:" + bean.toString());
代码示例来源:origin: apache/zookeeper
new ObjectName(CommonNames.DOMAIN + ":*"), null);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
LOG.info("expect:" + name);
for (ObjectName bean : beans) {
if (bean.toString().contains(name)) {
LOG.info("found:" + name + " " + bean);
found.add(bean);
代码示例来源:origin: apache/zookeeper
new ObjectName(CommonNames.DOMAIN + ":*"), null);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
for (ObjectName bean : beans) {
if (compare(bean.toString(), name)) {
LOG.info("found:" + name + " " + bean);
found.add(bean);
代码示例来源:origin: apache/zookeeper
new ObjectName(CommonNames.DOMAIN + ":*"), null);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
for (ObjectName bean : beans) {
if (bean.toString().equals(expectedName)) {
LOG.info("found:{} {}", new Object[] { expectedName, bean });
return conn().getAttribute(bean, expectedAttribute);
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testRegisterIgnoreExisting() throws Exception {
ObjectName objectName = ObjectNameManager.getInstance(OBJECT_NAME);
Person preRegistered = new Person();
preRegistered.setName("Rob Harrop");
server.registerMBean(preRegistered, objectName);
Person springRegistered = new Person();
springRegistered.setName("Sally Greenwood");
String objectName2 = "spring:test=equalBean";
Map<String, Object> beans = new HashMap<>();
beans.put(objectName.toString(), springRegistered);
beans.put(objectName2, springRegistered);
MBeanExporter exporter = new MBeanExporter();
exporter.setServer(server);
exporter.setBeans(beans);
exporter.setRegistrationPolicy(RegistrationPolicy.IGNORE_EXISTING);
start(exporter);
ObjectInstance instance = server.getObjectInstance(objectName);
assertNotNull(instance);
ObjectInstance instance2 = server.getObjectInstance(new ObjectName(objectName2));
assertNotNull(instance2);
// should still be the first bean with name Rob Harrop
assertEquals("Rob Harrop", server.getAttribute(objectName, "Name"));
}
代码示例来源:origin: apache/geode
ObjectName objectName = new ObjectName(name.trim());
return persister;
} else {
throw new InstanceNotFoundException(objectName.toString());
代码示例来源:origin: hector-client/hector
public void unregisterMonitor(String name, String monitorType)
throws MalformedObjectNameException, InstanceAlreadyExistsException,
MBeanRegistrationException, NotCompliantMBeanException {
String monitorName = generateMonitorName(name, monitorType);
log.info("Unregistering JMX {}", monitorName);
ObjectName oName = new ObjectName(monitorName);
// Check if the monitor is already registered
if (!mbs.isRegistered(oName)) {
log.info("Monitor is not registered: {}", oName);
return;
}
try
{
mbs.unregisterMBean(oName);
}
catch(InstanceNotFoundException e)
{
log.warn("Failed to unregister monitor: {}" + oName.toString(), e);
}
}
代码示例来源:origin: org.apache.commons/commons-pool2
@After
public void tearDown() throws Exception {
final String poolName = pool.getJmxName().toString();
pool.clear();
pool.close();
pool = null;
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
final Set<ObjectName> result = mbs.queryNames(new ObjectName(
"org.apache.commoms.pool2:type=GenericObjectPool,*"), null);
// There should be no registered pools at this point
final int registeredPoolCount = result.size();
final StringBuilder msg = new StringBuilder("Current pool is: ");
msg.append(poolName);
msg.append(" Still open pools are: ");
for (final ObjectName name : result) {
// Clean these up ready for the next test
msg.append(name.toString());
msg.append(" created via\n");
msg.append(mbs.getAttribute(name, "CreationStackTrace"));
msg.append('\n');
mbs.unregisterMBean(name);
}
Assert.assertEquals(msg.toString(), 0, registeredPoolCount);
}
代码示例来源:origin: org.apache.commons/commons-pool2
@After
public void tearDown() throws Exception {
final String poolName = genericObjectPool.getJmxName().toString();
genericObjectPool.clear();
genericObjectPool.close();
genericObjectPool = null;
simpleFactory = null;
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
final Set<ObjectName> result = mbs.queryNames(new ObjectName(
"org.apache.commoms.pool2:type=GenericObjectPool,*"), null);
// There should be no registered pools at this point
final int registeredPoolCount = result.size();
final StringBuilder msg = new StringBuilder("Current pool is: ");
msg.append(poolName);
msg.append(" Still open pools are: ");
for (final ObjectName name : result) {
// Clean these up ready for the next test
msg.append(name.toString());
msg.append(" created via\n");
msg.append(mbs.getAttribute(name, "CreationStackTrace"));
msg.append('\n');
mbs.unregisterMBean(name);
}
Assert.assertEquals(msg.toString(), 0, registeredPoolCount);
}
代码示例来源:origin: org.apache.commons/commons-pool2
@Override
@After
public void tearDown() throws Exception {
super.tearDown();
final String poolName = gkoPool.getJmxName().toString();
gkoPool.clear();
gkoPool.close();
gkoPool = null;
simpleFactory = null;
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
final Set<ObjectName> result = mbs.queryNames(new ObjectName(
"org.apache.commoms.pool2:type=GenericKeyedObjectPool,*"),
null);
// There should be no registered pools at this point
final int registeredPoolCount = result.size();
final StringBuilder msg = new StringBuilder("Current pool is: ");
msg.append(poolName);
msg.append(" Still open pools are: ");
for (final ObjectName name : result) {
// Clean these up ready for the next test
msg.append(name.toString());
msg.append(" created via\n");
msg.append(mbs.getAttribute(name, "CreationStackTrace"));
msg.append('\n');
mbs.unregisterMBean(name);
}
Assert.assertEquals(msg.toString(), 0, registeredPoolCount);
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void testCustomMBeanRegistration() throws Exception {
Set<ObjectName> names = server.queryNames(new ObjectName("custom:type=MessageChannel,*"), null);
assertEquals(1, names.size());
ObjectName name = names.iterator().next();
assertEquals("custom:type=MessageChannel,name=foo", name.toString());
MBeanInfo mBeanInfo = server.getMBeanInfo(name);
assertEquals("custom channel", mBeanInfo.getDescription());
names = server.queryNames(new ObjectName("custom:type=MessageHandler,*"), null);
assertEquals(1, names.size());
name = names.iterator().next();
assertEquals("custom:type=MessageHandler,name=foo", name.toString());
mBeanInfo = server.getMBeanInfo(name);
assertEquals("custom handler", mBeanInfo.getDescription());
assertEquals("10", descriptor.getFieldValue("persistPeriod"));
assertEquals("Never", descriptor.getFieldValue("persistPolicy"));
names = server.queryNames(new ObjectName("custom:type=MessageSource,*"), null);
assertEquals(1, names.size());
name = names.iterator().next();
assertEquals("custom:type=MessageSource,name=foo", name.toString());
name = names.iterator().next();
assertEquals("custom:type=MessageRouter,name=foo", name.toString());
Iterator<ObjectName> iterator = names.iterator();
name = iterator.next();
assertEquals("test.custom:type=MessageHandler,name=standardHandler,bean=handler", name.toString());
name = iterator.next();
assertEquals("test.custom:type=MessageHandler,name=errorLogger,bean=internal", name.toString());
代码示例来源:origin: org.apache.tomcat/tomcat-jdbc
private static ObjectName getObjectName(ObjectName base, String keyprop)
throws MalformedObjectNameException {
if (base == null) return null;
StringBuilder OnameStr = new StringBuilder(base.toString());
if (keyprop != null) OnameStr.append(keyprop);
ObjectName oname = new ObjectName(OnameStr.toString());
return oname;
}
}
内容来源于网络,如有侵权,请联系作者删除!