use of javax.management.MalformedObjectNameException in project com.revolsys.open by revolsys.
the class JmxUtil method getMBeanAttributes.
@SuppressWarnings("unchecked")
public static Map<String, MBeanAttributeInfo[]> getMBeanAttributes(final MBeanServerConnection connection, final String objectNameString) {
Map<String, MBeanAttributeInfo[]> attributesMap = null;
Set<ObjectName> objectNames;
try {
objectNames = connection.queryNames(new ObjectName(objectNameString), null);
attributesMap = new TreeMap<>();
for (final ObjectName objectName : objectNames) {
MBeanInfo mBeanInfo;
mBeanInfo = connection.getMBeanInfo(objectName);
final MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes();
attributesMap.put(objectName.getCanonicalName(), attributes);
}
} catch (final InstanceNotFoundException e) {
e.printStackTrace();
} catch (final IntrospectionException e) {
e.printStackTrace();
} catch (final ReflectionException e) {
e.printStackTrace();
} catch (final MalformedObjectNameException e) {
e.printStackTrace();
} catch (final NullPointerException e) {
e.printStackTrace();
} catch (final IOException e) {
e.printStackTrace();
}
return attributesMap;
}
use of javax.management.MalformedObjectNameException in project jmeter-plugins by undera.
the class JMXMonSampler method generateSamples.
public void generateSamples(JMXMonSampleGenerator collector) {
try {
if (hasFailed && !canRetry) {
return;
}
// Construct the fully qualified name of the bean.
ObjectName beanName = new ObjectName(objectName);
MBeanServerConnection activeRemote = null;
if (remote == null) {
activeRemote = pool.getConnection(url.getStringValue(), connectionAttributes);
if (activeRemote == null) {
hasFailed = true;
}
} else {
activeRemote = remote;
}
final double val;
if (activeRemote != null) {
Object o = activeRemote.getAttribute(beanName, attribute);
if (o instanceof CompositeDataSupport) {
if (key == null || "".equals(key)) {
log.error("Got composite object from JMX, but no key specified ");
return;
}
CompositeDataSupport cds = (CompositeDataSupport) o;
// log.info("CDS: " + cds.toString());
val = Double.parseDouble(cds.get(key).toString());
} else {
if (key != null && !key.equals("")) {
log.error("key specified, but didnt get composite object from JMX. Will continue anyway.");
}
val = Double.parseDouble(o.toString());
}
} else {
val = 0;
}
if (sampleDeltaValue) {
if (!Double.isNaN(oldValue)) {
collector.generateSample(val - oldValue, metricName);
}
oldValue = val;
} else {
collector.generateSample(val, metricName);
}
} catch (MalformedURLException ex) {
log.error(ex.getMessage());
} catch (ConnectException ex) {
log.warn("Connection lost", ex);
pool.notifyConnectionDirty(url.getStringValue());
if (sampleDeltaValue) {
if (!Double.isNaN(oldValue)) {
collector.generateSample(0 - oldValue, metricName);
}
oldValue = 0;
} else {
collector.generateSample(0, metricName);
}
} catch (IOException ex) {
log.error(ex.getMessage());
} catch (ReflectionException ex) {
log.error(ex.getMessage());
} catch (MalformedObjectNameException ex) {
log.error(ex.getMessage());
} catch (NullPointerException ex) {
log.error(ex.getMessage());
} catch (MBeanException ex) {
log.error(ex.getMessage());
} catch (AttributeNotFoundException ex) {
log.error(ex.getMessage());
} catch (InstanceNotFoundException ex) {
log.error(ex.getMessage());
}
}
use of javax.management.MalformedObjectNameException in project jspwiki by apache.
the class DefaultAdminBeanManager method actionPerformed.
/* (non-Javadoc)
* @see org.apache.wiki.ui.admin.AdminBeanManager#actionPerformed(org.apache.wiki.event.WikiEvent)
*/
@Override
public void actionPerformed(WikiEvent event) {
if (event instanceof WikiEngineEvent) {
if (((WikiEngineEvent) event).getType() == WikiEngineEvent.SHUTDOWN) {
for (Iterator<AdminBean> i = m_allBeans.iterator(); i.hasNext(); ) {
try {
AdminBean ab = i.next();
ObjectName on = getObjectName(ab);
if (m_mbeanServer.isRegistered(on)) {
m_mbeanServer.unregisterMBean(on);
log.info("Unregistered AdminBean " + ab.getTitle());
}
} catch (MalformedObjectNameException e) {
log.error("Malformed object name when unregistering", e);
} catch (InstanceNotFoundException e) {
log.error("Object was registered; yet claims that it's not there", e);
} catch (MBeanRegistrationException e) {
log.error("Registration exception while unregistering", e);
}
}
}
}
}
use of javax.management.MalformedObjectNameException in project jspwiki by apache.
the class DefaultAdminBeanManager method registerAdminBean.
/**
* Register an AdminBean. If the AdminBean is also a JMX MBean, it also gets registered to the MBeanServer
* we've found.
*
* @param ab AdminBean to register.
*/
private void registerAdminBean(AdminBean ab) {
try {
if (ab instanceof DynamicMBean && m_mbeanServer != null) {
ObjectName name = getObjectName(ab);
if (!m_mbeanServer.isRegistered(name)) {
m_mbeanServer.registerMBean(ab, name);
}
}
m_allBeans.add(ab);
log.info("Registered new admin bean " + ab.getTitle());
} catch (InstanceAlreadyExistsException e) {
log.error("Admin bean already registered to JMX", e);
} catch (MBeanRegistrationException e) {
log.error("Admin bean cannot be registered to JMX", e);
} catch (NotCompliantMBeanException e) {
log.error("Your admin bean is not very good", e);
} catch (MalformedObjectNameException e) {
log.error("Your admin bean name is not very good", e);
} catch (NullPointerException e) {
log.error("Evil NPE occurred", e);
}
}
use of javax.management.MalformedObjectNameException in project alliance by codice.
the class SourcesToQuery method registerMbean.
private void registerMbean() {
try {
objectName = new ObjectName(SourcesToQuery.class.getName() + ":service=stream");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.error("Unable to create Sources to Query Helper MBean.", e);
}
if (mBeanServer == null) {
return;
}
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.info("Registered Sources to Query Helper MBean under object name: {}", objectName);
} catch (InstanceAlreadyExistsException e) {
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
LOGGER.info("Re-registered Sources to Query Helper MBean");
}
} catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
LOGGER.error("Could not register MBean [{}].", objectName.toString(), e);
}
}
Aggregations