throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name");
public Object invoke(String operationName, Object params[], String signature[]) throws MBeanException, ReflectionException { if (operationName == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Operation name cannot be null"), "Cannot invoke a null operation in " + dClassName); } // Check for a recognized operation name and call the corresponding operation if(operationName.equals("addLoggerMBean")) { return addLoggerMBean((String)params[0]); } else { throw new ReflectionException( new NoSuchMethodException(operationName), "Cannot find the operation " + operationName + " in " + dClassName); } }
public MX4JModelMBean(ModelMBeanInfo info) throws MBeanException, RuntimeOperationsException { if (info == null) throw new RuntimeOperationsException(new IllegalArgumentException( "ModelMBeanInfo parameter cannot be null.")); else setModelMBeanInfo(info); }
throw new RuntimeOperationsException( new IllegalArgumentException("Attribute cannot be null"), "Cannot invoke a setter of "+dClassName+" with null attribute"); throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name cannot be null"), "Cannot invoke the setter of "+dClassName+
throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name");
throw new RuntimeOperationsException( new IllegalArgumentException("Attribute cannot be null"), "Cannot invoke a setter of " + dClassName + throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name cannot be null"), "Cannot invoke the setter of "+dClassName+
throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name");
/** * Enables the to get the values of several attributes of the Dynamic MBean. */ public AttributeList getAttributes(String[] attributeNames) { // Check attributeNames is not null to avoid NullPointerException later on if (attributeNames == null) { throw new RuntimeOperationsException( new IllegalArgumentException("attributeNames[] cannot be null"), "Cannot invoke a getter of " + dClassName); } AttributeList resultList = new AttributeList(); // if attributeNames is empty, return an empty result list if (attributeNames.length == 0) return resultList; // build the result attribute list for (int i=0 ; i<attributeNames.length ; i++){ try { Object value = getAttribute((String) attributeNames[i]); resultList.add(new Attribute(attributeNames[i],value)); } catch (JMException e) { e.printStackTrace(); } catch (RuntimeException e) { e.printStackTrace(); } } return(resultList); }
@Override public void sendAttributeChangeNotification(Attribute oldAttribute, Attribute newAttribute) throws MBeanException, RuntimeOperationsException { if (oldAttribute == null || newAttribute == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute cannot be null.")); if (!oldAttribute.getName().equals(newAttribute.getName())) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute names cannot be different.")); // TODO: the source must be the object name of the MBean if the listener was registered through // MBeanServer Object oldValue = oldAttribute.getValue(); AttributeChangeNotification n = new AttributeChangeNotification(this, 1, System.currentTimeMillis(), "Attribute value changed", oldAttribute.getName(), oldValue == null ? null : oldValue.getClass().getName(), oldValue, newAttribute.getValue()); sendAttributeChangeNotification(n); }
throw new RuntimeOperationsException( new IllegalArgumentException("Attribute cannot be null"), "Cannot invoke a setter of " + dClassName + throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name cannot be null"), "Cannot invoke the setter of "+dClassName+
throw new RuntimeOperationsException( new IllegalArgumentException("Attribute cannot be null"), "Cannot invoke a setter of " + dClassName + throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name cannot be null"), "Cannot invoke the setter of "+dClassName+
throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name");
@Override public void removeAttributeChangeNotificationListener(NotificationListener listener, String attributeName) throws RuntimeOperationsException, ListenerNotFoundException { try { removeAttributeChangeNotificationListener(listener, attributeName, null); } catch (MBeanException e) { throw new RuntimeOperationsException(new RuntimeException(e.getMessage())); } }
throw new RuntimeOperationsException( new IllegalArgumentException("AttributeList attributes cannot be null"), "Cannot invoke a setter of " + dClassName);
@Override public void setModelMBeanInfo(ModelMBeanInfo modelMBeanInfo) throws MBeanException, RuntimeOperationsException { if (modelMBeanInfo == null) throw new RuntimeOperationsException(new IllegalArgumentException( "ModelMBeanInfo cannot be null.")); if (!isModelMBeanInfoValid(modelMBeanInfo)) throw new RuntimeOperationsException(new IllegalArgumentException( "ModelMBeanInfo is invalid.")); m_modelMBeanInfo = (ModelMBeanInfo) modelMBeanInfo.clone(); Logger logger = getLogger(); if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("ModelMBeanInfo successfully set to: " + m_modelMBeanInfo); // Only now the MBean can be registered in the MBeanServer m_canBeRegistered = true; }
@Override public AttributeList setAttributes(AttributeList attributes) { if (attributes == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute list cannot be null.")); Logger logger = getLogger(); AttributeList list = new AttributeList(); for (Iterator i = attributes.iterator(); i.hasNext();) { Attribute attribute = (Attribute) i.next(); String name = attribute.getName(); try { setAttribute(attribute); list.add(attribute); } catch (Exception x) { if (logger.isEnabledFor(Logger.TRACE)) logger.trace("setAttribute for attribute " + name + " failed", x); // And go on with the next one } } return list; }
@Override public AttributeList getAttributes(String[] attributes) { if (attributes == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute names cannot be null.")); Logger logger = getLogger(); AttributeList list = new AttributeList(); for (int i = 0; i < attributes.length; ++i) { String attrName = attributes[i]; Attribute attribute = null; try { Object value = getAttribute(attrName); attribute = new Attribute(attrName, value); list.add(attribute); } catch (Exception x) { if (logger.isEnabledFor(Logger.TRACE)) logger.trace("getAttribute for attribute " + attrName + " failed", x); // And go on with the next attribute } } return list; }
@Override public void setManagedResource(Object resource, String resourceType) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException { if (resource == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Managed resource cannot be null.")); if (!isResourceTypeSupported(resourceType)) throw new InvalidTargetObjectTypeException(resourceType); Logger logger = getLogger(); if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Setting managed resource to be: " + resource); m_managedResource = resource; }
@Override public void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException { if (notification == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Notification cannot be null.")); getAttributeChangeBroadcaster().sendNotification(notification); Logger modelMBeanLogger = getModelMBeanLogger(notification.getType()); if (modelMBeanLogger != null) if (modelMBeanLogger.isEnabledFor(Logger.DEBUG)) modelMBeanLogger.debug("ModelMBean log: " + new Date() + " - " + notification); Logger logger = getLogger(); if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Attribute change notification " + notification + " sent"); }
private void removeAttributeChangeNotificationListener(NotificationListener listener, String attributeName, Object handback) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException { if (listener == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Listener cannot be null.")); AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter(); if (attributeName != null) { filter.enableAttribute(attributeName); } else { MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes(); for (int i = 0; i < ai.length; i++) { Descriptor d = ((ModelMBeanAttributeInfo) ai[i]).getDescriptor(); filter.enableAttribute((String) d.getFieldValue("name")); } } getAttributeChangeBroadcaster().removeNotificationListener(listener, filter, handback); Logger logger = getLogger(); if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Listener " + listener + " for attribute " + attributeName + " removed successfully, handback is " + handback); }