use of javax.management.MBeanNotificationInfo in project aries by apache.
the class ServiceState method getNotificationInfo.
/**
* @see javax.management.NotificationBroadcasterSupport#getNotificationInfo()
*/
public MBeanNotificationInfo[] getNotificationInfo() {
MBeanNotificationInfo eventInfo = new MBeanNotificationInfo(new String[] { SERVICE_EVENT }, Notification.class.getName(), "A ServiceEvent issued from the Framework describing a service lifecycle change");
MBeanNotificationInfo attributeChangeInfo = new MBeanNotificationInfo(new String[] { AttributeChangeNotification.ATTRIBUTE_CHANGE }, AttributeChangeNotification.class.getName(), "An attribute of this MBean has changed");
return new MBeanNotificationInfo[] { eventInfo, attributeChangeInfo };
}
use of javax.management.MBeanNotificationInfo in project geode by apache.
the class MBeanProxyInvocationHandler method invokeBroadcasterMethod.
/**
* The call will delegate to Managed Node for NotificationHub to register a local listener to
* listen for notification from the MBean
*
* Moreover it will also add the client to local listener list by adding to the contained emitter.
*
* @param proxy the proxy object
* @param method method to be invoked
* @param args method arguments
* @return result value if any
* @throws Exception
*/
private Object invokeBroadcasterMethod(Object proxy, Method method, Object[] args) throws Throwable {
final String methodName = method.getName();
final int nargs = (args == null) ? 0 : args.length;
final Class[] paramTypes = method.getParameterTypes();
final String[] signature = new String[paramTypes.length];
if (methodName.equals("addNotificationListener")) {
if (nargs != 3) {
final String msg = "Bad arg count to addNotificationListener: " + nargs;
throw new IllegalArgumentException(msg);
}
/*
* Other inconsistencies will produce ClassCastException below.
*/
NotificationListener listener = (NotificationListener) args[0];
NotificationFilter filter = (NotificationFilter) args[1];
Object handback = args[2];
emitter.addNotificationListener(listener, filter, handback);
delegateToFucntionService(objectName, methodName, null, signature);
return null;
} else if (methodName.equals("removeNotificationListener")) {
/*
* NullPointerException if method with no args, but that shouldn't happen because removeNL
* does have args.
*/
NotificationListener listener = (NotificationListener) args[0];
switch(nargs) {
case 1:
emitter.removeNotificationListener(listener);
/**
* No need to send listener and filter details to other members. We only need to send a
* message saying remove the listner registered for this object on your side. Fixes Bug[
* #47075 ]
*/
delegateToFucntionService(objectName, methodName, null, signature);
return null;
case 3:
NotificationFilter filter = (NotificationFilter) args[1];
Object handback = args[2];
emitter.removeNotificationListener(listener, filter, handback);
delegateToFucntionService(objectName, methodName, null, signature);
return null;
default:
final String msg = "Bad arg count to removeNotificationListener: " + nargs;
throw new IllegalArgumentException(msg);
}
} else if (methodName.equals("getNotificationInfo")) {
if (args != null) {
throw new IllegalArgumentException("getNotificationInfo has " + "args");
}
if (!MBeanJMXAdapter.mbeanServer.isRegistered(objectName)) {
return new MBeanNotificationInfo[0];
}
/**
* MBean info is delegated to function service as intention is to get the info of the actual
* mbean rather than the proxy
*/
Object obj = delegateToFucntionService(objectName, methodName, args, signature);
if (obj instanceof String) {
return new MBeanNotificationInfo[0];
}
MBeanInfo info = (MBeanInfo) obj;
return info.getNotifications();
} else {
throw new IllegalArgumentException("Bad method name: " + methodName);
}
}
use of javax.management.MBeanNotificationInfo in project karaf by apache.
the class FeaturesServiceMBeanImpl method getBroadcastInfo.
private static MBeanNotificationInfo[] getBroadcastInfo() {
String type = Notification.class.getCanonicalName();
MBeanNotificationInfo info1 = new MBeanNotificationInfo(new String[] { FEATURE_EVENT_EVENT_TYPE }, type, "Some features notification");
MBeanNotificationInfo info2 = new MBeanNotificationInfo(new String[] { REPOSITORY_EVENT_EVENT_TYPE }, type, "Some repository notification");
return new MBeanNotificationInfo[] { info1, info2 };
}
use of javax.management.MBeanNotificationInfo in project jdk8u_jdk by JetBrains.
the class SnmpMibTable method getNotificationInfo.
/**
* Return a <CODE>NotificationInfo</CODE> object containing the
* notification class and the notification type sent by the
* <CODE>SnmpMibTable</CODE>.
*/
@Override
public MBeanNotificationInfo[] getNotificationInfo() {
String[] types = { SnmpTableEntryNotification.SNMP_ENTRY_ADDED, SnmpTableEntryNotification.SNMP_ENTRY_REMOVED };
MBeanNotificationInfo[] notifsInfo = { new MBeanNotificationInfo(types, "com.sun.jmx.snmp.agent.SnmpTableEntryNotification", "Notifications sent by the SnmpMibTable") };
return notifsInfo;
}
use of javax.management.MBeanNotificationInfo in project jdk8u_jdk by JetBrains.
the class ModelMBeanInfoSupport method getDescriptors.
public Descriptor[] getDescriptors(String inDescriptorType) throws MBeanException, RuntimeOperationsException {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, ModelMBeanInfoSupport.class.getName(), "getDescriptors(String)", "Entry");
}
if ((inDescriptorType == null) || (inDescriptorType.equals(""))) {
inDescriptorType = "all";
}
// if no descriptors of that type, will return empty array
//
final Descriptor[] retList;
if (inDescriptorType.equalsIgnoreCase(MMB)) {
retList = new Descriptor[] { modelMBeanDescriptor };
} else if (inDescriptorType.equalsIgnoreCase(ATTR)) {
final MBeanAttributeInfo[] attrList = modelMBeanAttributes;
int numAttrs = 0;
if (attrList != null)
numAttrs = attrList.length;
retList = new Descriptor[numAttrs];
for (int i = 0; i < numAttrs; i++) {
retList[i] = (((ModelMBeanAttributeInfo) attrList[i]).getDescriptor());
}
} else if (inDescriptorType.equalsIgnoreCase(OPER)) {
final MBeanOperationInfo[] operList = modelMBeanOperations;
int numOpers = 0;
if (operList != null)
numOpers = operList.length;
retList = new Descriptor[numOpers];
for (int i = 0; i < numOpers; i++) {
retList[i] = (((ModelMBeanOperationInfo) operList[i]).getDescriptor());
}
} else if (inDescriptorType.equalsIgnoreCase(CONS)) {
final MBeanConstructorInfo[] consList = modelMBeanConstructors;
int numCons = 0;
if (consList != null)
numCons = consList.length;
retList = new Descriptor[numCons];
for (int i = 0; i < numCons; i++) {
retList[i] = (((ModelMBeanConstructorInfo) consList[i]).getDescriptor());
}
} else if (inDescriptorType.equalsIgnoreCase(NOTF)) {
final MBeanNotificationInfo[] notifList = modelMBeanNotifications;
int numNotifs = 0;
if (notifList != null)
numNotifs = notifList.length;
retList = new Descriptor[numNotifs];
for (int i = 0; i < numNotifs; i++) {
retList[i] = (((ModelMBeanNotificationInfo) notifList[i]).getDescriptor());
}
} else if (inDescriptorType.equalsIgnoreCase(ALL)) {
final MBeanAttributeInfo[] attrList = modelMBeanAttributes;
int numAttrs = 0;
if (attrList != null)
numAttrs = attrList.length;
final MBeanOperationInfo[] operList = modelMBeanOperations;
int numOpers = 0;
if (operList != null)
numOpers = operList.length;
final MBeanConstructorInfo[] consList = modelMBeanConstructors;
int numCons = 0;
if (consList != null)
numCons = consList.length;
final MBeanNotificationInfo[] notifList = modelMBeanNotifications;
int numNotifs = 0;
if (notifList != null)
numNotifs = notifList.length;
int count = numAttrs + numCons + numOpers + numNotifs + 1;
retList = new Descriptor[count];
retList[count - 1] = modelMBeanDescriptor;
int j = 0;
for (int i = 0; i < numAttrs; i++) {
retList[j] = (((ModelMBeanAttributeInfo) attrList[i]).getDescriptor());
j++;
}
for (int i = 0; i < numCons; i++) {
retList[j] = (((ModelMBeanConstructorInfo) consList[i]).getDescriptor());
j++;
}
for (int i = 0; i < numOpers; i++) {
retList[j] = (((ModelMBeanOperationInfo) operList[i]).getDescriptor());
j++;
}
for (int i = 0; i < numNotifs; i++) {
retList[j] = (((ModelMBeanNotificationInfo) notifList[i]).getDescriptor());
j++;
}
} else {
final IllegalArgumentException iae = new IllegalArgumentException("Descriptor Type is invalid");
final String msg = "Exception occurred trying to find" + " the descriptors of the MBean";
throw new RuntimeOperationsException(iae, msg);
}
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, ModelMBeanInfoSupport.class.getName(), "getDescriptors(String)", "Exit");
}
return retList;
}
Aggregations