本文整理匯總了Java中javax.management.openmbean.CompositeData.get方法的典型用法代碼示例。如果您正苦於以下問題:Java CompositeData.get方法的具體用法?Java CompositeData.get怎麽用?Java CompositeData.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.management.openmbean.CompositeData
的用法示例。
在下文中一共展示了CompositeData.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: printCompositeInfo
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
/**
* Dumps the details of a single CompositeData object.
*
* @param composite
* the composite object
* @param out
* PrintWriter to write the output to
* @param nestLevel
* the nesting level
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@SuppressWarnings("unchecked")
private static void printCompositeInfo(CompositeData composite, PrintWriter out, int nestLevel) throws IOException
{
Map<String, Object> attributes = new TreeMap<String, Object>();
for (String key : (Set<String>)composite.getCompositeType().keySet())
{
Object value;
try
{
value = composite.get(key);
}
catch (Exception e)
{
value = JmxDumpUtil.PROTECTED_VALUE;
}
attributes.put(key, value);
}
tabulate(JmxDumpUtil.NAME_HEADER, JmxDumpUtil.VALUE_HEADER, attributes, out, nestLevel);
}
示例2: fromCompositeData
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
Object fromCompositeData(CompositeData cd,
String[] itemNames,
MXBeanMapping[] converters)
throws InvalidObjectException {
Object o;
try {
final Class<?> targetClass = getTargetClass();
ReflectUtil.checkPackageAccess(targetClass);
@SuppressWarnings("deprecation")
Object tmp = targetClass.newInstance();
o = tmp;
for (int i = 0; i < itemNames.length; i++) {
if (cd.containsKey(itemNames[i])) {
Object openItem = cd.get(itemNames[i]);
Object javaItem =
converters[i].fromOpenValue(openItem);
MethodUtil.invoke(setters[i], o, new Object[] {javaItem});
}
}
} catch (Exception e) {
throw invalidObjectException(e);
}
return o;
}
示例3: getMemoryUsageAfterGc
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
public static Map<String, MemoryUsage>
getMemoryUsageAfterGc(CompositeData cd) {
try {
TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC);
//return (Map<String,MemoryUsage>)
return cast(memoryUsageMapType.toJavaTypeData(td));
} catch (InvalidObjectException | OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
示例4: getProperty
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
private static String getProperty(TabularData td, String propName) {
CompositeData cd = td.get(new Object[] { propName});
if (cd != null) {
String key = (String) cd.get("key");
if (!propName.equals(key)) {
throw new RuntimeException("TEST FAILED: " +
key + " property found" +
" but expected to be " + propName);
}
return (String) cd.get("value");
}
return null;
}
示例5: getCompositeData
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
protected CompositeData getCompositeData() {
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// monitorInfoItemNames!
int len = monitorInfoItemNames.length;
Object[] values = new Object[len];
CompositeData li = LockInfoCompositeData.toCompositeData(lock);
for (int i = 0; i < len; i++) {
String item = monitorInfoItemNames[i];
if (item.equals(LOCKED_STACK_FRAME)) {
StackTraceElement ste = lock.getLockedStackFrame();
values[i] = (ste != null ? StackTraceElementCompositeData.
toCompositeData(ste)
: null);
} else if (item.equals(LOCKED_STACK_DEPTH)) {
values[i] = new Integer(lock.getLockedStackDepth());
} else {
values[i] = li.get(item);
}
}
try {
return new CompositeDataSupport(monitorInfoCompositeType,
monitorInfoItemNames,
values);
} catch (OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
示例6: getMemoryUsageBeforeGc
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
public static Map<String, MemoryUsage>
getMemoryUsageBeforeGc(CompositeData cd) {
try {
TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC);
return cast(memoryUsageMapType.toJavaTypeData(td));
} catch (InvalidObjectException | OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
示例7: handleInvokeBrowse
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
private OperationResult handleInvokeBrowse(Configuration parameters, EmsBean emsBean) throws Exception {
// get selector
final String selector = parameters.getSimpleValue("filter");
// find the operation
EmsOperation browseMessagesOp = findOperation(emsBean, BROWSE_OPERATION, 1);
// invoke
final Object opResult = browseMessagesOp.invoke(selector);
// map result to a list of mapped values
final PropertyList messageList = new PropertyList("messageList");
int nMsgs = Array.getLength(opResult);
for (int i = 0; i < nMsgs; i++) {
final PropertyMap msgMap = new PropertyMap("message");
final CompositeData compositeData = (CompositeData) Array.get(opResult, i);
for (String key : compositeData.getCompositeType().keySet()) {
// get the value of the key and add it to the message map
final Object value = compositeData.get(key);
if (value != null && value instanceof TabularData) {
// skip TabularData properties like BooleanProperties
} else if (value != null && value.getClass().isArray()) {
StringBuilder builder = new StringBuilder("[");
final int size = Array.getLength(value);
for (int index = 0; index < size; index++) {
builder.append(Array.get(value, index));
if (index < (size - 1)) {
builder.append(", ");
}
}
builder.append(']');
msgMap.put(new PropertySimple(key, builder.toString()));
} else {
// convert to string and save
msgMap.put(new PropertySimple(key, (value != null) ? value.toString() : null));
}
}
// add the message to the list
messageList.add(msgMap);
}
final OperationResult result = new OperationResult();
result.getComplexResults().put(messageList);
return result;
}
示例8: from
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
public static ExoticCompositeData from(CompositeData cd) {
String whatsit = (String) cd.get("whatsit");
if (!whatsit.startsWith("!"))
throw new IllegalArgumentException(whatsit);
return new ExoticCompositeData(whatsit.substring(1));
}
示例9: getBoolean
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
static boolean getBoolean(CompositeData cd, String itemName) {
if (cd == null)
throw new IllegalArgumentException("Null CompositeData");
return ((Boolean) cd.get(itemName));
}
示例10: validateCompositeData
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
/** Validate if the input CompositeData has the expected
* CompositeType (i.e. contain all attributes with expected
* names and types).
*/
public static void validateCompositeData(CompositeData cd) {
if (cd == null) {
throw new NullPointerException("Null CompositeData");
}
CompositeType type = cd.getCompositeType();
boolean currentVersion = true;
if (!isTypeMatched(threadInfoCompositeType, type)) {
currentVersion = false;
// check if cd is an older version
if (!isTypeMatched(threadInfoV5CompositeType, type) &&
!isTypeMatched(threadInfoV6CompositeType, type)) {
throw new IllegalArgumentException(
"Unexpected composite type for ThreadInfo");
}
}
CompositeData[] stackTraceData =
(CompositeData[]) cd.get(STACK_TRACE);
if (stackTraceData == null) {
throw new IllegalArgumentException(
"StackTraceElement[] is missing");
}
if (stackTraceData.length > 0) {
StackTraceElementCompositeData.validateCompositeData(stackTraceData[0]);
}
// validate v6 attributes
if (currentVersion) {
CompositeData li = (CompositeData) cd.get(LOCK_INFO);
if (li != null) {
if (!isTypeMatched(lockInfoCompositeType,
li.getCompositeType())) {
throw new IllegalArgumentException(
"Unexpected composite type for \"" +
LOCK_INFO + "\" attribute.");
}
}
CompositeData[] lms = (CompositeData[]) cd.get(LOCKED_MONITORS);
if (lms == null) {
throw new IllegalArgumentException("MonitorInfo[] is null");
}
if (lms.length > 0) {
MonitorInfoCompositeData.validateCompositeData(lms[0]);
}
CompositeData[] lsyncs = (CompositeData[]) cd.get(LOCKED_SYNCS);
if (lsyncs == null) {
throw new IllegalArgumentException("LockInfo[] is null");
}
if (lsyncs.length > 0) {
if (!isTypeMatched(lockInfoCompositeType,
lsyncs[0].getCompositeType())) {
throw new IllegalArgumentException(
"Unexpected composite type for \"" +
LOCKED_SYNCS + "\" attribute.");
}
}
}
}
示例11: getInt
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
static int getInt(CompositeData cd, String itemName) {
if (cd == null)
throw new IllegalArgumentException("Null CompositeData");
return ((Integer) cd.get(itemName));
}
示例12: getLong
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
static long getLong(CompositeData cd, String itemName) {
if (cd == null)
throw new IllegalArgumentException("Null CompositeData");
return ((Long) cd.get(itemName));
}
示例13: getString
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
static String getString(CompositeData cd, String itemName) {
if (cd == null)
throw new IllegalArgumentException("Null CompositeData");
return (String) cd.get(itemName);
}
示例14: main
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
MBeanServer mbs = MBeanServerFactory.newMBeanServer();
ObjectName pointName = new ObjectName("a:type=Point");
PointMXBean pointmx = new PointImpl();
mbs.registerMBean(pointmx, pointName);
Point point = new Point(1, 2);
PointMXBean pointproxy =
JMX.newMXBeanProxy(mbs, pointName, PointMXBean.class);
Point point1 = pointproxy.identity(point);
if (point1.getX() != point.getX() || point1.getY() != point.getY())
throw new Exception("Point doesn't match");
System.out.println("Point test passed");
ObjectName evolveName = new ObjectName("a:type=Evolve");
EvolveMXBean evolvemx = new EvolveImpl();
mbs.registerMBean(evolvemx, evolveName);
Evolve evolve =
new Evolve(59, "tralala", Collections.singletonList("tiddly"));
EvolveMXBean evolveProxy =
JMX.newMXBeanProxy(mbs, evolveName, EvolveMXBean.class);
Evolve evolve1 = evolveProxy.identity(evolve);
if (evolve1.getOldInt() != evolve.getOldInt()
|| !evolve1.getNewString().equals(evolve.getNewString())
|| !evolve1.getNewerList().equals(evolve.getNewerList()))
throw new Exception("Evolve doesn't match");
System.out.println("Evolve test passed");
ObjectName evolvedName = new ObjectName("a:type=Evolved");
EvolveMXBean evolvedmx = new EvolveImpl();
mbs.registerMBean(evolvedmx, evolvedName);
CompositeType evolvedType =
new CompositeType("Evolved", "descr", new String[] {"oldInt"},
new String[] {"oldInt descr"},
new OpenType[] {SimpleType.INTEGER});
CompositeData evolvedData =
new CompositeDataSupport(evolvedType, new String[] {"oldInt"},
new Object[] {5});
CompositeData evolved1 = (CompositeData)
mbs.invoke(evolvedName, "identity", new Object[] {evolvedData},
new String[] {CompositeData.class.getName()});
if ((Integer) evolved1.get("oldInt") != 5
|| !evolved1.get("newString").equals("defaultString")
|| ((String[]) evolved1.get("newerList")).length != 0)
throw new Exception("Evolved doesn't match: " + evolved1);
System.out.println("Evolved test passed");
}
示例15: getMBeanAttrValue
import javax.management.openmbean.CompositeData; //導入方法依賴的package包/類
private static Object getMBeanAttrValue(MBeanServerConnection mbsc, ObjectName on, String attr, String key) {
Object o = getMBeanAttrValue(mbsc, on, attr);
if (o == null) {
return null;
}
if (CompositeData.class.isAssignableFrom(o.getClass())) {
CompositeData cd = (CompositeData) o;
return cd.get(key);
}
return null;
}