本文整理了Java中javax.management.Attribute.<init>()
方法的一些代码示例,展示了Attribute.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute.<init>()
方法的具体详情如下:
包路径:javax.management.Attribute
类名称:Attribute
方法名:<init>
暂无
代码示例来源:origin: apache/kafka
@Override
public AttributeList getAttributes(String[] names) {
AttributeList list = new AttributeList();
for (String name : names) {
try {
list.add(new Attribute(name, getAttribute(name)));
} catch (Exception e) {
log.warn("Error getting JMX attribute '{}'", name, e);
}
}
return list;
}
代码示例来源:origin: org.logicalcobwebs/com.springsource.org.logicalcobwebs.proxool
private void setIntegerAttribute(String attributeName, String propertyName, Object value, int defaultValue, Properties properties,
AttributeList resultList) throws InvalidAttributeValueException {
checkAssignable(attributeName, Integer.class, value);
if (notEmptyOrZero((Integer) value)) {
properties.setProperty(propertyName, value.toString());
resultList.add(new Attribute(attributeName, value));
} else {
resultList.add(new Attribute(attributeName,
new Integer(defaultValue)));
}
}
代码示例来源:origin: org.aeonbits.owner/owner
@Delegate
public AttributeList getAttributes(String[] attributes) {
List<Attribute> attrList = new LinkedList<Attribute>();
for (String propertyName : attributes)
attrList.add(new Attribute(propertyName, manager.getProperty(propertyName)));
return new AttributeList(attrList);
}
代码示例来源:origin: apache/hive
@Override
public AttributeList getAttributes(String[] arg0) {
AttributeList results = new AttributeList();
synchronized(metricsMap) {
for (String key : arg0) {
results.add(new Attribute(key,metricsMap.get(key)));
}
}
return results;
}
代码示例来源:origin: airlift/airlift
@Test
public void testGetAttributes()
throws Exception
{
assertEquals(mbeanServerConnection.getAttributes(testMBeanName, new String[] {"Value", "ObjectValue"}),
new AttributeList(ImmutableList.of(new Attribute("Value", null), new Attribute("ObjectValue", null))));
testMBean.setValue("FOO");
testMBean.setObjectValue(UUID.randomUUID());
assertEquals(mbeanServerConnection.getAttributes(testMBeanName, new String[] {"Value", "ObjectValue"}),
new AttributeList(ImmutableList.of(new Attribute("Value", "FOO"), new Attribute("ObjectValue", testMBean.getObjectValue()))));
}
代码示例来源:origin: com.cloudhopper.proxool/proxool
private void setIntegerAttribute(String attributeName, String propertyName, Object value, int defaultValue, Properties properties,
AttributeList resultList) throws InvalidAttributeValueException {
checkAssignable(attributeName, Integer.class, value);
if (notEmptyOrZero((Integer) value)) {
properties.setProperty(propertyName, value.toString());
resultList.add(new Attribute(attributeName, value));
} else {
resultList.add(new Attribute(attributeName,
new Integer(defaultValue)));
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public AttributeList getAttributes( String[] attributes )
{
AttributeList result = new AttributeList( attributes.length );
for ( String attribute : attributes )
{
try
{
result.add( new Attribute( attribute, getAttribute( attribute ) ) );
}
catch ( Exception e )
{
throw new RuntimeException( e );
}
}
return result;
}
代码示例来源:origin: io.airlift/jmx-http-rpc-experimental
@Test
public void testGetAttributes()
throws Exception
{
assertEquals(mbeanServerConnection.getAttributes(testMBeanName, new String[]{"Value", "ObjectValue"}),
new AttributeList(ImmutableList.of(new Attribute("Value", null), new Attribute("ObjectValue", null))));
testMBean.setValue("FOO");
testMBean.setObjectValue(UUID.randomUUID());
assertEquals(mbeanServerConnection.getAttributes(testMBeanName, new String[]{"Value", "ObjectValue"}),
new AttributeList(ImmutableList.of(new Attribute("Value", "FOO"), new Attribute("ObjectValue", testMBean.getObjectValue()))));
}
代码示例来源:origin: Netflix/servo
/**
* {@inheritDoc}
*/
@Override
public AttributeList getAttributes(String[] names) {
AttributeList list = new AttributeList();
for (String name : names) {
list.add(new Attribute(name, monitor.getValue()));
}
return list;
}
代码示例来源:origin: airlift/airlift
@Test
public void testSetAttributes()
throws Exception
{
UUID uuid = UUID.randomUUID();
mbeanServerConnection.setAttributes(testMBeanName, new AttributeList(ImmutableList.of(new Attribute("Value", "Foo"), new Attribute("ObjectValue", uuid))));
assertEquals(testMBean.getValue(), "Foo");
assertEquals(testMBean.getObjectValue(), uuid);
mbeanServerConnection.setAttributes(testMBeanName, new AttributeList(ImmutableList.of(new Attribute("Value", null), new Attribute("ObjectValue", null))));
assertEquals(testMBean.getValue(), null);
assertEquals(testMBean.getObjectValue(), null);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public AttributeList getAttributes(String[] attributes) {
AttributeList list = new AttributeList();
for (Map.Entry<String, CacheStat> stats : cacheStats.entrySet()) {
list.add(new Attribute(stats.getKey(), stats.getValue().getHitRate().doubleValue()));
}
return list;
}
代码示例来源:origin: btraceio/btrace
@Override
public synchronized AttributeList getAttributes(String[] names) {
AttributeList list = new AttributeList();
for (String name : names) {
Field field = attributes.get(name);
Object value = null;
if (field != null) {
value = getFieldValue(field);
}
if (value != null) {
list.add(new Attribute(name, value));
}
}
return list;
}
代码示例来源:origin: vipshop/vjtools
private AttributeList getAttributes(ObjectName objName, String[] attrNames)
throws InstanceNotFoundException, ReflectionException, IOException {
final NameValueMap values = getCachedAttributes(objName, new TreeSet<String>(Arrays.asList(attrNames)));
final AttributeList list = new AttributeList();
for (String attrName : attrNames) {
final Object value = values.get(attrName);
if (value != null || values.containsKey(attrName)) {
list.add(new Attribute(attrName, value));
}
}
return list;
}
代码示例来源:origin: log4j/log4j
/**
* 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);
}
代码示例来源:origin: apache/geode
@Override
public AttributeList getAttributes(ObjectName name, String[] attributes)
throws InstanceNotFoundException, ReflectionException {
AttributeList results = new AttributeList();
for (String attribute : attributes) {
try {
Object value = getAttribute(name, attribute);
Attribute att = new Attribute(attribute, value);
results.add(att);
} catch (Exception e) {
throw new GemFireSecurityException("error getting value of " + attribute + " from " + name,
e);
}
}
return results;
}
代码示例来源:origin: log4j/log4j
"Cannot invoke a setter of " + dClassName);
AttributeList resultList = new AttributeList();
String name = attr.getName();
Object value = getAttribute(name);
resultList.add(new Attribute(name,value));
} catch(JMException e) {
e.printStackTrace();
代码示例来源:origin: patric-r/jvmtop
private AttributeList getAttributes(
ObjectName objName, String[] attrNames) throws
InstanceNotFoundException, ReflectionException, IOException {
final NameValueMap values = getCachedAttributes(
objName,
new TreeSet<String>(Arrays.asList(attrNames)));
final AttributeList list = new AttributeList();
for (String attrName : attrNames) {
final Object value = values.get(attrName);
if (value != null || values.containsKey(attrName)) {
list.add(new Attribute(attrName, value));
}
}
return list;
}
代码示例来源:origin: apache/geode
@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;
}
代码示例来源:origin: apache/cloudstack
@Override
public synchronized AttributeList getAttributes(String[] names) {
AttributeList list = new AttributeList();
for (String name : names) {
Object value = _propMap.get(name);
if (value != null)
list.add(new Attribute(name, value));
}
return list;
}
代码示例来源:origin: apache/cloudstack
@Override
public synchronized AttributeList setAttributes(AttributeList list) {
Attribute[] attrs = list.toArray(new Attribute[0]);
AttributeList retList = new AttributeList();
for (Attribute attr : attrs) {
String name = attr.getName();
Object value = attr.getValue();
_propMap.put(name, value);
retList.add(new Attribute(name, value));
}
return retList;
}
内容来源于网络,如有侵权,请联系作者删除!