use of javax.management.JMException in project Payara by payara.
the class JmxServiceUrlsResource method getJmxServiceUrl.
@GET
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED })
public ActionReportResult getJmxServiceUrl() {
try {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
JMXServiceURL[] urls = (JMXServiceURL[]) mBeanServer.getAttribute(getBootAMXMBeanObjectName(), "JMXServiceURLs");
List<String> jmxUrls = new ArrayList<String>();
for (JMXServiceURL url : urls) {
jmxUrls.add(url.getURLPath());
}
RestActionReporter ar = new RestActionReporter();
ar.setActionDescription("Get JMX Service URLs");
ar.setSuccess();
ar.getExtraProperties().put("jmxServiceUrls", jmxUrls);
return new ActionReportResult(ar);
} catch (final JMException e) {
throw new RuntimeException(e);
}
}
use of javax.management.JMException in project Payara by payara.
the class RuntimeRootImpl method getJMXServiceURLs.
public String[] getJMXServiceURLs() {
try {
final AMXGlassfish amxg = AMXGlassfish.DEFAULT;
final JMXServiceURL[] items = (JMXServiceURL[]) getMBeanServer().getAttribute(amxg.getBootAMXMBeanObjectName(), "JMXServiceURLs");
final String[] urls = new String[items.length];
for (int i = 0; i < items.length; ++i) {
urls[i] = "" + items[i];
}
return urls;
} catch (final JMException e) {
throw new RuntimeException(e);
}
}
use of javax.management.JMException in project Payara by payara.
the class NotificationListenerBase method cleanup.
/**
* Reset everything so that no listening is occuring and
* all lists are empty.
*/
public synchronized void cleanup() {
try {
if (mDelegateListener != null) {
// it's crucial we listen for registration/unregistration events
// so that any patterns are maintained.
getConn().removeNotificationListener(JMXUtil.getMBeanServerDelegateObjectName(), mDelegateListener, null, null);
mDelegateListener = null;
}
for (final ObjectName objectName : mListenees) {
getConn().removeNotificationListener(objectName, this, mFilter, null);
}
} catch (JMException e) {
} catch (IOException e) {
}
mListenees.clear();
}
use of javax.management.JMException in project Payara by payara.
the class BootAMX method bootAMX.
/**
* We need to dynamically load the AMX module. HOW? we can't depend on the amx-impl module.
*
* For now though, assume that a well-known MBean is available through other means via the amx-impl module.
* @return
*/
@Override
public synchronized ObjectName bootAMX() {
if (mDomainRootObjectName == null) {
getLoader();
final ObjectName startupON = AMXStartupServiceMBean.OBJECT_NAME;
if (!mMBeanServer.isRegistered(startupON)) {
JMX_LOGGER.log(Level.FINEST, "Booter.bootAMX(): AMX MBean not yet available: {0}", startupON);
throw new IllegalStateException("AMX MBean not yet available: " + startupON);
}
try {
JMX_LOGGER.log(Level.FINEST, "Booter.bootAMX: invoking loadAMXMBeans() on {0}", startupON);
mDomainRootObjectName = (ObjectName) mMBeanServer.invoke(startupON, "loadAMXMBeans", null, null);
JMX_LOGGER.log(Level.FINEST, "Booter.bootAMX: domainRoot = {0}", mDomainRootObjectName);
} catch (final JMException e) {
JMX_LOGGER.log(Level.SEVERE, null, e);
throw new RuntimeException(e);
}
}
return mDomainRootObjectName;
}
use of javax.management.JMException in project metrics by dropwizard.
the class BufferPoolMetricSet method getMetrics.
@Override
public Map<String, Metric> getMetrics() {
final Map<String, Metric> gauges = new HashMap<>();
for (String pool : POOLS) {
for (int i = 0; i < ATTRIBUTES.length; i++) {
final String attribute = ATTRIBUTES[i];
final String name = NAMES[i];
try {
final ObjectName on = new ObjectName("java.nio:type=BufferPool,name=" + pool);
mBeanServer.getMBeanInfo(on);
gauges.put(name(pool, name), new JmxAttributeGauge(mBeanServer, on, attribute));
} catch (JMException ignored) {
LOGGER.debug("Unable to load buffer pool MBeans, possibly running on Java 6");
}
}
}
return Collections.unmodifiableMap(gauges);
}
Aggregations