List of usage examples for javax.management.openmbean TabularDataSupport TabularDataSupport
public TabularDataSupport(TabularType tabularType)
From source file:org.jolokia.converter.object.TabularDataConverter.java
/** {@inheritDoc} */ @Override/* w w w . j a v a2 s . co m*/ Object convertToObject(TabularType pType, Object pFrom) { JSONObject value = getAsJsonObject(pFrom); // Convert simple map representation (with rowtype "key" and "value") if (checkForMapAttributeWithSimpleKey(pType)) { return convertToTabularTypeFromMap(pType, value); } // If it is given a a full representation (with "indexNames" and "values"), then parse this // accordingly if (checkForFullTabularDataRepresentation(value, pType)) { return convertTabularDataFromFullRepresentation(value, pType); } // Its a plain TabularData, which is tried to convert rom a maps of maps TabularDataSupport tabularData = new TabularDataSupport(pType); // Recursively go down the map and collect the values putRowsToTabularData(tabularData, value, pType.getIndexNames().size()); return tabularData; }
From source file:com.adobe.acs.commons.util.impl.AbstractCacheMBean.java
@Override public final TabularData getCacheContents() throws CacheMBeanException { try {/*from ww w .j ava2 s . c o m*/ final CompositeType cacheEntryType = getCacheEntryType(); final TabularDataSupport tabularData = new TabularDataSupport(new TabularType("Cache Entries", "Cache Entries", cacheEntryType, new String[] { JMX_PN_CACHEKEY })); Map<K, V> cacheAsMap = getCacheAsMap(); for (final Map.Entry<K, V> entry : cacheAsMap.entrySet()) { final Map<String, Object> data = new HashMap<String, Object>(); data.put(JMX_PN_CACHEKEY, entry.getKey().toString()); V cacheObj = entry.getValue(); if (cacheObj != null) { addCacheData(data, cacheObj); } tabularData.put(new CompositeDataSupport(cacheEntryType, data)); } return tabularData; } catch (OpenDataException ex) { throw new CacheMBeanException("Error getting the cache contents", ex); } }
From source file:org.alfresco.repo.security.authentication.ldap.Monitor.java
/** * test authenticate//from w w w . j a va 2s . co m * * @param userName String * @param credentials String * @throws AuthenticationException */ public CompositeData testAuthenticate(String userName, String credentials) { String stepKeys[] = { "id", "stepMessage", "success" }; String stepDescriptions[] = { "id", "stepMessage", "success" }; OpenType<?> stepTypes[] = { SimpleType.INTEGER, SimpleType.STRING, SimpleType.BOOLEAN }; try { String[] key = { "id" }; CompositeType sType = new CompositeType("Authentication Step", "Step", stepKeys, stepDescriptions, stepTypes); TabularType tType = new TabularType("Diagnostic", "Authentication Steps", sType, key); TabularData table = new TabularDataSupport(tType); String attributeKeys[] = { "authenticationMessage", "success", "diagnostic" }; String attributeDescriptions[] = { "authenticationMessage", "success", "diagnostic" }; OpenType<?> attributeTypes[] = { SimpleType.STRING, SimpleType.BOOLEAN, tType }; try { component.authenticate(userName, credentials.toCharArray()); CompositeType cType = new CompositeType("Authentication Result", "Result Success", attributeKeys, attributeDescriptions, attributeTypes); Map<String, Object> value = new HashMap<String, Object>(); value.put("authenticationMessage", "Test Passed"); value.put("success", true); value.put("diagnostic", table); CompositeDataSupport row = new CompositeDataSupport(cType, value); return row; } catch (AuthenticationException ae) { CompositeType cType = new CompositeType("Authentication Result", "Result Failed", attributeKeys, attributeDescriptions, attributeTypes); Map<String, Object> value = new HashMap<String, Object>(); value.put("authenticationMessage", ae.getMessage()); value.put("success", false); if (ae.getDiagnostic() != null) { int i = 0; for (AuthenticationStep step : ae.getDiagnostic().getSteps()) { Map<String, Object> x = new HashMap<String, Object>(); x.put("id", i++); x.put("stepMessage", step.getMessage()); x.put("success", step.isSuccess()); CompositeDataSupport row = new CompositeDataSupport(sType, x); table.put(row); } } value.put("diagnostic", table); CompositeDataSupport row = new CompositeDataSupport(cType, value); return row; } } catch (OpenDataException oe) { logger.error("", oe); return null; } }
From source file:com.alibaba.dragoon.stat.WebStatisticManager.java
public TabularData getURIList() throws JMException { CompositeType rowType = WebURIStatistic.getCompositeType(); String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]); TabularType tabularType = new TabularType("URIStatisticList", "URIStatisticList", rowType, indexNames); TabularData data = new TabularDataSupport(tabularType); for (Map.Entry<String, WebURIStatistic> entry : this.statsMap.entrySet()) { if (entry.getValue().getCountDirect() == 0) { continue; }/*from ww w. ja v a 2 s .c om*/ data.put(entry.getValue().getCompositeData()); } return data; }
From source file:com.adobe.acs.commons.util.impl.AbstractGuavaCacheMBean.java
@Override @SuppressWarnings("squid:S1192") public final TabularData getCacheStats() throws OpenDataException { // Exposing all google guava stats. final CompositeType cacheEntryType = new CompositeType("Cache Stats", "Cache Stats", new String[] { "Stat", "Value" }, new String[] { "Stat", "Value" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING }); final TabularDataSupport tabularData = new TabularDataSupport( new TabularType("Cache Stats", "Cache Stats", cacheEntryType, new String[] { "Stat" })); CacheStats cacheStats = getCache().stats(); final Map<String, Object> row = new HashMap<String, Object>(); row.put("Stat", "Request Count"); row.put("Value", String.valueOf(cacheStats.requestCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Hit Count"); row.put("Value", String.valueOf(cacheStats.hitCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Hit Rate"); row.put("Value", String.format("%.0f%%", cacheStats.hitRate() * 100)); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Miss Count"); row.put("Value", String.valueOf(cacheStats.missCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Miss Rate"); row.put("Value", String.format("%.0f%%", cacheStats.missRate() * 100)); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Eviction Count"); row.put("Value", String.valueOf(cacheStats.evictionCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Load Count"); row.put("Value", String.valueOf(cacheStats.loadCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Load Exception Count"); row.put("Value", String.valueOf(cacheStats.loadExceptionCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Load Exception Rate"); row.put("Value", String.format("%.0f%%", cacheStats.loadExceptionRate() * 100)); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Load Success Count"); row.put("Value", String.valueOf(cacheStats.loadSuccessCount())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Average Load Penalty"); row.put("Value", String.valueOf(cacheStats.averageLoadPenalty())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); row.put("Stat", "Total Load Time"); row.put("Value", String.valueOf(cacheStats.totalLoadTime())); tabularData.put(new CompositeDataSupport(cacheEntryType, row)); return tabularData; }
From source file:jenkins.security.security218.ysoserial.payloads.JSON1.java
/** * Will call all getter methods on payload that are defined in the given interfaces *//*from w ww . j av a 2 s . c o m*/ public static Map makeCallerChain(Object payload, Class... ifaces) throws OpenDataException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, Exception, ClassNotFoundException { CompositeType rt = new CompositeType("a", "b", new String[] { "a" }, new String[] { "a" }, new OpenType[] { javax.management.openmbean.SimpleType.INTEGER }); TabularType tt = new TabularType("a", "b", rt, new String[] { "a" }); TabularDataSupport t1 = new TabularDataSupport(tt); TabularDataSupport t2 = new TabularDataSupport(tt); // we need to make payload implement composite data // it's very likely that there are other proxy impls that could be used AdvisedSupport as = new AdvisedSupport(); as.setTarget(payload); InvocationHandler delegateInvocationHandler = (InvocationHandler) Reflections .getFirstCtor("org.springframework.aop.framework.JdkDynamicAopProxy").newInstance(as); InvocationHandler cdsInvocationHandler = Gadgets .createMemoizedInvocationHandler(Gadgets.createMap("getCompositeType", rt)); CompositeInvocationHandlerImpl invocationHandler = new CompositeInvocationHandlerImpl(); invocationHandler.addInvocationHandler(CompositeData.class, cdsInvocationHandler); invocationHandler.setDefaultHandler(delegateInvocationHandler); final CompositeData cdsProxy = Gadgets.createProxy(invocationHandler, CompositeData.class, ifaces); JSONObject jo = new JSONObject(); Map m = new HashMap(); m.put("t", cdsProxy); Reflections.setFieldValue(jo, "properties", m); Reflections.setFieldValue(jo, "properties", m); Reflections.setFieldValue(t1, "dataMap", jo); Reflections.setFieldValue(t2, "dataMap", jo); return Gadgets.makeMap(t1, t2); }
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
private TabularData prepareMxMBeanMapData(String... keyAndValues) throws OpenDataException, MalformedObjectNameException { CompositeTypeAndJson ctj = new CompositeTypeAndJson(STRING, "key", null, OBJECTNAME, "value", null); TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "key" }, ctj); TabularData data = new TabularDataSupport(taj.getType()); for (int i = 0; i < keyAndValues.length; i += 2) { CompositeData cd = new CompositeDataSupport(ctj.getType(), new String[] { "key", "value" }, new Object[] { keyAndValues[i], new ObjectName(keyAndValues[i + 1]) }); data.put(cd);/*from w ww . ja v a 2 s. c o m*/ } return data; }
From source file:com.opengamma.engine.management.ViewProcessStatsProcessor.java
public ViewProcessStatsProcessor(CompiledViewDefinition compiledViewDef, ViewComputationResultModel viewComputationResultModel) { _compiledViewDef = compiledViewDef;//from www. j av a2 s . c om _viewComputationResultModel = viewComputationResultModel; _successCountBySec = new HashMap<>(); _failureCountBySec = new HashMap<>(); _errorCountBySec = new HashMap<>(); _totalCountBySec = new HashMap<>(); _successCount = new HashMap<>(); _failureCount = new HashMap<>(); _errorCount = new HashMap<>(); _totalCount = new HashMap<>(); _successes = new MutableInt(0); _failures = new MutableInt(0); _errors = new MutableInt(0); _total = new MutableInt(0); _columnReqBySecTypeRowType = ColumnRequirementBySecurityType.getCompositeType(); _columnReqBySecurityTypeTabularType = ColumnRequirementBySecurityType.getTablularType(); _columnReqRowType = ColumnRequirement.getCompositeType(); _columnReqTabularType = ColumnRequirement.getTabularType(); _resultsBySecurityType = new TabularDataSupport(_columnReqBySecurityTypeTabularType); _resultsByColumnRequirement = new TabularDataSupport(_columnReqTabularType); }
From source file:org.xmatthew.spy2servers.jmx.AbstractComponentViewMBean.java
protected TabularData tabularDataWrapFromMessages(List<Message> messages) throws OpenDataException { if (CollectionUtils.isBlankCollection(messages)) { return null; }/*from ww w.ja v a 2s. c om*/ messages = Collections.synchronizedList(messages); String[] itemNames = Message.getKeys().toArray(new String[Message.getKeys().size()]); String[] itemDescriptions = itemNames; OpenType[] itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING }; CompositeType compositeType = new CompositeType("MessageList", "list spyed messages", itemNames, itemDescriptions, itemTypes); TabularType tt = new TabularType("MessageList", "MessageList", compositeType, itemNames); TabularDataSupport rc = new TabularDataSupport(tt); for (Message message : messages) { try { rc.put(new CompositeDataSupport(compositeType, message.getFileds())); } catch (Exception e) { throw new OpenDataException(e.getMessage()); } } return rc; }
From source file:org.jolokia.converter.object.TabularDataConverter.java
private TabularData convertToTabularTypeFromMap(TabularType pType, JSONObject pValue) { CompositeType rowType = pType.getRowType(); // A TabularData is requested for mapping a map for the call to an MXBean // as described in http://download.oracle.com/javase/6/docs/api/javax/management/MXBean.html // This means, we will convert a JSONObject to the required format TabularDataSupport tabularData = new TabularDataSupport(pType); @SuppressWarnings("unchecked") Map<String, String> jsonObj = (Map<String, String>) pValue; for (Map.Entry<String, String> entry : jsonObj.entrySet()) { Map<String, Object> map = new HashMap<String, Object>(); map.put("key", getDispatcher().convertToObject(rowType.getType("key"), entry.getKey())); map.put("value", getDispatcher().convertToObject(rowType.getType("value"), entry.getValue())); try {/* ww w .j ava 2 s . c o m*/ CompositeData compositeData = new CompositeDataSupport(rowType, map); tabularData.put(compositeData); } catch (OpenDataException e) { throw new IllegalArgumentException(e.getMessage(), e); } } return tabularData; }