use of javax.management.Attribute in project hive by apache.
the class MetricsMBeanImpl method setAttributes.
@Override
public AttributeList setAttributes(AttributeList arg0) {
AttributeList attributesSet = new AttributeList();
for (Attribute attr : arg0.asList()) {
try {
setAttribute(attr);
attributesSet.add(attr);
} catch (AttributeNotFoundException e) {
// ignore exception - we simply don't add this attribute
// back in to the resultant set.
} catch (InvalidAttributeValueException e) {
// ditto
} catch (MBeanException e) {
// likewise
} catch (ReflectionException e) {
// and again, one last time.
}
}
return attributesSet;
}
use of javax.management.Attribute in project tomcat by apache.
the class JMXProxyServlet method setAttributeInternal.
/**
* Sets an MBean attribute's value.
*/
private void setAttributeInternal(String onameStr, String attributeName, String value) throws OperationsException, MBeanException, ReflectionException {
ObjectName oname = new ObjectName(onameStr);
String type = registry.getType(oname, attributeName);
Object valueObj = registry.convertValue(type, value);
mBeanServer.setAttribute(oname, new Attribute(attributeName, valueObj));
}
use of javax.management.Attribute in project tomcat by apache.
the class BaseModelMBean method setAttribute.
/**
* Set the value of a specific attribute of this MBean.
*
* @param attribute The identification of the attribute to be set
* and the new value
*
* @exception AttributeNotFoundException if this attribute is not
* supported by this MBean
* @exception MBeanException if the initializer of an object
* throws an exception
* @exception ReflectionException if a Java reflection exception
* occurs when invoking the getter
*/
@Override
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, ReflectionException {
if (log.isDebugEnabled())
log.debug("Setting attribute " + this + " " + attribute);
if ((resource instanceof DynamicMBean) && !(resource instanceof BaseModelMBean)) {
try {
((DynamicMBean) resource).setAttribute(attribute);
} catch (InvalidAttributeValueException e) {
throw new MBeanException(e);
}
return;
}
// Validate the input parameters
if (attribute == null)
throw new RuntimeOperationsException(new IllegalArgumentException("Attribute is null"), "Attribute is null");
String name = attribute.getName();
Object value = attribute.getValue();
if (name == null)
throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null");
Object oldValue = null;
//if( getAttMap.get(name) != null )
// oldValue=getAttribute( name );
Method m = managedBean.getSetter(name, this, resource);
try {
if (m.getDeclaringClass().isAssignableFrom(this.getClass())) {
m.invoke(this, new Object[] { value });
} else {
m.invoke(resource, new Object[] { value });
}
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t == null)
t = e;
if (t instanceof RuntimeException)
throw new RuntimeOperationsException((RuntimeException) t, "Exception invoking method " + name);
else if (t instanceof Error)
throw new RuntimeErrorException((Error) t, "Error invoking method " + name);
else
throw new MBeanException(e, "Exception invoking method " + name);
} catch (Exception e) {
log.error("Exception invoking method " + name, e);
throw new MBeanException(e, "Exception invoking method " + name);
}
try {
sendAttributeChangeNotification(new Attribute(name, oldValue), attribute);
} catch (Exception ex) {
log.error("Error sending notification " + name, ex);
}
//attributes.put( name, value );
// if( source != null ) {
// // this mbean is associated with a source - maybe we want to persist
// source.updateField(oname, name, value);
// }
}
use of javax.management.Attribute in project tomcat by apache.
the class BaseModelMBean method setAttributes.
/**
* Set the values of several attributes of this MBean.
*
* @param attributes THe names and values to be set
*
* @return The list of attributes that were set and their new values
*/
@Override
public AttributeList setAttributes(AttributeList attributes) {
AttributeList response = new AttributeList();
// Validate the input parameters
if (attributes == null)
return response;
// Prepare and return our response, eating all exceptions
String[] names = new String[attributes.size()];
int n = 0;
Iterator<?> items = attributes.iterator();
while (items.hasNext()) {
Attribute item = (Attribute) items.next();
names[n++] = item.getName();
try {
setAttribute(item);
} catch (Exception e) {
// Ignore all exceptions
}
}
return (getAttributes(names));
}
use of javax.management.Attribute in project jetty.project by eclipse.
the class ObjectMBean method setAttributes.
/* ------------------------------------------------------------ */
public AttributeList setAttributes(AttributeList attrs) {
if (LOG.isDebugEnabled())
LOG.debug("setAttributes");
AttributeList results = new AttributeList(attrs.size());
Iterator<Object> iter = attrs.iterator();
while (iter.hasNext()) {
try {
Attribute attr = (Attribute) iter.next();
setAttribute(attr);
results.add(new Attribute(attr.getName(), getAttribute(attr.getName())));
} catch (Exception e) {
LOG.warn(Log.EXCEPTION, e);
}
}
return results;
}
Aggregations