本文整理汇总了Java中javax.management.AttributeList.add方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeList.add方法的具体用法?Java AttributeList.add怎么用?Java AttributeList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.AttributeList
的用法示例。
在下文中一共展示了AttributeList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
@Override
public AttributeList getAttributes(String[] attributeNames) {
if (attributeNames == null || attributeNames.length == 0)
throw new IllegalArgumentException();
updateMbeanInfoIfMetricsListChanged();
AttributeList result = new AttributeList(attributeNames.length);
for (String iAttributeName : attributeNames) {
try {
Object value = getAttribute(iAttributeName);
result.add(new Attribute(iAttributeName, value));
} catch (Exception e) {
continue;
}
}
return result;
}
示例2: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
@Override
public AttributeList getAttributes(String[] attributeNames) {
if (attributeNames == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("attributeNames[] cannot be null"),
"Cannot call getAttributes with null attribute names");
}
AttributeList resultList = new AttributeList();
if (attributeNames.length == 0) {
return resultList;
}
for (String attributeName : attributeNames) {
try {
Object value = getAttribute(attributeName);
resultList.add(new Attribute(attributeName, value));
} catch (Exception e) {
e.printStackTrace();
}
}
return (resultList);
}
示例3: doTest
import javax.management.AttributeList; //导入方法依赖的package包/类
private void doTest(JMXConnector connector) throws IOException,
MalformedObjectNameException, ReflectionException,
InstanceAlreadyExistsException, MBeanRegistrationException,
MBeanException, NotCompliantMBeanException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException {
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
ObjectName objName = new ObjectName("com.redhat.test.jmx:type=NameMBean");
System.out.println("DEBUG: Calling createMBean");
mbsc.createMBean(Name.class.getName(), objName);
System.out.println("DEBUG: Calling setAttributes");
AttributeList attList = new AttributeList();
attList.add(new Attribute("FirstName", ANY_NAME));
attList.add(new Attribute("LastName", ANY_NAME));
mbsc.setAttributes(objName, attList);
}
示例4: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
public AttributeList getAttributes(String[] attributeNames)
{
if(attributeNames != null)
{
AttributeList resultList = new AttributeList();
if (attributeNames.length == 0)
return resultList;
// Build the result attribute list
for(int i=0 ; i<attributeNames.length; i++)
{
try
{
Object oValue = getAttribute(attributeNames[i]);
resultList.add(new Attribute(attributeNames[i], oValue));
}
catch (Exception e)
{
}
}
return resultList;
}
return null;
}
示例5: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
/**
* Obtain and return the values of several attributes of this MBean.
*
* @param names Names of the requested attributes
*/
@Override
public AttributeList getAttributes(String names[]) {
// Validate the input parameters
if (names == null)
throw new RuntimeOperationsException
(new IllegalArgumentException("Attribute names list is null"),
"Attribute names list is null");
// Prepare our response, eating all exceptions
AttributeList response = new AttributeList();
for (int i = 0; i < names.length; i++) {
try {
response.add(new Attribute(names[i],getAttribute(names[i])));
} catch (Exception e) {
// Not having a particular attribute in the response
// is the indication of a getter problem
}
}
return (response);
}
示例6: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
@Override
public AttributeList getAttributes(String[] attributes) {
AttributeList attributeList = new AttributeList();
for (String atr : attributes) {
try {
attributeList.add(new Attribute(atr, folder.getProperty(atr).getValue()));
} catch (IntrospectionException ex) {
Logger.getLogger(FolderMBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
return attributeList;
}
示例7: setAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
/**
* Sets the values of an array of attributes of this ModelMBean.
* Executes the setAttribute() method for each attribute in the list.
*
* @param attributes A list of attributes: The identification of the
* attributes to be set and the values they are to be set to.
*
* @return The array of attributes that were set, with their new
* values in Attribute instances.
*
* @exception RuntimeOperationsException Wraps an
* {@link IllegalArgumentException}: The object name in parameter
* is null or attributes in parameter is null.
*
* @see #getAttributes
**/
public AttributeList setAttributes(AttributeList attributes) {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"setAttribute(Attribute)", "Entry");
}
if (attributes == null)
throw new RuntimeOperationsException(new
IllegalArgumentException("attributes must not be null"),
"Exception occurred trying to set attributes of a "+
"RequiredModelMBean");
final AttributeList responseList = new AttributeList();
// Go through the list of attributes
for (Attribute attr : attributes.asList()) {
try {
setAttribute(attr);
responseList.add(attr);
} catch (Exception excep) {
responseList.remove(attr);
}
}
return responseList;
}
示例8: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
/**
* Returns the values of several attributes in the ModelMBean.
* Executes a getAttribute for each attribute name in the
* attrNames array passed in.
*
* @param attrNames A String array of names of the attributes
* to be retrieved.
*
* @return The array of the retrieved attributes.
*
* @exception RuntimeOperationsException Wraps an
* {@link IllegalArgumentException}: The object name in parameter is
* null or attributes in parameter is null.
*
* @see #setAttributes(javax.management.AttributeList)
*/
public AttributeList getAttributes(String[] attrNames) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
RequiredModelMBean.class.getName(), "Entry");
}
if (attrNames == null)
throw new RuntimeOperationsException(new
IllegalArgumentException("attributeNames must not be null"),
"Exception occurred trying to get attributes of a "+
"RequiredModelMBean");
AttributeList responseList = new AttributeList();
for (int i = 0; i < attrNames.length; i++) {
try {
responseList.add(new Attribute(attrNames[i],
getAttribute(attrNames[i])));
} catch (Exception e) {
// eat exceptions because interface doesn't have an
// exception on it
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Failed to get \"" + attrNames[i] + "\": ", e);
}
}
}
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
}
return responseList;
}
示例9: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
public AttributeList getAttributes(String[] attributes) {
AttributeList list = new AttributeList();
for (String attr : attributes) {
try {
list.add(new Attribute(attr, getAttribute(attr)));
} catch (Exception e) {
// OK: ignore per spec
}
}
return list;
}
示例10: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
public final AttributeList getAttributes(String[] attributes) {
final AttributeList result = new AttributeList(attributes.length);
for (String attrName : attributes) {
try {
final Object attrValue = getAttribute(attrName);
result.add(new Attribute(attrName, attrValue));
} catch (Exception e) {
// OK: attribute is not included in returned list, per spec
// XXX: log the exception
}
}
return result;
}
示例11: setAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
/**
* Sets the values of an array of attributes of this ModelMBean.
* Executes the setAttribute() method for each attribute in the list.
*
* @param attributes A list of attributes: The identification of the
* attributes to be set and the values they are to be set to.
*
* @return The array of attributes that were set, with their new
* values in Attribute instances.
*
* @exception RuntimeOperationsException Wraps an
* {@link IllegalArgumentException}: The object name in parameter
* is null or attributes in parameter is null.
*
* @see #getAttributes
**/
public AttributeList setAttributes(AttributeList attributes) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
}
if (attributes == null)
throw new RuntimeOperationsException(new
IllegalArgumentException("attributes must not be null"),
"Exception occurred trying to set attributes of a "+
"RequiredModelMBean");
final AttributeList responseList = new AttributeList();
// Go through the list of attributes
for (Attribute attr : attributes.asList()) {
try {
setAttribute(attr);
responseList.add(attr);
} catch (Exception excep) {
responseList.remove(attr);
}
}
return responseList;
}
示例12: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
/**
* Returns the values of several attributes in the ModelMBean.
* Executes a getAttribute for each attribute name in the
* attrNames array passed in.
*
* @param attrNames A String array of names of the attributes
* to be retrieved.
*
* @return The array of the retrieved attributes.
*
* @exception RuntimeOperationsException Wraps an
* {@link IllegalArgumentException}: The object name in parameter is
* null or attributes in parameter is null.
*
* @see #setAttributes(javax.management.AttributeList)
*/
public AttributeList getAttributes(String[] attrNames) {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"getAttributes(String[])","Entry");
}
if (attrNames == null)
throw new RuntimeOperationsException(new
IllegalArgumentException("attributeNames must not be null"),
"Exception occurred trying to get attributes of a "+
"RequiredModelMBean");
AttributeList responseList = new AttributeList();
for (int i = 0; i < attrNames.length; i++) {
try {
responseList.add(new Attribute(attrNames[i],
getAttribute(attrNames[i])));
} catch (Exception e) {
// eat exceptions because interface doesn't have an
// exception on it
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"getAttributes(String[])",
"Failed to get \"" + attrNames[i] + "\": ", e);
}
}
}
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"getAttributes(String[])","Exit");
}
return responseList;
}
示例13: setupOffHeapMonitor
import javax.management.AttributeList; //导入方法依赖的package包/类
/**
* Creates and adds a generic GaugeMonitor for an attribute of the MemberMXBean.
*
* @param attribute the attribute to monitor.
* @param highThreshold the high threshold trigger.
* @param lowThreshold the low threshold trigger.
*/
protected void setupOffHeapMonitor(String attribute, long highThreshold, long lowThreshold) {
ObjectName memberMBeanObjectName = MBeanJMXAdapter.getMemberMBeanName(
InternalDistributedSystem.getConnectedInstance().getDistributedMember());
assertNotNull(memberMBeanObjectName);
try {
ObjectName offHeapMonitorName = new ObjectName("monitors:type=Gauge,attr=" + attribute);
mbeanServer.createMBean("javax.management.monitor.GaugeMonitor", offHeapMonitorName);
AttributeList al = new AttributeList();
al.add(new Attribute("ObservedObject", memberMBeanObjectName));
al.add(new Attribute("GranularityPeriod", 500));
al.add(new Attribute("ObservedAttribute", attribute));
al.add(new Attribute("Notify", true));
al.add(new Attribute("NotifyHigh", true));
al.add(new Attribute("NotifyLow", true));
al.add(new Attribute("HighTheshold", highThreshold));
al.add(new Attribute("LowThreshold", lowThreshold));
mbeanServer.setAttributes(offHeapMonitorName, al);
mbeanServer.addNotificationListener(offHeapMonitorName, notificationListener, null, null);
mbeanServer.invoke(offHeapMonitorName, "start", new Object[] {}, new String[] {});
} catch (Exception e) {
fail(e.getMessage());
}
}
示例14: setAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
public AttributeList setAttributes(AttributeList attributes)
{
// Check attributes is not null to avoid NullPointerException later on
//
if (attributes != null)
{
AttributeList resultList = new AttributeList();
// If attributeNames is empty, nothing more to do
//
if (attributes.isEmpty())
return resultList;
// For each attribute, try to set it and add to the result list if
// successfull
//
for (Iterator i = attributes.iterator(); i.hasNext();)
{
Attribute attr = (Attribute) i.next();
try
{
setAttribute(attr);
String name = attr.getName();
Object value = getAttribute(name);
resultList.add(new Attribute(name,value));
}
catch(Exception e)
{
e.printStackTrace();
}
}
return resultList;
}
return null;
}
示例15: getAttributes
import javax.management.AttributeList; //导入方法依赖的package包/类
/**
* Makes it possible to get the values of several attributes of
* the MBeanServerDelegate.
*
* @param attributes A list of the attributes to be retrieved.
*
* @return The list of attributes retrieved.
*
*/
public AttributeList getAttributes(String[] attributes) {
// If attributes is null, the get all attributes.
//
final String[] attn = (attributes==null?attributeNames:attributes);
// Prepare the result list.
//
final int len = attn.length;
final AttributeList list = new AttributeList(len);
// Get each requested attribute.
//
for (int i=0;i<len;i++) {
try {
final Attribute a =
new Attribute(attn[i],getAttribute(attn[i]));
list.add(a);
} catch (Exception x) {
// Skip the attribute that couldn't be obtained.
//
if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
MBEANSERVER_LOGGER.log(Level.TRACE,
"Attribute " + attn[i] + " not found");
}
}
}
// Finally return the result.
//
return list;
}