本文整理匯總了Java中javax.management.Attribute.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java Attribute.getName方法的具體用法?Java Attribute.getName怎麽用?Java Attribute.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.management.Attribute
的用法示例。
在下文中一共展示了Attribute.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAttributes
import javax.management.Attribute; //導入方法依賴的package包/類
/**
* 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));
}
示例2: setAttributes
import javax.management.Attribute; //導入方法依賴的package包/類
/**
* 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));
}
示例3: setAttributes
import javax.management.Attribute; //導入方法依賴的package包/類
/**
* 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
*/
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));
}
示例4: sendAttributeChangeNotification
import javax.management.Attribute; //導入方法依賴的package包/類
public void sendAttributeChangeNotification(Attribute oldAttribute, Attribute newAttribute)
throws MBeanException, RuntimeOperationsException {
if (oldAttribute == null || newAttribute == null)
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_ATTRIBUTE_CANNOT_BE_NULL.toLocalizedString()));
if (!oldAttribute.getName().equals(newAttribute.getName()))
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_ATTRIBUTE_NAMES_CANNOT_BE_DIFFERENT.toLocalizedString()));
// 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);
}
示例5: setAttributes
import javax.management.Attribute; //導入方法依賴的package包/類
public AttributeList setAttributes(AttributeList attributes) {
if (attributes == null)
throw new RuntimeOperationsException(new IllegalArgumentException(
LocalizedStrings.MX4JModelMBean_ATTRIBUTE_LIST_CANNOT_BE_NULL.toLocalizedString()));
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;
}
示例6: if
import javax.management.Attribute; //導入方法依賴的package包/類
/**
* Send an <code>AttributeChangeNotification</code> to all registered
* listeners.
*
* @param oldValue The original value of the <code>Attribute</code>
* @param newValue The new value of the <code>Attribute</code>
*
* @exception MBeanException if an object initializer throws an
* exception
* @exception RuntimeOperationsException wraps IllegalArgumentException
* when the specified notification is <code>null</code> or invalid
*/
@Override
public void sendAttributeChangeNotification
(Attribute oldValue, Attribute newValue)
throws MBeanException, RuntimeOperationsException {
// Calculate the class name for the change notification
String type = null;
if (newValue.getValue() != null)
type = newValue.getValue().getClass().getName();
else if (oldValue.getValue() != null)
type = oldValue.getValue().getClass().getName();
else
return; // Old and new are both null == no change
AttributeChangeNotification notification =
new AttributeChangeNotification
(this, 1, System.currentTimeMillis(),
"Attribute value has changed",
oldValue.getName(), type,
oldValue.getValue(), newValue.getValue());
sendAttributeChangeNotification(notification);
}
示例7: setAttribute
import javax.management.Attribute; //導入方法依賴的package包/類
/**
* This method always fail since all MBeanServerDelegateMBean attributes
* are read-only.
*
* @param attribute The identification of the attribute to
* be set and the value it is to be set to.
*
* @exception AttributeNotFoundException
*/
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
// Now we will always fail:
// Either because the attribute is null or because it is not
// accessible (or does not exist).
//
final String attname = (attribute==null?null:attribute.getName());
if (attname == null) {
final RuntimeException r =
new IllegalArgumentException("Attribute name cannot be null");
throw new RuntimeOperationsException(r,
"Exception occurred trying to invoke the setter on the MBean");
}
// This is a hack: we call getAttribute in order to generate an
// AttributeNotFoundException if the attribute does not exist.
//
Object val = getAttribute(attname);
// If we reach this point, we know that the requested attribute
// exists. However, since all attributes are read-only, we throw
// an AttributeNotFoundException.
//
throw new AttributeNotFoundException(attname + " not accessible");
}
示例8: cloneAttribute
import javax.management.Attribute; //導入方法依賴的package包/類
/**
* Clone attribute.
*/
private Attribute cloneAttribute(Attribute attribute) {
if (attribute != null) {
if (!attribute.getClass().equals(Attribute.class)) {
return new Attribute(attribute.getName(), attribute.getValue());
}
}
return attribute;
}
示例9: setAttribute
import javax.management.Attribute; //導入方法依賴的package包/類
public final void setAttribute(Attribute attribute)
throws AttributeNotFoundException,
InvalidAttributeValueException,
MBeanException,
ReflectionException {
final String name = attribute.getName();
final Object value = attribute.getValue();
perInterface.setAttribute(resource, name, value, getCookie());
}
示例10: setAttribute
import javax.management.Attribute; //導入方法依賴的package包/類
public void setAttribute(Attribute attr)
throws MBeanException {
String attrName = attr.getName();
if (attrName.equals("UncheckedException"))
throw theUncheckedException;
else
throw new AssertionError();
}
示例11: setAttributes
import javax.management.Attribute; //導入方法依賴的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;
}
示例12: setAttribute
import javax.management.Attribute; //導入方法依賴的package包/類
public void setAttribute(Attribute attribute)
throws AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
String name = attribute.getName();
AttrMethods am = attrMap.get(name);
if (am == null || am.setter == null)
throw new AttributeNotFoundException(name);
invokeMethod(am.setter, attribute.getValue());
}
示例13: sendAttributeChangeNotification
import javax.management.Attribute; //導入方法依賴的package包/類
public void sendAttributeChangeNotification(Attribute inOldVal,
Attribute inNewVal)
throws MBeanException, RuntimeOperationsException {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
}
// do we really want to do this?
if ((inOldVal == null) || (inNewVal == null))
throw new RuntimeOperationsException(new
IllegalArgumentException("Attribute object must not be null"),
"Exception occurred trying to send " +
"attribute change notification of a ModelMBean");
if (!(inOldVal.getName().equals(inNewVal.getName())))
throw new RuntimeOperationsException(new
IllegalArgumentException("Attribute names are not the same"),
"Exception occurred trying to send " +
"attribute change notification of a ModelMBean");
Object newVal = inNewVal.getValue();
Object oldVal = inOldVal.getValue();
String className = "unknown";
if (newVal != null)
className = newVal.getClass().getName();
if (oldVal != null)
className = oldVal.getClass().getName();
AttributeChangeNotification myNtfyObj = new
AttributeChangeNotification(this,
1,
((new Date()).getTime()),
"AttributeChangeDetected",
inOldVal.getName(),
className,
inOldVal.getValue(),
inNewVal.getValue());
sendAttributeChangeNotification(myNtfyObj);
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
}
}
示例14: sendAttributeChangeNotification
import javax.management.Attribute; //導入方法依賴的package包/類
public void sendAttributeChangeNotification(Attribute inOldVal,
Attribute inNewVal)
throws MBeanException, RuntimeOperationsException {
final String mth =
"sendAttributeChangeNotification(Attribute, Attribute)";
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),mth,
"Entry");
}
// do we really want to do this?
if ((inOldVal == null) || (inNewVal == null))
throw new RuntimeOperationsException(new
IllegalArgumentException("Attribute object must not be null"),
"Exception occurred trying to send " +
"attribute change notification of a ModelMBean");
if (!(inOldVal.getName().equals(inNewVal.getName())))
throw new RuntimeOperationsException(new
IllegalArgumentException("Attribute names are not the same"),
"Exception occurred trying to send " +
"attribute change notification of a ModelMBean");
Object newVal = inNewVal.getValue();
Object oldVal = inOldVal.getValue();
String className = "unknown";
if (newVal != null)
className = newVal.getClass().getName();
if (oldVal != null)
className = oldVal.getClass().getName();
AttributeChangeNotification myNtfyObj = new
AttributeChangeNotification(this,
1,
((new Date()).getTime()),
"AttributeChangeDetected",
inOldVal.getName(),
className,
inOldVal.getValue(),
inNewVal.getValue());
sendAttributeChangeNotification(myNtfyObj);
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),mth,
"Exit");
}
}
示例15: setAttribute
import javax.management.Attribute; //導入方法依賴的package包/類
@Override
public void setAttribute(Attribute attribute) throws AttributeNotFoundException,
InvalidAttributeValueException, MBeanException, ReflectionException {
throw new AttributeNotFoundException(attribute.getName());
}