use of javax.management.MBeanNotificationInfo in project jdk8u_jdk by JetBrains.
the class MBeanIntrospector method getMBeanInfo.
/**
* Return the MBeanInfo for the given resource, based on the given
* per-interface data.
*/
final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) {
MBeanInfo mbi = getClassMBeanInfo(resource.getClass(), perInterface);
MBeanNotificationInfo[] notifs = findNotifications(resource);
if (notifs == null || notifs.length == 0)
return mbi;
else {
return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), mbi.getAttributes(), mbi.getConstructors(), mbi.getOperations(), notifs, mbi.getDescriptor());
}
}
use of javax.management.MBeanNotificationInfo in project tomcat by apache.
the class ManagedBean method getMBeanInfo.
/**
* Create and return a <code>ModelMBeanInfo</code> object that
* describes this entire managed bean.
* @return the MBean info
*/
MBeanInfo getMBeanInfo() {
// Return our cached information (if any)
mBeanInfoLock.readLock().lock();
try {
if (info != null) {
return info;
}
} finally {
mBeanInfoLock.readLock().unlock();
}
mBeanInfoLock.writeLock().lock();
try {
if (info == null) {
// Create subordinate information descriptors as required
AttributeInfo[] attrs = getAttributes();
MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[attrs.length];
for (int i = 0; i < attrs.length; i++) attributes[i] = attrs[i].createAttributeInfo();
OperationInfo[] opers = getOperations();
MBeanOperationInfo[] operations = new MBeanOperationInfo[opers.length];
for (int i = 0; i < opers.length; i++) operations[i] = opers[i].createOperationInfo();
NotificationInfo[] notifs = getNotifications();
MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[notifs.length];
for (int i = 0; i < notifs.length; i++) notifications[i] = notifs[i].createNotificationInfo();
// Construct and return a new ModelMBeanInfo object
info = new MBeanInfo(getClassName(), getDescription(), attributes, new MBeanConstructorInfo[] {}, operations, notifications);
}
return info;
} finally {
mBeanInfoLock.writeLock().unlock();
}
}
use of javax.management.MBeanNotificationInfo in project tomcat by apache.
the class ConnectionPool method getDefaultNotificationInfo.
public static MBeanNotificationInfo[] getDefaultNotificationInfo() {
String[] types = new String[] { NOTIFY_INIT, NOTIFY_CONNECT, NOTIFY_ABANDON, SLOW_QUERY_NOTIFICATION, FAILED_QUERY_NOTIFICATION, SUSPECT_ABANDONED_NOTIFICATION, POOL_EMPTY, SUSPECT_RETURNED_NOTIFICATION };
String name = Notification.class.getName();
String description = "A connection pool error condition was met.";
MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description);
return new MBeanNotificationInfo[] { info };
}
use of javax.management.MBeanNotificationInfo in project jetty.project by eclipse.
the class ObjectMBean method getMBeanInfo.
public MBeanInfo getMBeanInfo() {
try {
if (_info == null) {
// Start with blank lazy lists attributes etc.
String desc = null;
List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
List<MBeanConstructorInfo> constructors = new ArrayList<MBeanConstructorInfo>();
List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>();
List<MBeanNotificationInfo> notifications = new ArrayList<MBeanNotificationInfo>();
// Find list of classes that can influence the mbean
Class<?> o_class = _managed.getClass();
List<Class<?>> influences = new ArrayList<Class<?>>();
// always add MBean itself
influences.add(this.getClass());
influences = findInfluences(influences, _managed.getClass());
if (LOG.isDebugEnabled())
LOG.debug("Influence Count: {}", influences.size());
// Process Type Annotations
ManagedObject primary = o_class.getAnnotation(ManagedObject.class);
if (primary != null) {
desc = primary.value();
} else {
if (LOG.isDebugEnabled())
LOG.debug("No @ManagedObject declared on {}", _managed.getClass());
}
// For each influence
for (int i = 0; i < influences.size(); i++) {
Class<?> oClass = influences.get(i);
ManagedObject typeAnnotation = oClass.getAnnotation(ManagedObject.class);
if (LOG.isDebugEnabled())
LOG.debug("Influenced by: " + oClass.getCanonicalName());
if (typeAnnotation == null) {
if (LOG.isDebugEnabled())
LOG.debug("Annotations not found for: {}", oClass.getCanonicalName());
continue;
}
for (Method method : oClass.getDeclaredMethods()) {
ManagedAttribute methodAttributeAnnotation = method.getAnnotation(ManagedAttribute.class);
if (methodAttributeAnnotation != null) {
// TODO sort out how a proper name could get here, its a method name as an attribute at this point.
if (LOG.isDebugEnabled())
LOG.debug("Attribute Annotation found for: {}", method.getName());
MBeanAttributeInfo mai = defineAttribute(method, methodAttributeAnnotation);
if (mai != null) {
attributes.add(mai);
}
}
ManagedOperation methodOperationAnnotation = method.getAnnotation(ManagedOperation.class);
if (methodOperationAnnotation != null) {
if (LOG.isDebugEnabled())
LOG.debug("Method Annotation found for: {}", method.getName());
MBeanOperationInfo oi = defineOperation(method, methodOperationAnnotation);
if (oi != null) {
operations.add(oi);
}
}
}
}
_info = new MBeanInfo(o_class.getName(), desc, (MBeanAttributeInfo[]) attributes.toArray(new MBeanAttributeInfo[attributes.size()]), (MBeanConstructorInfo[]) constructors.toArray(new MBeanConstructorInfo[constructors.size()]), (MBeanOperationInfo[]) operations.toArray(new MBeanOperationInfo[operations.size()]), (MBeanNotificationInfo[]) notifications.toArray(new MBeanNotificationInfo[notifications.size()]));
}
} catch (RuntimeException e) {
LOG.warn(e);
throw e;
}
return _info;
}
use of javax.management.MBeanNotificationInfo in project camel by apache.
the class ManagedEventNotifier method getNotificationInfo.
public MBeanNotificationInfo[] getNotificationInfo() {
// all the class names in the event package
String[] names = { "CamelContextStartedEvent", "CamelContextStartingEvent", "CamelContextStartupFailureEvent", "CamelContextStopFailureEvent", "CamelContextStoppedEvent", "CamelContextStoppingEvent", "CamelContextSuspendingEvent", "CamelContextSuspendedEvent", "CamelContextResumingEvent", "CamelContextResumedEvent", "CamelContextResumeFailureEvent", "ExchangeCompletedEvent", "ExchangeCreatedEvent", "ExchangeFailedEvent", "ExchangeFailureHandledEvent", "ExchangeRedeliveryEvents", "ExchangeSendingEvent", "ExchangeSentEvent", "RouteStartedEvent", "RouteStoppedEvent", "ServiceStartupFailureEvent", "ServiceStopFailureEvent" };
List<MBeanNotificationInfo> infos = new ArrayList<MBeanNotificationInfo>();
for (String name : names) {
MBeanNotificationInfo info = new MBeanNotificationInfo(new String[] { "org.apache.camel.management.event" }, "org.apache.camel.management.event." + name, "The event " + name + " occurred");
infos.add(info);
}
return infos.toArray(new MBeanNotificationInfo[infos.size()]);
}
Aggregations