List of usage examples for javax.management.openmbean CompositeDataSupport CompositeDataSupport
public CompositeDataSupport(CompositeType compositeType, String[] itemNames, Object[] itemValues) throws OpenDataException
Constructs a CompositeDataSupport instance with the specified compositeType , whose item values are specified by itemValues[] , in the same order as in itemNames[] .
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
private TabularData getComplexTabularData() throws OpenDataException { CompositeTypeAndJson ctj = new CompositeTypeAndJson(STRING, "name", null, STRING, "firstname", null, INTEGER, "age", null, BOOLEAN, "male", null); TabularTypeAndJson taj = new TabularTypeAndJson(new String[] { "name", "firstname" }, ctj); TabularData data = new TabularDataSupport(taj.getType()); data.put(new CompositeDataSupport(ctj.getType(), new String[] { "name", "firstname", "age", "male" }, new Object[] { "meyer", "xaver", 12, true })); data.put(new CompositeDataSupport(ctj.getType(), new String[] { "name", "firstname", "age", "male" }, new Object[] { "meyer", "zensi", 28, false })); data.put(new CompositeDataSupport(ctj.getType(), new String[] { "name", "firstname", "age", "male" }, new Object[] { "huber", "erna", 18, false })); return data;//w w w . j a va2 s .c o m }
From source file:org.apache.qpid.server.jmx.mbeans.QueueMBean.java
public CompositeData viewMessageContent(long messageId) throws IOException, JMException { QueueEntry entry = getMessage(messageId); if (entry == null) { throw new OperationsException( "AMQMessage with message id = " + messageId + " is not in the " + _queue.getName()); }/*from ww w . j a v a 2s . c om*/ ServerMessage serverMsg = entry.getMessage(); final int bodySize = (int) serverMsg.getSize(); byte[] msgContent = new byte[bodySize]; ByteBuffer buf = ByteBuffer.wrap(msgContent); int stored = serverMsg.getContent(buf, 0); if (bodySize != stored) { LOGGER.error(String.format( "An unexpected amount of content was retrieved " + "(expected %d, got %d bytes) when viewing content for message with ID %d " + "on queue '%s' in virtual host '%s'", bodySize, stored, messageId, _queue.getName(), _vhostMBean.getName())); } AMQMessageHeader header = serverMsg.getMessageHeader(); String mimeType = null, encoding = null; if (header != null) { mimeType = header.getMimeType(); encoding = header.getEncoding(); } Object[] itemValues = { messageId, mimeType, encoding, msgContent }; return new CompositeDataSupport(MSG_CONTENT_TYPE, VIEW_MSG_COMPOSIT_ITEM_NAMES_ARRAY, itemValues); }
From source file:org.jolokia.converter.json.TabularDataExtractorTest.java
private TabularData getMapTabularData(OpenType keyType, Object... keyAndValues) throws OpenDataException { CompositeTypeAndJson ctj = new CompositeTypeAndJson(keyType, "key", null, STRING, "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], keyAndValues[i + 1] }); data.put(cd);/* ww w .j a va 2 s . c o m*/ } return data; }
From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java
/** * Method to display a list of messages when browsed. * * @param metadataList the list of message metadata * @return Composite data array of properties of all messages * @throws MBeanException if an OpenDataException occurs while mapping JMS headers for the Message. *///from ww w .java 2 s. c o m private CompositeData[] getDisplayableMetaData(List<AndesMessageMetadata> metadataList, boolean includeContent) throws MBeanException { List<CompositeData> compositeDataList = new ArrayList<>(); try { for (AndesMessageMetadata andesMessageMetadata : metadataList) { Object[] itemValues = getItemValues(andesMessageMetadata, includeContent); if (null != itemValues) { CompositeDataSupport support = new CompositeDataSupport(_msgContentType, VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.toArray( new String[VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.size()]), itemValues); compositeDataList.add(support); } } } catch (OpenDataException exception) { throw new MBeanException(exception, "Error occurred when formatting message in queue."); } return compositeDataList.toArray(new CompositeData[compositeDataList.size()]); }
From source file:org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier.java
@Override public TabularData getIndexPathMapping() { TabularDataSupport tds;/*from w ww .j av a 2s.com*/ try { TabularType tt = new TabularType(IndexMappingData.class.getName(), "Lucene Index Stats", IndexMappingData.TYPE, new String[] { "jcrPath" }); tds = new TabularDataSupport(tt); for (LocalIndexDir indexDir : indexRootDirectory.getAllLocalIndexes()) { String size = humanReadableByteCount(indexDir.size()); tds.put(new CompositeDataSupport(IndexMappingData.TYPE, IndexMappingData.FIELD_NAMES, new String[] { indexDir.getJcrPath(), indexDir.getFSPath(), size })); } } catch (OpenDataException e) { throw new IllegalStateException(e); } catch (IOException e) { throw new IllegalStateException(e); } return tds; }
From source file:com.cyberway.issue.crawler.Heritrix.java
protected TabularData makeJobsTabularData(List jobs) throws OpenDataException { if (jobs == null || jobs.size() == 0) { return null; }/*from www .ja v a2 s . com*/ TabularData td = new TabularDataSupport(this.jobsTabularType); for (Iterator i = jobs.iterator(); i.hasNext();) { CrawlJob job = (CrawlJob) i.next(); CompositeData cd = new CompositeDataSupport(this.jobCompositeType, JOB_KEYS, new String[] { job.getUID(), job.getJobName(), job.getStatus() }); td.put(cd); } return td; }